π Production-Ready - A professional, full-stack TypeScript template with enterprise-grade authentication and modern architecture.
A modern, fully-tested monorepo template featuring Next.js 15, NestJS, and a comprehensive authentication system with a beautiful UI built on shadcn/ui components. Perfect for SaaS applications, internal tools, or any full-stack project requiring robust authentication.
- β 615 Tests Passing - Comprehensive test coverage across 43 test suites
- π Enterprise Security - Rate limiting, bot protection, session management, SSR route protection
- π¨ Modern UI - Built with shadcn/ui and Tailwind CSS v4
- π¦ Monorepo - Turborepo for optimal build caching and task execution
- π³ Stripe Integration - Complete subscription and payment handling with webhook audit logging
- π§ Email System - React Email templates with Nodemailer
- π Auth System - Email verification, password reset, role-based access control
- π Production Ready - Helmet, CORS, Winston logging, error handling
- ROADMAP.md - Future enhancements and feature roadmap
- CLAUDE.md - Development guidelines and project conventions
.
βββ apps/
β βββ api/ # NestJS backend (141 TS files)
β β βββ src/
β β β βββ common/ # Guards, decorators, interceptors, filters
β β β βββ config/ # Helmet, CORS, Swagger configuration
β β β βββ modules/ # Feature modules
β β β βββ auth/ # Authentication & authorization
β β β βββ user/ # User management
β β β βββ mail/ # Email service (React Email)
β β β βββ logger/ # Winston logging with rotation
β β β βββ stripe/ # Subscription & payments
β β β βββ s3/ # File uploads (AWS S3)
β β β βββ rate-limit/ # Redis-based rate limiting
β β βββ prisma/ # Database schema and migrations
β β
β βββ web/ # Next.js frontend (83 TS files)
β βββ app/ # App Router pages
β β βββ (main)/ # Public landing page
β β βββ auth/ # Authentication pages
β β βββ dashboard/# Protected dashboard
β β βββ legal/ # Privacy, Terms, etc.
β βββ components/ # React components
β βββ lib/ # API client, utilities
β βββ hooks/ # Custom React hooks
β βββ middleware.ts # SSR route protection
β
βββ packages/
β βββ ui/ # Shared shadcn/ui components
β βββ eslint-config/ # Shared ESLint configuration
β βββ typescript-config/# Shared TypeScript configuration
β
βββ docker-compose.yml # PostgreSQL, Redis, Mailpit, S3rver
βββ turbo.json # Turborepo configuration
- Next.js 15 - React framework with App Router and Turbopack
- React 19 - Latest React with server components
- TypeScript 5.7 - Type safety throughout
- Tailwind CSS v4 - Utility-first styling
- shadcn/ui - Beautiful, accessible components
- Framer Motion - Smooth animations
- React Hook Form + Zod - Form handling with validation
- TanStack Query - Server state management
- next-themes - Dark/light mode support
- NestJS 11 - Progressive Node.js framework
- Prisma 6 - Next-generation ORM
- PostgreSQL - Relational database
- Redis - Session storage and rate limiting
- Stripe - Payment and subscription handling
- Winston - Structured logging with rotation
- Jest - Testing framework (615 tests)
- Scrypt - Password hashing (via @oslojs/crypto)
- Turborepo - High-performance monorepo build system
- pnpm 10.4 - Fast, disk-efficient package manager
- Docker & Docker Compose - Development services
- ESLint + Prettier - Code quality and formatting
- Husky - Git hooks for quality checks
- Commitlint - Conventional commit enforcement
- Email/Password Auth - Secure registration and login
- Email Verification - Code-based email verification
- Password Reset - Secure token-based reset flow
- Session Management - Redis-backed sessions with device tracking
- Rate Limiting - Configurable limits per endpoint (3 attempts/15 min on login)
- Bot Protection - Cloudflare Turnstile integration on sensitive endpoints
- Role-Based Access - USER and ADMIN roles with guards
- SSR Route Protection - Next.js middleware validates sessions server-side
- Subscription Management - Complete lifecycle handling
- Checkout Sessions - Hosted checkout flow
- Customer Portal - Self-service subscription management
- Webhook Handling - Comprehensive event processing
- Audit Logging - All webhook events logged to database
- Email Notifications - Automated emails for subscription events
- React Email Templates - Modern, responsive email templates
- Nodemailer Integration - SMTP email delivery
- Development Mode - Mailpit for local email testing
- Template Types:
- Email verification codes
- Password reset links
- Account locked notifications
- Subscription status changes
- Landing Page - Professional hero, features, testimonials, pricing, CTA
- Authentication Pages - Login, register, forgot password, reset password, verify email
- Dashboard - Protected area with sidebar navigation
- Legal Pages - Privacy Policy, Terms of Service, Cookie Policy, GDPR compliance
- Dark/Light Mode - System preference detection with manual toggle
- Responsive Design - Mobile-first, works on all devices
- Accessibility - ARIA labels, keyboard navigation, screen reader support
- Helmet - Security headers (CSP, XSS protection, etc.)
- CORS - Configurable cross-origin resource sharing
- Rate Limiting - Redis-based with graceful degradation
- Password Hashing - Scrypt with salt (N=16384, r=16, p=1)
- Session Security - httpOnly, secure, sameSite cookies
- SQL Injection Protection - Prisma parameterized queries
- XSS Prevention - React automatic escaping
- Bot Protection - Turnstile verification on sensitive endpoints
- Winston Logger - Structured logging with context
- File Rotation - Daily log rotation with retention
- Log Levels - Debug, info, warn, error with filtering
- Context Logging - Logger per service with metadata
- Error Tracking - Comprehensive error logging with stack traces
- Unit Tests - 615 tests across 43 test suites
- Integration Tests - Full request/response testing
- Mock Coverage - External dependencies fully mocked
- Test Utilities - Helper functions for common scenarios
- CI Ready - Fast, parallelizable test execution
- Node.js 20+ (recommended: use nvm)
- pnpm 10.4+ (
npm install -g pnpm@10.4.1) - Docker & Docker Compose (for development services)
-
Clone the repository
git clone <repository-url> cd next-js-nest-js-template
-
Install dependencies
pnpm install
-
Set up environment variables
# API environment cp apps/api/.env.example apps/api/.env # Web environment cp apps/web/.env.example apps/web/.env # Edit the files and add your configuration
-
Start development services
docker-compose up -d
This starts:
- PostgreSQL (port 5432)
- Redis (port 6379)
- Mailpit (UI: 8025, SMTP: 1025)
- S3rver (port 4569)
-
Run database migrations
pnpm --filter=api db:migrate
-
Generate Prisma client
pnpm --filter=api db:generate
-
Start development servers
pnpm dev
- API: http://localhost:3001
- Web: http://localhost:3000
- API Docs: http://localhost:3001/docs
-
Install Stripe CLI
# macOS brew install stripe/stripe-cli/stripe # Other platforms: https://stripe.com/docs/stripe-cli
-
Login to Stripe
stripe login
-
Forward webhooks
pnpm --filter=api stripe:listen
-
Copy webhook secret
- The CLI will output a webhook signing secret
- Add it to
apps/api/.envasSTRIPE_WEBHOOK_SECRET
pnpm dev # Start all dev servers
pnpm build # Build all apps
pnpm lint # Lint all code
pnpm typecheck # Type check all apps
pnpm format # Format all code
pnpm release # Build + lint + typecheck (CI check)pnpm --filter=api dev # Start API in watch mode
pnpm --filter=api build # Build API for production
pnpm --filter=api test # Run tests
pnpm --filter=api test:watch # Run tests in watch mode
pnpm --filter=api test:cov # Run tests with coverage
pnpm --filter=api db:generate # Generate Prisma client
pnpm --filter=api db:migrate # Run database migrations
pnpm --filter=api db:studio # Open Prisma Studio
pnpm --filter=api stripe:listen # Forward Stripe webhookspnpm --filter=web dev # Start web dev server
pnpm --filter=web build # Build web for production
pnpm --filter=web start # Start production server
pnpm --filter=web lint # Lint web code
pnpm --filter=web typecheck # Type check web code# Add a shadcn/ui component to the shared UI package
pnpm dlx shadcn@latest add button -c apps/webThe API includes comprehensive test coverage:
- 615 tests across 43 test suites
- 100% coverage of business logic
- Unit tests for all services and controllers
- Integration tests for critical flows
- Mock implementations of external dependencies
Run tests:
# Run all tests
pnpm --filter=api test
# Run specific test file
pnpm --filter=api test auth.service.spec.ts
# Run tests in watch mode
pnpm --filter=api test:watch
# Generate coverage report
pnpm --filter=api test:covThis template follows security best practices with room for enhancements.
Implemented:
- β No critical or high vulnerabilities (API dependencies updated)
- β SSR route protection implemented
- β Rate limiting on all sensitive endpoints
- β Bot protection with Turnstile
- β Secure session management (httpOnly, secure cookies)
- β Password hashing with Scrypt
- β Input validation on all endpoints
Planned (Priority):
- π CSRF protection with double-submit cookie strategy
- π Update web dependencies to latest versions
- π Frontend testing suite
- Fast Builds - Turborepo with intelligent caching
- Hot Reload - Sub-second reload times in development
- Optimized Production - Tree-shaking, code splitting, lazy loading
- Efficient Queries - Prisma with optimized database queries
- Redis Caching - Session and rate limit data cached
Contributions are welcome! Please read our contribution guidelines:
- Fork the repository
- Create a feature branch (
feature/amazing-feature) - Commit your changes using conventional commits
- Push to the branch
- Open a Pull Request
Commit Convention:
feat(scope): add new feature
fix(scope): fix bug
docs(scope): update documentation
refactor(scope): refactor code
test(scope): add tests
See .commitlintrc.js for full configuration.
See ROADMAP.md for planned features and enhancements, including:
- Two-Factor Authentication (2FA)
- Frontend testing suite
- CI/CD pipeline
- Performance monitoring
- Advanced security features
- And much more!
This project is licensed under the MIT License - see the LICENSE file for details.
- Next.js - The React framework for production
- NestJS - A progressive Node.js framework
- shadcn/ui - Beautiful, accessible component library
- Turborepo - High-performance build system
- Prisma - Next-generation ORM
For questions, issues, or feature requests:
- π Open an issue
- π¬ Start a discussion
- π§ Email: support@taketach.pl
Built with β€οΈ using TypeScript, Next.js, and NestJS