Cairn

Reference: environment variables

Every environment variable Cairn reads, grouped by concern. The canonical templates are the .env.example files at the repo root and in apps/web, apps/worker, and packages/db. Required means the app won't work without it in production.

Database

VariableRequiredUsed byPurpose
DATABASE_URLweb, worker, dbPostgres connection (pooled) used at runtime.
DATABASE_URL_UNPOOLED✅ (migrations)dbDirect (non-pooled) connection for drizzle-kit.
DATABASE_PUBLIC_URLoptionalworker, dbRailway public-proxy alternative to the unpooled URL.

Auth

VariableRequiredPurpose
BETTER_AUTH_SECRETSession encryption key. Generate: openssl rand -base64 32.
BETTER_AUTH_URLApp origin, e.g. http://localhost:3000.
NEXT_PUBLIC_APP_URLPublic app URL for the auth client + dashboard links.
CAIRN_PRODUCTION_URLlocal/preview proxyProduction Cairn origin that receives GitHub's registered callback. Ignored in production.
OAUTH_PROXY_SECRETOAuth proxyDedicated proxy key shared between production and local/preview. Do not reuse BETTER_AUTH_SECRET.
OAUTH_PROXY_TRUSTED_ORIGINSoptionalComma-separated preview or non-default local origins accepted by the proxy. Port 3000 is trusted automatically.

GitHub user authorization (sign-in)

VariableRequiredPurpose
GITHUB_CLIENT_IDOAuth client ID.
GITHUB_CLIENT_SECRETproduction or direct OAuthOAuth client secret. Not required by a local proxy client.

Callback URL: <app-url>/api/auth/callback/github. To keep only the production callback registered while developing locally, configure the OAuth proxy in both environments. GitHub returns to production, which exchanges the code and relays encrypted profile data to the local app.

GitHub App (repo access + webhooks)

VariableRequiredPurpose
GITHUB_APP_IDGitHub App ID.
GITHUB_APP_SLUGApp URL slug (used by the install flow).
GITHUB_APP_PRIVATE_KEYRSA private key (PEM). Keep the \n escapes or quote the whole PEM.
GITHUB_WEBHOOK_SECRETVerifies incoming webhook signatures.

Permissions: contents:read, issues:write, pull_requests:write, checks:write. Events: installation, installation_repositories, push, pull_request. Webhook URL: <app-url>/api/github/webhook.

AI models

VariableRequiredPurpose
GOOGLE_GENERATIVE_AI_API_KEYGemini — flow mapping + test generation.
ANTHROPIC_API_KEYoptionalClaude — auto-fix. Usually set per-environment in the dashboard.

Background jobs (Inngest)

VariableRequiredPurpose
INNGEST_EVENT_KEYprod onlyInngest event key. Empty in local dev (keyless dev server).
INNGEST_SIGNING_KEYprod onlyInngest signing key.

Artifact storage

VariableRequiredPurpose
STORAGE_DRIVERvolume (local/mounted dir) — the self-host default.
ARTIFACTS_DIR✅ (volume)Where run videos/traces are written; mount a persistent volume here.
ARTIFACTS_BEARER_TOKENShared token so the web app can proxy artifact reads from the worker.
WORKER_ARTIFACTS_URLwhen splitWorker's public URL, set when web + worker run on different hosts.

Email (weekly recap)

VariableRequiredPurpose
RESEND_API_KEYoptionalResend key. Without it, recaps are stored but not emailed.
RECAP_FROM_EMAILoptionalFrom address (a verified Resend domain).

Landing page

VariableRequiredPurpose
NEXT_PUBLIC_GITHUB_REPOoptionalPublic owner/repo for the Contribute button + star count.

Optional / advanced

VariablePurpose
CHAT_UPLOAD_DRIVER, BLOB_READ_WRITE_TOKENChat image uploads (vercel-blob / r2).
CAIRN_INSTRUMENT_*Production API-capture SDK (Cairn dogfooding its own API tracking).
PORTServer port (web 3000, worker 3100).