Chapter 01Turborepo
A monorepo with dependency rules
The four Next.js apps and the API live in one repository, with Turborepo and pnpm workspaces. Apps import packages; packages never import apps. Among the product apps, only the API imports packages/db, so no site touches the database directly: business rules and cache invalidation live in one place.
The Next.js apps never touch the database. They read and write through the API, using the types from packages/shared.
- packages/shared depends only on zod
- Turbo cache in CI: what didn't change doesn't run again