Skip to main content
Codebase

Architecture

Understand routes, server functions and shared application code.

Open MarkdownFull AI corpusFeedback

src/routes contains TanStack Router's file routes. src/routes/__root.tsx defines the document shell, metadata and global error handling. Marketing, authentication, dashboard and API routes live in the same route tree. src/router.tsx creates the router and vite.config.ts configures the TanStack Start, Content Collections, Tailwind and Nitro plugins.

Route guards run in beforeLoad: src/routes/dashboard.tsx loads the session, while organization and admin routes check membership or platform role. A beforeLoad guard can also run during client-side navigation, so it is not an authorization boundary for API requests. Server functions in src/server read the current request, and protected tRPC procedures check authorization again before accessing tenant data. The handlers in src/routes/api are thin HTTP adapters.

The product modules remain organized by responsibility: components for UI, lib/auth for Better Auth, lib/billing for Stripe and credits, trpc for typed APIs, and prisma plus lib/db for persistence. Keep database access and secrets in server functions, server-only modules or API handlers rather than code imported by the browser. The tRPC adapter is at src/routes/api/trpc/$.ts.

See the official routing guide, server functions guide and execution model.