DEV Community

CodeWithDhanian
CodeWithDhanian

Posted on

How to Structure Your Fullstack Project with Next.js 15 and TypeScript β€” The Modern Way ⬇️

Grab the Full Ebook Here β†’

πŸ“ nextjs-fullstack-app/
β”œβ”€β”€ πŸ“ app/ (App Router - Next.js 15)
β”‚   β”œβ”€β”€ πŸ“ api/ (Server-side API Routes)
β”‚   β”‚   β”œβ”€β”€ πŸ“ auth/
β”‚   β”‚   β”‚   └── πŸ“„ route.ts
β”‚   β”‚   └── πŸ“ users/
β”‚   β”‚       └── πŸ“„ route.ts
β”‚   β”œβ”€β”€ πŸ“ dashboard/
β”‚   β”‚   └── πŸ“„ page.tsx
β”‚   β”œβ”€β”€ πŸ“ login/
β”‚   β”‚   └── πŸ“„ page.tsx
β”‚   β”œβ”€β”€ πŸ“ signup/
β”‚   β”‚   └── πŸ“„ page.tsx
β”‚   β”œβ”€β”€ πŸ“„ layout.tsx
β”‚   └── πŸ“„ page.tsx
β”‚
β”œβ”€β”€ πŸ“ components/ (UI Components)
β”‚   β”œβ”€β”€ πŸ“„ Header.tsx
β”‚   β”œβ”€β”€ πŸ“„ Footer.tsx
β”‚   └── πŸ“„ Sidebar.tsx
β”‚
β”œβ”€β”€ πŸ“ lib/ (Utilities & Server Functions)
β”‚   β”œβ”€β”€ πŸ“„ db.ts (Prisma/PostgreSQL setup)
β”‚   └── πŸ“„ auth.ts
β”‚
β”œβ”€β”€ πŸ“ prisma/
β”‚   β”œβ”€β”€ πŸ“„ schema.prisma
β”‚   └── πŸ“„ seed.ts
β”‚
β”œβ”€β”€ πŸ“ styles/
β”‚   β”œβ”€β”€ πŸ“„ globals.css
β”‚   └── πŸ“„ theme.css
β”‚
β”œβ”€β”€ πŸ“ public/
β”‚   └── πŸ“„ favicon.ico
β”‚
β”œβ”€β”€ πŸ“ types/
β”‚   └── πŸ“„ index.d.ts
β”‚
β”œβ”€β”€ πŸ“„ middleware.ts
β”œβ”€β”€ πŸ“„ next.config.js
β”œβ”€β”€ πŸ“„ tsconfig.json
β”œβ”€β”€ πŸ“„ tailwind.config.ts
β”œβ”€β”€ πŸ“„ .env
β”œβ”€β”€ πŸ“„ .gitignore
└── πŸ“„ package.json
Enter fullscreen mode Exit fullscreen mode

Explanation of Key Directories:

1️⃣ app/: App Router & Pages (Next.js 15)

➑️ api/: Server-side route handlers (e.g., auth, CRUD logic).

➑️ dashboard/, login/, signup/: Route-specific pages.

➑️ layout.tsx: Root layout shared across all pages.

➑️ page.tsx: Main homepage.

2️⃣ components/:

➑️ Reusable UI parts like Header, Footer, and Sidebar.

3️⃣ lib/:

➑️ Utilities like db.ts for Prisma & PostgreSQL, auth.ts for server actions.

4️⃣ prisma/:

➑️ schema.prisma: Data models.

➑️ seed.ts: Sample data for development.

5️⃣ styles/:

➑️ Tailwind CSS setup and global styles.

6️⃣ public/:

➑️ Static files like images, icons, etc.

7️⃣ types/:

➑️ TypeScript type declarations for props and APIs.

Other Essentials:

  • .env: Environment variables.
  • tsconfig.json: TypeScript config.
  • tailwind.config.ts: Tailwind settings.
  • next.config.js: Next.js app settings.

Use this structure to build scalable, production-ready Fullstack apps using Next.js 15, TypeScript, Prisma, and PostgreSQL.

Get the complete guide here:

Build Fullstack Apps with Next.js 15 and TypeScript β€” The Modern Way

Bookmark it.

Follow @e_opore πŸ”” for more project structures and development blueprints!

Top comments (0)