A production-ready monorepo template for building modern full-stack TypeScript applications with NestJS backend, Next.js 16 frontend, Prisma ORM, and PostgreSQL database.
- ποΈ Modular Architecture - Scalable NestJS with dependency injection
- ποΈ Prisma ORM - Type-safe database access with PostgreSQL 16
- π Validation - Automatic DTO validation with class-validator
- π³ Docker - PostgreSQL via Docker Compose
- β Testing - Jest for unit tests, Playwright for E2E
- β‘ Turbopack - Lightning-fast development builds
- π¨ Component Library - 8+ production-ready UI components
- πͺ Custom Hooks - 15+ utility hooks (infinite scroll, keyboard nav, etc.)
- π TanStack Query - Powerful server state management
- π§© Adapter Pattern - Swappable API backends
- π Form Validation - React Hook Form + Zod
- π§ͺ Testing - Vitest + React Testing Library
- π Storybook - Component documentation and testing
- βΏ Accessibility - Built-in screen reader support and keyboard navigation
- π Error Boundaries - Multi-level error handling with retry
- π Intelligent Caching - Fast incremental builds
- π¦ Shared Libraries - Type-safe code sharing
- π§ Code Quality - Biome for linting and formatting
- πͺ Git Hooks - Husky + Commitlint for conventional commits
- π Consistent - Single source of truth for dependencies
- SaaS applications
- Internal tools and dashboards
- E-commerce platforms
- CRM/ERP systems
- Booking and scheduling applications
- API-first applications
- Any full-stack TypeScript project requiring scalability
| Layer | Technology | Version |
|---|---|---|
| Monorepo | Nx | 22.5 |
| Backend | NestJS | 11 |
| Frontend | Next.js | 16 |
| UI | React | 19 |
| Database | PostgreSQL | 16 |
| ORM | Prisma | 7.4 |
| State Management | TanStack Query | 5 |
| Forms | React Hook Form + Zod | 7 + 4 |
| Testing | Vitest + Playwright | 3 + 1.36 |
| Styling | CSS Modules + CSS Variables | - |
| Documentation | Storybook | 8.4 |
| Package Manager | pnpm | - |
| Language | TypeScript | 5.9 |
| Code Quality | Biome | 2.4 |
| Node Version | Volta | 22.20.0 |
fullstack-starter/
βββ api/ # NestJS Backend
β βββ src/
β β βββ app/ # Root module
β β βββ prisma/ # Database service
β β βββ generated/ # Generated Prisma Client
β βββ prisma/
β β βββ schema.prisma # Database schema
β βββ .env.example # Environment template
β
βββ web/ # Next.js Frontend
β βββ src/
β β βββ app/ # Next.js App Router
β β βββ components/ # UI components
β β βββ hooks/ # Custom React hooks
β β βββ adapters/ # API adapters
β β βββ lib/ # Utilities
β β βββ providers/ # React contexts
β β βββ styles/ # Global styles
β βββ .storybook/ # Storybook config
β βββ scripts/ # CLI tools
β
βββ libs/ # Shared Libraries
β βββ shared/
β βββ types/ # Shared TypeScript types
β
βββ api-e2e/ # API E2E tests
βββ web-e2e/ # Web E2E tests
βββ docs/ # Documentation
β βββ API.md # Backend documentation
β βββ WEB.md # Frontend documentation
β βββ SETUP.md # Setup guide
β βββ CUSTOMIZATION.md # Customization guide
β βββ TEMPLATE_GUIDE.md # Architecture guide
β
βββ docker-compose.yml # PostgreSQL configuration
βββ nx.json # Nx workspace config
βββ tsconfig.base.json # Base TypeScript config
βββ biome.json # Linter/formatter config
βββ init-template.ps1 # Windows setup script
βββ init-template.sh # Linux/Mac setup script
- Node.js 18+ (22.20.0 recommended via Volta)
- pnpm -
npm install -g pnpm - Docker and Docker Compose
# Clone this repository
git clone <repository-url> my-project
cd my-project
# Or download as ZIP and extractNote: The initialization script will prompt you to remove the template's git remote. If you want to use your own repository, you can add it after initialization:
git remote add origin <your-repository-url>Windows (PowerShell):
.\init-template.ps1Linux/Mac:
chmod +x init-template.sh
./init-template.shThe script will:
- β Prompt for project name
- β Configure database credentials
- β Set API and web ports
- β Update all configuration files
- β Create environment files
pnpm installdocker compose up -dcd api
npx prisma migrate dev --name init
cd ..Option A: Start Both (Parallel)
# Terminal 1 - API
pnpm nx serve api
# Terminal 2 - Web
pnpm nx dev webOption B: Use Nx Run-Many
pnpm nx run-many -t serve dev -p api web- API: http://localhost:3000/api
- Web: http://localhost:4200
- Storybook:
pnpm nx run web:storybookβ http://localhost:6006
Comprehensive documentation is organized by topic:
- Setup Guide - Detailed setup instructions
- API Documentation - Backend (NestJS) guide
- Database & Prisma
- Creating modules
- Testing
- Deployment
- Web Documentation - Frontend (Next.js) guide
- Component library
- Custom hooks
- Adapter pattern
- Styling system
- Testing
- Customization Guide - How to customize the template
- Architecture Guide - Overall architecture and design patterns
- Web CLAUDE.md - Frontend development patterns
- Web README - Next.js template specifics
- GitHub Actions Guide - CI/CD recommendations
# Start API
pnpm nx serve api
# Start Web
pnpm nx dev web
# Start Storybook
pnpm nx run web:storybook
# Run both API and Web
pnpm nx run-many -t serve -p api web# Build API
pnpm nx build api
# Build Web
pnpm nx build web
# Build everything
pnpm nx run-many -t build --all# Test API
pnpm nx test api
# Test Web
pnpm nx test web
# Test Web with UI
pnpm nx test web --ui
# E2E tests
pnpm nx e2e api-e2e
pnpm nx e2e web-e2e
# All tests
pnpm nx run-many -t test# Format all files
pnpm format:write
# Check code quality
pnpm check
# Fix issues automatically
pnpm check:write
# Check only changed files
pnpm check:changedcd api
# Create migration
npx prisma migrate dev --name <migration_name>
# Open Prisma Studio
npx prisma studio
# Reset database (WARNING: deletes data)
npx prisma migrate resetcd web
# Interactive mode
pnpm generate
# With arguments
pnpm generate MyComponent --client --styles --props "title: string"# Generate NestJS resource
pnpm nx g @nx/nest:resource users --project=apiThis creates:
api/src/users/users.module.tsapi/src/users/users.controller.tsapi/src/users/users.service.ts- DTOs and entities
See API Documentation for details.
cd web
pnpm generate MyComponent --client --stylesThis creates:
src/components/MyComponent/index.tssrc/components/MyComponent/my-component.tsxsrc/components/MyComponent/my-component.module.css
See Web Documentation for details.
-
Edit
api/prisma/schema.prisma:model User { id String @id @default(cuid()) email String @unique name String createdAt DateTime @default(now()) }
-
Create migration:
cd api npx prisma migrate dev --name add_user_model -
Use in your code:
const users = await this.prisma.user.findMany();
- Input - Text input with validation states
- Select - Dropdown with custom styling
- Checkbox - Accessible checkbox
- Radio - Radio buttons with groups
- Toast - Notification system
- Loader - Loading spinner
- SmartErrorBoundary - Error handling with retry
- Accessibility - Screen reader announcers
See them in action: pnpm nx run web:storybook
useInfiniteData- API-agnostic infinite scrolluseInfiniteScroll- Auto-load on scrolluseDebounce- Debounce valuesuseThrottle- Throttle eventsuseKeyboardNavigation- Keyboard interactionsuseGridNavigation- Grid keyboard navuseLocalStorage- Persistent state- And 8+ more...
- Vitest - Fast unit testing
- React Testing Library - Component testing
- Playwright - E2E testing
- Storybook - Visual testing
- Example tests included
cd web
vercelSee API Documentation for Dockerfile examples.
Production checklist:
- Set
DATABASE_URLto production database - Set
NEXT_PUBLIC_API_BASE_URLto production API - Set
NODE_ENV=production - Set
CORS_ORIGINto production domain - Generate secure secrets
This is a template repository. Fork it and customize for your needs!
If you improve the template:
- Create a feature branch
- Make your changes
- Follow conventional commits
- Test thoroughly
- Submit a PR
MIT License - see LICENSE for details.
Built with:
- NestJS - https://nestjs.com
- Next.js - https://nextjs.org
- Prisma - https://prisma.io
- Nx - https://nx.dev
- TanStack Query - https://tanstack.com/query
- Biome - https://biomejs.dev
- Issues: Open an issue on GitHub
- Documentation: Check docs/ folder
Potential additions:
- Authentication scaffolding (Passport.js / NextAuth)
- Additional UI components (Button, Card, Modal, etc.)
- GraphQL support
- Rate limiting
- Caching layer
- Monitoring & logging
- Docker Compose for full-stack
- CI/CD examples
Current status: Fully functional production-ready starter template
Happy coding! π
For detailed guides, see: