ACK NestJs is a NestJs v11.x boilerplate designed for backend services. Production-ready NestJS boilerplate with authentication, authorization, and enterprise features
You can request feature or report bug with following this link
This boilerplate is perfect for:
- π’ Enterprise Applications - Full-featured auth system with RBAC and audit logging
- π Authentication Services - Ready-to-use JWT, OAuth, and 2FA implementation
- π± Mobile App Backends - RESTful API with social login support
- π Multi-tenant SaaS - Role-based access control and policy management
- π Microservices - Stateful sessions with Redis and async job processing
- πΌ Startup MVPs - Production-ready foundation to ship faster
- Important
- TODO
- Prerequisites
- Build with
- Objective
- Features
- Quick Start
- Change DB with Minimal Effort
- Installation
- License
- Contribute
- Contact
- Stateful Authorization, using
redis-sessionandJWT. - Must run MongoDB as a
replication setfordatabase transactions. - If you change the environment value of
APP_ENVtoproduction, it will disable Documentation. - When using multiple protection decorators, they must be applied in the correct order:
@ExampleDoc() @ActivityLog(...) @PolicyAbilityProtected({...}) @RoleProtected(...) @TermPolicyAcceptanceProtected(...) @UserProtected() @AuthJwtAccessProtected() @FeatureFlagProtected(...) @ApiKeyProtected() @HttpCode(HttpStatus.OK) @Get('/some-endpoint')
- Since version
8.0.0, the project uses theES256algorithm for Access Token, andES512for Refresh Token. - Since version
8.0.0, the project uses prisma6.19for handle database. - Since version
8.0.0, the project uses pnpm for package manager.
- Change enum name to use PascalCase
- 2FA with TOTP Authentication (eg: Google Authenticator)
- Recovery Codes Method
- Add TOTP Authentication Protected to reset password, change password, and regenerate backup codes endpoints
- Add import and export endpoint with presign upload
- Add migration script to migrate AWS S3 Policy for public and private, include config for presign expiration
- Activity Log support bidirectional logging
- Login with biometrics (fingerprint or face detection)
- Login with passkey
- Login with Github SSO
- Device awareness, Geo Location
- Sliding session (Example: 7d expires for a refresh token, can be extends until x day. if not action in 7d then need to re-login)
- Anomaly detection when refresh token
- Verification Mobile Number, whatsapp or/and sms
- Simple Notification System or Enchant Activity Log to be able act as notification
- Versioning System (Force frontend to update, especially mobile)
- Unit test
- Integration Test
- E2E Test
- Stress Test For Benchmark/Performance
- Load Test For Benchmark/Performance
I assume that everyone who comes here is a programmer with intermediate knowledge. To get the most out of this project, here's what you should understand:
- NestJs Fundamentals - Main framework with decorators, modules, services, and dependency injection
- TypeScript - Strong typing, interfaces, generics, and advanced TypeScript features
- Prisma ORM - Modern database toolkit for schema design, migrations, and type-safe queries
- MongoDB - NoSQL database concepts, especially replication sets for transactions
- Redis - Caching strategies, session storage, and queue management
- Repository Design Pattern - Data access layer abstraction for maintainable code
- SOLID Principles - Clean code architecture and dependency management
- Queue Systems - Background job processing with BullMQ
- Optional. Docker - Containerization for running the project
- Optional. Microservice Architecture - Understanding distributed systems concepts
The project is built using the following technologies and versions. We always strive to use the latest stable versions to ensure security, performance, and access to modern features:
| Name | Version |
|---|---|
| NestJs | v11.x |
| NodeJs | v24.11.x |
| TypeScript | v5.9.x |
| Prisma | v6.19.x |
| MongoDB | v8.0.x |
| Redis | v8.0.x |
| Docker | v28.5.x |
| Docker Compose | v2.40.x |
For more information see package.json
- Easy to maintain
- NestJs Habit
- Component based / modular folder structure
- Stateful authentication and authorization
- Repository Design Pattern
- Follow Community Guidelines
- Follow The Twelve-Factor App
- Repository Pattern - Clean data access abstraction
- SOLID Principles - Maintainable and testable codebase
- Modular Structure - Component-based folder organization
- 12-Factor App - Cloud-native best practices
- Production Ready - Enterprise-grade security and scalability
Production-ready authentication system with multiple strategies and security layers.
- JWT Authentication - ES256 for Access Token, ES512 for Refresh Token with automatic rotation
- Stateful Sessions - Redis-backed sessions with token revocation support
- Social Login - Google OAuth and Apple Sign In integration (docs)
- Two-Factor Authentication - TOTP-based 2FA with backup recovery codes (docs)
- RBAC & Policies - Fine-grained role and permission system (docs)
- API Key Protection - Secure external API access control
- Rate Limiting - DDoS protection with configurable throttling
- Security Headers - Helmet integration for HTTP security
Modern ORM with NoSQL database and file storage capabilities.
- Prisma ORM - Type-safe database toolkit with migrations (docs)
- MongoDB - NoSQL database with transaction support (replica set required)
- Redis Caching - Multi-level caching strategies for performance (docs)
- AWS S3 Integration - File storage with presigned URLs (docs)
- Repository Pattern - Clean separation of data access layer
Built for speed and scalability from day one.
- Background Jobs - BullMQ queue system for async processing (docs)
- Response Compression - Automatic gzip/deflate compression
- SWC Compiler - 20x faster than TypeScript compiler
- Pagination - Server-side pagination with cursor support (docs)
- Feature Flags - Dynamic feature rollout with A/B testing (docs)
Developer-friendly tooling and best practices.
- NestJS 11.x - Latest framework version with full TypeScript support
- Swagger/OpenAPI 3 - Interactive API documentation (docs)
- API Versioning - URL-based versioning (default v1)
- Request Validation - Automatic validation with class-validator (docs)
- Error Handling - Standardized error responses with i18n (docs)
- Hot Reload - Fast development with SWC
- Code Quality - ESLint, Prettier, Husky pre-commit hooks
- Database Seeding - Commander-based data population
Enterprise-grade integrations for production readiness.
- Sentry - Error tracking and performance monitoring (docs)
- AWS SES - Transactional email delivery
- Activity Logging - Comprehensive audit trail (docs)
- Health Checks - System monitoring endpoints
- Multi-language Support - i18n with
x-custom-langheader (docs)
Comprehensive testing framework and documentation.
- Jest Testing - Unit, integration, and e2e test setup
- Swagger UI - Auto-generated API documentation
- Detailed Docs - 20+ documentation files covering all features
- Docker Support - Complete containerization with docker-compose
# Clone repository
git clone https://github.com/andrechristikan/ack-nestjs-boilerplate
# Install dependencies
pnpm install
# Setup environment
cp .env.example .env
# Run with Docker
docker-compose up -d
# Access API
open http://localhost:3000/docsThanks to Repository Pattern and Prisma ORM, switching databases requires minimal code changes. The abstraction layer isolates database logic from business logic.
| Database | Best For | Transaction Support |
|---|---|---|
| MongoDB | Document-based, flexible schema | β Yes (replica set) |
| PostgreSQL | Production apps, complex queries | β Yes |
Other supported databases: MySQL, SQLite, SQL Server, CockroachDB
Migration typically requires:
- Updating
prisma/schema.prismaprovider - Adjusting ID strategy (ObjectId β UUID). Update DatabaseService Code.
- Running
npx prisma migrate dev - Running
pnpm migration:seed
Business logic stays unchanged - services, controllers, and authentication work as-is.
For detailed migration guides, see Database Documentation.
For detailed installation instructions (both default and Docker-based), please refer to the Installation.
This project is licensed under the MIT License.
We welcome contributions to this project! To contribute, follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name - Make your changes and ensure they follow our coding standards
- Run tests:
pnpm testandpnpm lintto verify your changes - Commit your changes:
git commit -m 'feat: add some feature' - Push to your branch:
git push origin feature/your-feature-name - Open a Pull Request with a clear description of your changes
- Follow the existing code style and conventions
- Write or update tests for any new functionality
- Ensure all tests pass before submitting
- Use conventional commit messages (feat, fix, docs, etc.)
- Keep PRs focused and atomic
If your branch is behind the origin/main branch, please rebase and resolve any conflicts before opening a pull request.
Andre Christi Kan
π§ andrechristikan@gmail.com
If you find this project helpful and would like to support its development, please consider giving it a β star on GitHub or buying me a β coffee!
Buy me a coffee β
Or support via PayPal π³