Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.

Project structure · Full stack

Next.js full stack (database and auth) project structure

Opens with credits

One Next.js app that is both your frontend and your backend: pages render on the server, forms call Server Actions, and Route Handlers serve the few real HTTP endpoints (auth, webhooks, jobs, health). PostgreSQL through Prisma ORM, sign-in through Better Auth, background jobs with Inngest, and every database read goes through a small Data Access Layer that checks who is asking. The example features are invoices and clients for freelancers.

Curated by Tauseef FayyazIntermediate258 files and foldersNext.js 16.4, React 19.3, TypeScript 5Checked October 2026
Explore the filesPick any file to see what it is, why it exists and when you add it.

How it grows

Each stage opens the explorer there

  1. 1Day 1What the scaffold and your first hour give you26 files and folders
  2. 2GrowingWhat a real app with features and tests adds+143 files and folders
  3. ProductionWhat running it for real users adds+46 files and foldersOpens with credits
  4. ExpertWhat a team needs to keep it healthy for years+43 files and foldersOpens with credits

How it is organised

  • src/app is for routing only: page, layout, loading, error and route files. The real code for a feature lives in src/features/<feature>, so the URL tree stays easy to read.
  • Server first. Pages are Server Components that read data through the Data Access Layer; only interactive pieces are Client Components. Forms call Server Actions instead of hand-written API routes.
  • Route Handlers (route.ts) are only for real HTTP endpoints: the auth handler, payment webhooks, the background job endpoint, health checks, and a versioned API if a mobile app needs one.
  • All data access goes through a Data Access Layer: server-only functions that check the session, filter by owner and return only the fields a page needs. proxy.ts can redirect early, but it is never the security check.
  • Same split as the frontend tree: src/server holds server-only modules (database, auth, env, logger, jobs, rate limits), each importing "server-only"; src/lib holds code that is safe in the browser.
  • Group by feature (invoices, clients), and features never import each other. If invoices needs a client name, it reads it in its own query.
  • Prisma ORM over Drizzle here because its schema file and migrations are the easiest to read when you are learning. Drizzle (schema in TypeScript, closer to SQL) is an equally good choice; only prisma/ and src/server/db.ts would change.
  • Tests grow in layers: Vitest unit and component tests at Growing, integration tests against a real Postgres in a throwaway container plus Playwright journeys at Production, then contract, visual, accessibility and load tests at Expert.

At the top of the project

Open one in the explorer for the full story

Learn more on Sefism

Roadmaps, cheat sheets and projects that go with Next.js full stack (database and auth).

See 11 more
Checked against 20 official sources, October 2026. If something has changed, the docs win.Show sources

Picked from the other libraries by shared topics.

Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.

  • 1:1 Mentorship
  • Fresh Graduate Mentorship
  • Career Guidance

Brand deals, promos and partnerships: tauseeffayyaz@gmail.com