For the complete documentation index, see llms.txt. Prefer markdown by appending.mdto documentation URLs or sendingAccept: text/markdown.
Project structure
Understand the Edge Kit layout. Where routes, modules, infrastructure adapters, the database, and Cloudflare config live.
Edge Kit is a single package, not a monorepo. Everything for the Worker lives in one repository root, so there are no workspaces or internal packages to wire up.
Repository structure
Two layers for app code
App code is split into infrastructure and features, and src/routes stays a thin URL map on top:
| Layer | Owns | Examples |
|---|---|---|
src/lib/ | Shared adapters reused by many features | auth, billing, email, kv, queue, storage, log, i18n |
src/modules/<f>/ | One product capability end-to-end | admin, auth, billing, dashboard, marketing, user |
src/routes/ | URL composition only | pages, webhooks, OAuth catch-alls |
src/db/ | Tables and client | Drizzle schema |
Add new capabilities under src/modules/<feature>/ instead of creating new top-level folders like src/payment/ or src/mail/.
Routes
src/routes holds TanStack Router file routes:
Individual pages call createServerFn handlers from modules. Keep src/routes/api for webhooks and other inbound HTTP only.
Generated files
Never edit src/routeTree.gen.ts, worker-configuration.d.ts, src/lib/i18n/, .content-collections/, or src/db/schema/auth.ts by hand. They're regenerated by Vite, vp run cf-typegen, Paraglide, content collections, and pnpm db:generate.
vite.config.ts is also where formatting, linting, Vitest, the pre-commit check, and the cached cf-typegen, generate-routes, and content tasks are configured.
Take a look at the feature recipe to see how these layers come together in a new notes module.
How is this guide?
Last updated on