Repository navigation
Self hosting
Overturn is one API service (NestJS, Node 22) and one web app (Next.js) on Postgres 16 with pgvector. Background jobs (replay, implicit approval, cache purge, retraining) run on pg-boss inside the API process. No Redis, no queues to operate.
cp .env.example .env
docker compose up -d
open http://localhost:3000The API runs migrations at boot. Sign in with your email: without RESEND_API_KEY the magic link is printed in the API log (docker compose logs api) and shown on the login page.
| Variable | Service | Purpose |
|---|---|---|
DATABASE_URL |
api | Postgres 16 with CREATE EXTENSION vector allowed |
PORT |
api | default 4000 |
WEB_URL |
api | public URL of the web app, used in magic links and cookie settings |
AUTH_SECRET |
api | any long random string |
RESEND_API_KEY, EMAIL_FROM
|
api | magic-link email; optional in dev |
OPENAI_API_KEY, ANTHROPIC_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY, OPENROUTER_API_KEY, TOGETHER_API_KEY
|
api | replay targets and the judge/embedding models |
OPENAI_BASE_URL |
api | point the OpenAI provider at a gateway |
LOCAL_MODEL_BASE_URL, LOCAL_MODEL_API_KEY
|
api | any OpenAI-compatible server (vLLM, Ollama, TGI, LM Studio); replay with local/<model>. Air-gapped replay needs only this: the lexical example retrieval and the structured scorers need no key |
TOGETHER_PROJECT_ID |
api | with it, trained models get a dedicated Together endpoint before the gate |
JOBS_DISABLED |
api |
1 to run without pg-boss (replays then run inline in the request process) |
LOG_LEVEL |
api | fatal … trace |
OVERTURN_API_URL |
web | the URL the browser uses to reach the API (read at runtime) |
Cookies: when WEB_URL is https://…, the session cookie is Secure; SameSite=None so the web app and API can live on different hosts. Put both behind one domain (app.example.com and api.example.com) or the same reverse proxy.
See railway/: a Postgres plugin plus two services built from apps/api/Dockerfile and apps/web/Dockerfile. A deploy workflow (.github/workflows/deploy-railway.yml) ships main when RAILWAY_TOKEN and the RAILWAY_DEPLOY=true variable are set.
pnpm install && pnpm build
pnpm db:migrate
pnpm --filter @overturn-ai/api start # node apps/api/dist/main.js
OVERTURN_API_URL=http://localhost:4000 pnpm --filter @overturn-ai/web start-
Migrations are plain SQL in
apps/api/drizzle/, applied bypnpm db:migrate(or at container boot). Never auto-applied by the running API. -
Retention: a daily job (03:23 UTC) deletes runs older than
retentionDaysthat back no case, with their steps and corrections. Runs behind a case are kept: they are the evidence. -
Review webhook:
reviewWebhookUrl(Slack incoming-webhook format) gets every completed run once (runs.notified_at) and every training/gate event; a failed POST is logged, not retried. -
Cache: model responses for replay live in
response_cache(24h TTL, purged hourly). -
Scaling: the API is stateless; pg-boss coordinates replay jobs through Postgres, so several API replicas behind a load balancer share one queue. Replays are the only CPU-heavy work; they run
PROVIDER_CONCURRENCYmodel calls in parallel per replica. A 1 vCPU / 1 GB API and a 1 GB Postgres handle tens of teams; grow Postgres first (runs and steps are the bulk), then replicas. -
Backups: it is one Postgres database;
pg_dumpis the whole story. Response cache rows are disposable.