The evidence workspace for research teams. Find the literature, screen it against your criteria, extract the data and publish what you learn. Openscholar searches OpenAlex's 250 million works and runs at discover.openscholar.ai.
This repository holds the app, its Convex backend, and the marketing site at openscholar.ai (marketing/). Evidence Communities, the public research libraries that teams set up from Openscholar, live in OpenDevEd/evidence-community.
- Search. Ask in plain language or write Boolean queries, filter by year, region, language, type and citations, and follow who cites what.
- Screening. Set your inclusion questions once and screen every paper of a search against them, with AI or by hand.
- Extraction. Pull the answers you need out of each paper's text or PDF into a table you can sort, check and export.
- Research assistant. Hand off the groundwork in a chat that can do anything you can do in the app.
- Evidence Communities. Turn a collection into a public library with its own address, search, maps and answers linked to their sources.
- Reports. Publish a report with a DOI through Crossref or Zenodo.
- Teams. Workspaces, roles, shared screenings and a record of who changed what.
- Next.js 16 (App Router), React 19, Tailwind CSS 4
- Convex for data, functions and scheduling
- Clerk for sign-in
- Autumn (self-hosted) on Stripe for plans and credits
- OpenRouter, OpenAI, Anthropic and Google models for AI features
You need Node.js 22 or later, a Convex deployment (Convex Cloud or self-hosted), and a Clerk application. Billing needs an Autumn server and a Stripe account, and AI features need an OpenRouter key.
git clone https://github.com/OpenDevEd/openscholar.git
cd openscholar
npm install
cp .env.example .env.local.env.example lists every setting. The first part goes in .env.local for the Next.js app. The second part is set on the Convex deployment with npx convex env set NAME value.
npx convex dev # push the backend to your deployment and watch for changes
npm run dev:web # the app at http://localhost:3000Useful commands:
npm test # unit tests (Vitest)
npm run build # production build
npm run check:ui-rules # the UI rules CI enforcesnpm run dev and npm run convex:push are for the core team: they only run against Openscholar's shared development deployment.
- Next.js auth edge protection is configured in
proxy.ts. - Public route policy is centralized in
lib/auth/public-routes.tsand shared by bothproxy.tsand client route gating. - Middleware matcher coverage follows Clerk guidance (including API/TRPC) and still enforces protected-by-default behavior.
- Clerk auth routes are canonicalized to
/sign-inand/sign-up. - Sign out is handled by the Clerk client API in UI components.
- Convex JWT verification is configured in
convex/auth.config.tswithCLERK_JWT_ISSUER_DOMAINandapplicationID: "convex". - Protected App Router rendering is guarded by
components/auth/auth-route-gate.tsx, which enforces a no-flicker auth bootstrap flow. - Client auth readiness is exposed via
useAuthReadiness()fromcomponents/providers/convex-provider.tsx. - Use auth-aware query wrappers from
lib/auth/use-auth-query.ts(useProtectedQuery,useProtectedPaginatedQuery,useOptionalAuthQuery) instead of directuseQuerycalls in UI. - Configure your Clerk webhook endpoint to
POST /webhooks/clerkon your Convex HTTP deployment URL. CLERK_WEBHOOK_SIGNING_SECRETmust be configured in every environment, including local development and deployed environments, or webhook verification will fail with401.CLERK_WEBHOOK_SIGNING_SECRETmust be the endpoint Signing Secret value from Clerk (starts withwhsec_); do not use API keys or frontend URL values.- Auth paths are
/sign-inand/sign-uponly. - Keep local
.env.localaligned with current auth env variables to avoid operator confusion.
- Plans, credit balances, subscriptions, and invoices live in a self-hosted
Autumn server, which talks to
Stripe. Plans, prices, credits, top-up bundles and which plans include
which features are all edited in Autumn's dashboard. Convex copies the
catalog into
billingCatalogevery five minutes, and the app reads it from there. Plan metadata sets what the dashboard has no field for:popular(true),highlights(one card line per line) and, on the top-up plan,bundles(credit amounts to offer). - A feature flag with
planFeatureis on only for users whose plan includes that Autumn feature.extraction.startneedsextraction. - Convex keeps a cached copy of each user's plan and balance in
billingAccountsfor reactive UI, and a log of every charge inbillingUsage. Design, trial results, and the data migration are inplans/autumn-billing/README.md. - Autumn sends its webhooks through the Svix server beside it. Add an
endpoint for
POST /webhooks/autumnon the Convex HTTP URL in Autumn's dashboard under Developer, Webhooks, and setAUTUMN_WEBHOOK_SECRETto its signing secret. Each event refreshes that workspace's cached copy, so plan changes made in the dashboard reach the app in seconds. Autumn sends no event for a balance edit; the billing page refreshes the copy when it opens. - Autumn's own Stripe webhook points at the Autumn server. Openscholar's
Stripe webhook (
POST /webhooks/stripeon the Convex HTTP URL) refreshes the cached card and removes credits for refunded top-ups. Subscribe it to:customer.updated,payment_method.attached,payment_method.detached,charge.refunded. STRIPE_WEBHOOK_SECRETis that endpoint's signing secret.- The billing page pages through charges using a count kept in the
usageAggaggregate, under the workspace that paid. Each charge is counted as it's recorded.
- Admins see an Admin group in settings: feature switches, which models users can pick, and the admin list. The server refuses admin changes from everyone else.
- Make the first admin of a deployment from the command line:
npx convex run admins/mutations:grant '{"email": "you@example.org"}'. After that, admins add each other in settings. An invite by email becomes an admin when that person signs up; it's sent through the platform mail settings (EL_SMTP_*). - Set
AUTUMN_DASHBOARD_URLon the Convex deployment to show the Plans link to Autumn's dashboard. - Settings, Admin, AI models sets the model and reasoning effort each preset
(Cheap, Fast, Balanced, Intelligent) runs every task on. Users pick a preset,
or Custom to choose each task themselves and use their own keys.
npx convex run aiModelConfig/internal:seedadds the starting picks to a deployment that doesn't have them; it never replaces an existing pick. - Screening and Screen All can run on Jev (
typesafe/jev-1.13), TypeSafe's decision model, through OpenRouter's Decisions API: one call per paper. When a user's Screen All pick is Jev, their extraction jobs send yes/no questions to it too. The catalog sync adds Jev, which isn't in OpenRouter's model list.
-
Run auth E2E locally:
npm run test:e2e:auth
-
Required E2E environment variables:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYCLERK_PUBLISHABLE_KEY(or rely on auto-mapping fromNEXT_PUBLIC_CLERK_PUBLISHABLE_KEYine2e/global.setup.ts)CLERK_SECRET_KEYNEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-inNEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-upNEXT_PUBLIC_CONVEX_URLE2E_CLERK_USER_EMAILE2E_CLERK_USER_PASSWORD- Optional:
E2E_BASE_URL(defaults tohttp://localhost:3000)
Playwright starts a fresh server with Next's test proxy enabled and does not reuse
a running preview. For another port, set both E2E_BASE_URL and
PLAYWRIGHT_WEB_SERVER_COMMAND, for example http://localhost:3478 and
npm run build && npm run start -- --hostname localhost --port 3478.
E2E specs import test and expect from e2e/test.ts so every test initializes
the proxy. Responses stay real unless a spec supplies a network fixture.
- CI workflow:
.github/workflows/ci.ymlruns:unit-and-build(npm run test,npm run build)e2e-auth(npm run test:e2e:auth)
- Branch protection should require the aggregate
CIcheck. It covers the required jobs while allowing runtime E2E to skip documentation-only pull requests.
/app- Next.js App Router pages and layouts/components- React components (shadcn/ui, custom)/convex- Backend functions, schema, and cron jobs/lib- Utilities, stores (Zustand), and types
See CONTRIBUTING.md. To report a security problem, see SECURITY.md.
Openscholar is free software under the GNU Affero General Public License v3.0. If you run a changed version for other people, for example as a website, you must offer them its source code under the same licence.