GitDiagram is one Next.js application. The UI and generation API run together; no second backend process is required.
- Node.js
20.9.0or newer, as required by Next.js 16 - Bun
1.3.11or a compatible1.3.x
node --version
bun --versionbun install
cp .env.example .envUse bun ci when you want an exact frozen-lockfile install, such as in CI.
Set these storage and coordination variables in .env:
R2_ACCOUNT_IDR2_ACCESS_KEY_IDR2_SECRET_ACCESS_KEYR2_PUBLIC_BUCKETR2_PRIVATE_BUCKETCACHE_KEY_SECRETUPSTASH_REDIS_REST_URLUPSTASH_REDIS_REST_TOKEN
Choose one AI provider:
- OpenAI:
AI_PROVIDER=openaiandOPENAI_API_KEY - OpenRouter:
AI_PROVIDER=openrouterandOPENROUTER_API_KEY
Optional generation controls include:
OPENAI_MODELOPENAI_COMPLIMENTARY_GATE_ENABLEDOPENAI_COMPLIMENTARY_DAILY_LIMIT_TOKENSOPENAI_COMPLIMENTARY_MODEL_FAMILYOPENROUTER_MODELOPENROUTER_SITE_URLOPENROUTER_APP_NAME
Optional GitHub authentication:
GITHUB_PATfor one tokenGITHUB_PATSfor a comma- or newline-separated token poolGITHUB_APP_IDorGITHUB_CLIENT_ID, plusGITHUB_PRIVATE_KEYandGITHUB_INSTALLATION_ID, for GitHub App authentication
Optional browser analytics:
NEXT_PUBLIC_POSTHOG_KEY
The default OpenAI configuration is:
AI_PROVIDER=openai
OPENAI_MODEL=gpt-5.6-terraAn OpenRouter example:
AI_PROVIDER=openrouter
OPENROUTER_API_KEY=...
OPENROUTER_MODEL=openai/gpt-5.6-terra
OPENROUTER_SITE_URL=http://localhost:3000
OPENROUTER_APP_NAME=GitDiagrambun run devThe application is available at http://localhost:3000. Next.js Route Handlers under /api/generate/* run in the same process.
For a production-mode local check:
bun run build
bun run startbun run lint
bun run typecheck
bun run test
bun run buildThe test suite includes real Mermaid parser contract tests for the deterministic graph compiler, API route tests, cancellation and quota tests, storage concurrency tests, and browser-rendering safety tests.
The primary deployment is Vercel with Bun as both the package manager and the server runtime for Route Handlers. The route-level runtime = "nodejs" declarations select Next.js's server runtime rather than Edge; the project-level bunVersion setting makes Vercel execute those Functions with Bun. Add the variables from .env.example to the Vercel project, then deploy:
vercel deploy
vercel deploy --prodLocal .env files and tooling artifacts are excluded by .vercelignore.
The same source can be redeployed to Railway later through Dockerfile and railway.json. Those files are an offline recovery recipe, not a live standby. The container uses Next.js standalone output, listens on Railway's injected PORT, runs as a non-root user, and checks /api/healthz before promotion. See deployment-failover.md for the recovery procedure.