SaaS Dashboard Architecture: A Practical Blueprint
Most SaaS dashboards start clean and turn into spaghetti by month three. A little architecture up front keeps the codebase navigable as features pile up.
Separate marketing from the app
Keep public marketing pages (home, pricing, blog) and the authenticated app in clearly separated route groups. They have different layouts, different auth requirements, and different performance profiles — marketing wants SEO, the app wants interactivity.
A single data layer
Put all database access behind a `lib/` module of typed functions rather than querying Prisma directly from components. This gives you one place to add caching, authorization checks, and logging — and makes the app far easier to test and refactor.
The layers of a dashboard
- Auth & session — who is this, and what can they do?
- Data layer — typed queries and mutations, one module per domain.
- UI — server components for layout and data, client islands for interactivity.
- Billing — subscription state that gates features.
- Admin — a separate, role-gated surface for you to manage the product.
Gate features by plan
Read the user's subscription once, high in the tree, and pass entitlements down. Check them again on the server for any action that costs money or touches limits. Never rely on hiding a button in the UI as your only guard.
KitCraft's SaaS starter kits ship this exact structure — separated marketing and app, a typed data layer, auth, billing, and a role-gated admin — so you inherit a maintainable architecture instead of inventing one.
