Project structure
A map of a scaffolded project. Exact contents depend on the features you selected — feature-specific directories only exist when their feature is on.
Top level
my-saas-app/
├── app/ # Next.js App Router
│ ├── (auth)/ # login, register, verify, reset
│ ├── (dashboard)/ # chat + settings (behind sidebar shell)
│ ├── (admin)/ # platform-owner portal (admin-portal feature)
│ ├── api/ # route handlers
│ │ ├── auth/ # better-auth handler
│ │ ├── ai/ # chat + generate
│ │ ├── billing/ # checkout, portal, webhook
│ │ └── admin/ # admin APIs
│ ├── layout.tsx
│ ├── page.tsx # marketing landing page (/)
│ └── globals.css
├── components/ # shared UI
│ └── ui/ # shadcn/ui primitives
├── lib/ # server + shared logic
│ ├── auth.ts # better-auth server config
│ ├── auth-client.ts # browser auth client
│ ├── db/schema.ts # all Drizzle tables
│ ├── ai/ # provider wiring, tools, metering
│ ├── billing/ # stripe/* + plans.ts
│ ├── email/ # resend.ts (email feature)
│ └── rate-limit.ts # rate-limiting feature
├── drizzle/ # generated migrations
├── proxy.ts # route protection (Next.js 16 Proxy)
├── docker-compose.yml # local Postgres (port 5432)
├── .env.example # env template (feature-aware)
└── package.jsonRoute groups
| Group | URL | Purpose |
|---|---|---|
| — | / | Marketing landing page. |
(auth) | /login, /register, … | Authentication. |
(dashboard) | /chat, /settings, … | The app, behind the sidebar shell. |
(admin) | /admin | Platform-owner portal, role-gated. |
Conventions
- Import alias —
@/*maps to the project root (e.g.@/lib/auth). - TypeScript is
strict. lib/billing/plans.tsis the single source of truth for plans — never hardcode plan data elsewhere.
This is Next.js 16 / React 19 / Tailwind v4. The Middleware → Proxy
rename (proxy.ts) is one of several differences from older Next.js. Check the
installed Next.js docs when customising framework-level behaviour.