Skip to content

Core server packages

Owns the Kysely client (pg), SQL migrations, and generated types. Regenerate types with db:codegen before type checks. Schema changes may require service updates, contract updates, native model regeneration, seed changes, and docs updates.

Owns routers and service behavior. Keep endpoint shape in routers and business logic in services. Generated API docs read router source on every docs build.

Owns shared Better Auth configuration. Coordinate changes with web, API, mobile trusted origins, and session/cookie docs.

Owns Knock translations, payload typing, and email layout. Worker and web both consume it, so payload drift breaks cross-app notification behavior.

Owns the env schemas: one Zod fragment per integration under src/fragments/ (databaseEnv, valkeyEnv, stripeEnv, …) composed into one schema per host under src/hosts/ (apiEnv, workerEnv, webEnv). Each host calls its loader first thing at boot (loadApiEnv(), loadWorkerEnv(), loadWebEnv()) and gets a typed object; nothing is parsed at import time, so builds and tests are unaffected until a host actually starts. The boot is fail-fast (PRO-170, decision D3, since Wave 2): a missing or malformed value is reported on stderr, names and issue codes only, and the host refuses to start; CONFIG_ENFORCE=false is the escape hatch that logs the same report and starts anyway, with the failed keys reading as unset. Keys a laptop may leave unset but a deployed tier must set (ORIGIN, PII_ENCRYPTION_KEY, …) are listed per host as requiredWhenDeployed and checked when NODE_ENV=production. The packages below the hosts cannot take a host’s object as an argument (the pg pool, the Valkey clients and the queue names are built at import, and the adapters are imported directly by hosts, services, scripts and tests), so they read sharedEnv instead: a typed, read-only view over every fragment, parsed by the same schemas, where an invalid value reads as unset. Every shared package reads it (@repo/api, @repo/integrations, @repo/auth, @repo/cache, @repo/database, @repo/redis-search), and the worker’s job modules read the worker’s own env, so @repo/config is the only package whose source touches process.env. CI holds that line with bun run scripts/check-process-env.ts, which walks every host’s and package’s src/ and fails on process.env, Bun.env or SvelteKit’s $env/dynamic/private; ESLint shows the same rule in the editor. A host still has to declare what it reads: a key that is set and read through shared code on a host whose schema does not declare it is reported once as [config] <host>: shared code read <KEY>. Adding a variable means adding it to a fragment, documenting it in .env.example and the per-app .env.example, and (when a task needs it) turbo.json — bun run scripts/check-env-schema.ts fails on any of the three drifting.

Owns property search/index key formats, indexing utilities, and query behavior. Coordinate changes with worker sync jobs and property search UI expectations.