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

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

Explorer

  • .git…
  • .devcontainernew
  • devcontainer.jsonnew
  • .huskynew
  • pre-commitnew
  • commit-msgnew
  • .next…, not committed
  • .vscodenew
  • settings.jsonnew
  • extensions.jsonnew
  • launch.jsonnew
  • coverage…new, not committed
  • node_modules…, not committed
  • prismanew
  • schema.prismanew
  • seed.tsnew
  • public
  • file.svg
  • globe.svg
  • next.svg
  • vercel.svg
  • window.svg
  • logo.svgnew
  • src
  • generated…new, not committed
  • proxy.tsnew
  • .editorconfig
  • .envnew, not committed
  • .env.examplenew
  • .gitignore
  • .nvmrc
  • .prettierignorenew
  • .prettierrc.jsonnew
  • AGENTS.md
  • CLAUDE.mdnew
  • README.md
  • commitlint.config.mjsnew
  • docker-compose.ymlnew
  • eslint.config.mjs
  • next-env.d.ts, not committed
  • next.config.ts
  • package-lock.json
  • package.json
  • prisma.config.tsnew
  • tsconfig.json
  • vitest.config.mtsnew
  • vitest.setup.tsnew
  1. # Create the app with the recommended defaults, inside src/

    npx create-next-app@latest my-app --yes --src-dir
  2. # Add the database client, auth and validation

    npm install @prisma/client@7 @prisma/adapter-pg better-auth zod server-only
  3. # Add the Prisma CLI (pinned to 7) and helpers

    npm install -D prisma@7 @next/env tsx
  4. # Set up Prisma for PostgreSQL

    npx prisma init --datasource-provider postgresql --output ../src/generated/prisma
  5. # Add the auth tables to schema.prisma

    npx auth@latest generate
  6. # Create and apply the first migration

    npx prisma migrate dev --name init
  7. # Add the React app layer (same as the frontend tree)

    npm install @tanstack/react-query next-themes sonner react-hook-form @hookform/resolvers
  8. # Add tests: unit, component and real-database integration

    npm install -D vitest @vitejs/plugin-react jsdom vite-tsconfig-paths @testing-library/react @testing-library/dom @testing-library/user-event @testing-library/jest-dom msw @testcontainers/postgresql
  9. # Add end-to-end tests (Playwright)

    npm init playwright@latest