Consent Flow Legal Risk Analysis monorepo built with Bun, Turborepo, Next.js, Effect, T3 Env, Drizzle, and shared workspace packages.
- Bun
1.3.11or newer - Node.js
18or newer
Install dependencies:
bun installLink the Vercel project and pull development envs:
vercel link
vercel env pull apps/web/.env.localRun the app locally:
bun run devRun the main quality checks:
bun run check
bun run testApply formatting and autofixes:
bun run fixbun run devrunsturbo run devbun run buildrunsturbo run buildbun run db:generategenerates Drizzle SQL migrations inpackages/db/drizzlebun run db:migrateapplies committed Drizzle migrationsbun run lintrunsturbo run lintbun run check-typesrunsturbo run check-typesbun run checkruns Ultracite checksbun run fixformats and applies safe fixes with Ultracitebun run testruns Bun tests and succeeds when the repo has no tests yet
apps/webcontains the Next.js apppackages/envcontains the shared T3 Env validation contractpackages/aiowns the Vercel AI SDK analyzer boundarypackages/cacheowns Upstash Redis runtime config and cache helperspackages/dbowns PlanetScale Postgres schema, migrations, and scan persistencepackages/storageowns Vercel Blob runtime config and artifact helperspackages/kernel-appowns Kernel runtime config and browser integration boundarypackages/observabilityowns evlog runtime config and server logging helperspackages/workflowsowns scan orchestrationpackages/typescript-configcontains shared TypeScript base configs
Vercel is the source of truth for secrets and runtime configuration. Do not hand-maintain committed env files. The checked-in .env.example is documentation only.
- PlanetScale
- Upstash Redis
- Vercel Blob
- Kernel
- Vercel AI Gateway
Only app-managed secrets and service endpoints belong in the env contract. Model selection, logging presentation, and Kernel behavior defaults are owned by code.
DATABASE_URL
KERNEL_API_KEY
AI_GATEWAY_API_KEY
KV_REST_API_URLKV_REST_API_TOKEN
BLOB_READ_WRITE_TOKEN
- Run
vercel linkin the repo root. - Add the env vars above in the Vercel project for Development, Preview, and Production.
- Keep Production complete first, then mirror the same secret names into Preview and Development with environment-appropriate values.
- Pull local development envs with
vercel env pull apps/web/.env.local. - Start local development with
bun run dev.
- use low-risk development credentials
- use a development PlanetScale database or branch
- use a development Upstash database
- use a development Blob token if separated
- use preview-safe credentials
- keep the same env names as production
- use isolated preview services where practical
- use production-only credentials
- use the production PlanetScale database
- use the production Upstash database
- use the production Blob token
The typed runtime env contract lives in @cflra/env.
It exports:
serverEnvpublicEnvserverEnvSchemapublicEnvSchema
Service packages consume only the env fields they own:
@cflra/aireads the Vercel AI Gateway key and owns the hard-coded model selection@cflra/kernelreads Kernel configuration@cflra/cachereads Upstash Redis configuration@cflra/storagereads Blob configuration@cflra/dbreads PlanetScale configuration@cflra/dbuses Drizzle ORM with committed SQL migrations@cflra/observabilityuses code-owned logging defaults@cflra/workflowscomposes the services and calls the analyzer boundary
- The app derives its public base URL from request headers or
VERCEL_URLwhen needed. - The AI model is hard-coded to
google/gemini-2.5-proin@cflra/ai. - Kernel environment mode is derived from
NODE_ENV. - evlog formatting defaults are code-owned: pretty logs in development and structured logs in production.
The pre-commit hook formats staged files with Ultracite and runs the test command. In a fresh repo with no tests, the test step still passes.
- Add an app under
apps/ - Add shared packages under
packages/ - Define
build,lint,check-types, andtestscripts in each workspace that needs them