Project Structure
Authorization: Bearer lattice_sk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxDesign principle: mirrored test tree
Every source file's tests live at the same relative path under tests/, not next to the source. apps/gateway/server/routing/dispatch.ts is tested by tests/apps/gateway/server/routing/dispatch.test.ts. This keeps server/ and app/ free of *.test.ts noise and makes "does this file have a test" a single path transformation.
Design principle: server/ subdirectories are Nitro conventions
Both apps/gateway and apps/dashboard follow Nitro v3's server directory layout: routes/ for /-rooted handlers, api/ for /api-prefixed handlers (dashboard only — the gateway prefixes explicitly via its own routes/v1 and routes/management folders instead), middleware/, plugins/, and utils/. File-based routing means the path server/routes/management/v1/applications/[id]/index.get.ts maps directly to GET /management/v1/applications/:id.
Design principle: shared packages, not duplicated types
packages/api-contract exists because the gateway, the dashboard, and (indirectly) any future client all need the same request/response shapes. Rather than each app declaring its own ChatCompletionRequest type, both import from this workspace package. The same discipline applies to environment parsing, via the external @xcvzlabs/env package rather than ad-hoc process.env.FOO reads — see Shared Packages.
Where things are configured
| Concern | File |
|---|---|
| Gateway server directory, preset, error handler | apps/gateway/nitro.config.ts |
| Gateway environment schema | apps/gateway/server/utils/env.ts |
| Model registry (what models exist, fallbacks, pricing) | apps/gateway/server/registry/models.config.ts |
| Gateway database schema | apps/gateway/server/database/schema.ts |
| Dashboard Nuxt modules, app metadata | apps/dashboard/nuxt.config.ts |
| Dashboard auth (better-auth) | apps/dashboard/server/auth.config.ts |
| Dashboard environment schema | apps/dashboard/server/utils/env.ts |
| Dashboard database schema (better-auth tables only) | apps/dashboard/server/database/schema.ts |
| Lint rules | oxlint.config.ts |
| Format rules | oxfmt.config.ts |
| Test runner | vitest.config.ts |
| Pre-commit file filters | lint-staged.config.ts |