Production-ready NestJS backend template with comprehensive features and documentation.
Version: 1.0
# Install dependencies
npm install
# Setup environment
cp .env.example .env # Configure your environment variables
# Initialize database
npm run db:setup
npm run db:init
# Start development server
npm run start:devThe API will be available at http://localhost:3000
Comprehensive API documentation is available through Compodoc:
Example :# Generate documentation
npm run doc
# Generate and serve documentation (available at http://localhost:3001)
npm run doc:serve
# Watch mode - auto-regenerate on file changes
npm run doc:watchDocumentation URL: http://localhost:3001 (when served)
The documentation includes:
| Technology | Version | Purpose |
|---|---|---|
| Node.js | v22 (LTS) | Runtime environment |
| NestJS | v11 | Backend framework |
| PostgreSQL | v16 | Primary database |
| Redis | v7 | Caching layer |
| Elasticsearch | v8.11 | Search engine |
| TypeScript | v5.7 | Programming language |
| JWT | - | Authentication |
Create a .env file in the root directory:
# Database
DB_HOST="localhost"
DB_USERNAME="your_username"
DB_PASSWORD="your_password"
DB_NAME="your_database"
# Redis
REDIS_HOST="127.0.0.1"
REDIS_PORT="6379"
# Elasticsearch
ELASTICSEARCH_NODE="http://localhost:9200"
ELASTICSEARCH_USERNAME=""
ELASTICSEARCH_PASSWORD=""
# JWT
JWT_SECRET="your_secure_secret_key_here"
JWT_REFRESH_SECRET="your_refresh_secret_key_here"
JWT_COOKIE_NAME="elnr.sid"
# API Configuration
API_TITLE="Your API Title"
API_DESCRIPTION="Your API Description"
API_VERSION="1.0.0"
# Server
PORT="3000"โ ๏ธ Important: Change JWT secrets and cookie name for production!
Full Elasticsearch integration with:
Start Elasticsearch with Docker:
Example :docker-compose -f docker-compose.elasticsearch.yml up -dAccess:
http://localhost:9200http://localhost:5601# Setup database
npm run db:setup
# Run migrations
npm run migration:run
# Generate new migration
npm run migration:generate -- src/migrations/MigrationName
# Seed database
npm run seed
# Initialize (migrations + seed)
npm run db:init
# Reset database (โ ๏ธ destroys all data)
npm run db:reset# Extract and update translations
npm run translatenpm run start:dev - Start in watch modenpm run start:debug - Start with debuggernpm run build - Build for productionnpm run start:prod - Run production buildnpm run test - Run unit testsnpm run test:watch - Run tests in watch modenpm run test:cov - Generate coverage reportnpm run test:e2e - Run end-to-end testsnpm run doc - Generate documentationnpm run doc:serve - Serve documentation on port 3001npm run doc:watch - Watch and auto-regenerate docsnpm run lint - Lint and fix codenpm run format - Format code with Prettiersrc/
โโโ app.module.ts # Root module
โโโ main.ts # Application entry point
โโโ common/ # Shared utilities
โ โโโ decorators/ # Custom decorators
โ โโโ entities/ # Base entities
โ โโโ enums/ # Shared enums
โ โโโ interceptors/ # Global interceptors
โ โโโ pipes/ # Custom pipes
โโโ config/ # Configuration files
โโโ database/ # Database setup & utilities
โโโ elasticsearch/ # Elasticsearch integration
โโโ i18n/ # Internationalization
โโโ migrations/ # Database migrations
โโโ modules/ # Feature modules
โ โโโ auth/ # Authentication
โ โโโ users/ # User management
โ โโโ ... # Other features
โโโ redis/ # Redis integration
โโโ seed/ # Database seeders
โโโ swagger/ # API documentation setup# Unit tests
npm run test
# E2E tests
npm run test:e2e
# Test coverage
npm run test:covAvailable at: http://localhost:3000/api
Generate and view comprehensive code documentation:
Example :npm run doc:serveAccess at: http://localhost:3001
npm run lintUNLICENSED - Private use only
Need help? Check the generated documentation at http://localhost:3001 or review the inline JSDoc comments in the code.