A production-ready NestJS application following enterprise-level coding standards and architectural patterns.
- Features
- Tech Stack
- Project Structure
- Getting Started
- Environment Setup
- Database Setup
- Documentation
- Quick Start
- NestJS Framework - Scalable Node.js server-side applications
- Prisma ORM - Type-safe database access with PostgreSQL
- Bull Queues - Background job processing with Redis
- Joi Validation - Schema-based validation (NOT class-validator)
- JWT Authentication - Secure authentication with custom middleware
- TypeScript - Full type safety and modern JavaScript features
- ESLint + Prettier - Code quality and formatting
- Husky - Git hooks for code quality
- Docker Ready - Container support for deployment
- Framework: NestJS
- Language: TypeScript
- Database: PostgreSQL
- ORM: Prisma
- Queue System: Bull + Redis
- Validation: Joi
- Authentication: JWT + Custom middleware
- Code Quality: ESLint + Prettier + Husky
/project-root
├── src/
│ ├── apis/ # Feature modules
│ │ ├── auth/ # Authentication & 2FA
│ │ ├── users/ # User management
│ │ ├── api-keys/ # API key management
│ │ └── admin/ # Admin functionality
│ ├── common/
│ │ ├── constants/ # Queue constants
│ │ ├── entities/ # Common entities
│ │ ├── enums/ # Enums and constants
│ │ ├── middlewares/ # Custom middlewares
│ │ ├── prisma.ts # Prisma client instance
│ │ └── response.ts # Response interfaces
│ ├── config/
│ │ └── config.ts # Centralized configuration
│ ├── crons/ # Scheduled tasks
│ ├── helpers/ # External service helpers
│ ├── i18n/ # Internationalization
│ ├── queues/
│ │ ├── processors/ # Queue processors
│ │ ├── queue-processors.module.ts
│ │ └── queue-producers.module.ts
│ ├── repositories/ # Data access layer
│ ├── seeds/ # Database seeders
│ ├── utils/ # Utility functions
│ ├── app.controller.ts
│ ├── app.module.ts
│ ├── app.service.ts
│ └── main.ts
├── prisma/
│ ├── schema.prisma
│ └── migrations/
├── scripts/ # Deployment scripts
├── .github/ # GitHub workflows
├── .husky/ # Git hooks
└── .vscode/ # VS Code settings
- Node.js (v18+)
- PostgreSQL (v13+)
- Redis (v6+)
- npm or yarn
-
Clone the repository
git clone <repository-url> cd nestjs-project
-
Install dependencies
npm install
-
Set up environment variables
cp env-template.txt .env # Edit .env with your configuration -
Set up the database
npx prisma migrate dev npx prisma generate
-
Seed the database
npm run seed
-
Start the development server
npm run start:dev
Copy env-template.txt to .env and configure the following variables:
DATABASE_URL- PostgreSQL connection stringREDIS_URL- Redis connection stringAUTH_JWT_SECRET- JWT signing secretAUTH_REFRESH_JWT_SECRET- JWT refresh secret
SUPER_ADMIN_EMAIL- Super admin email (production only)SUPER_ADMIN_PASSWORD- Super admin password (production only)- OAuth provider credentials (Google, GitHub, etc.)
-
Create PostgreSQL database
CREATE DATABASE your_database_name;
-
Run migrations
npx prisma migrate dev
-
Generate Prisma client
npx prisma generate
-
Seed initial data
npm run seed
The project documentation has been consolidated into a single comprehensive file that includes:
- Architecture & Design - Project structure and design patterns
- Authentication & Security - 2FA, OAuth, and security features
- API Endpoints - Complete API reference
- Development Guidelines - Coding standards and best practices
- Production & Deployment - Deployment and production setup
- Testing & Quality Assurance - Testing strategies and quality guidelines
-
Start the application
npm run start:dev
-
Access the API
- Base URL:
http://localhost:3000 - Health Check:
GET /health - API Documentation: See DOCUMENTATION.md
- Base URL:
-
Create your first user
curl -X POST http://localhost:3000/api/v1/auth/register \ -H "Content-Type: application/json" \ -d '{"email":"user@example.com","password":"password123","firstName":"John","lastName":"Doe"}'
-
Login and get API key
# Login curl -X POST http://localhost:3000/api/v1/auth/login \ -H "Content-Type: application/json" \ -d '{"email":"user@example.com","password":"password123"}' # Create API key (use the access token from login) curl -X POST http://localhost:3000/api/v1/api-keys \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{"name":"My API Key","description":"For testing"}'
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
This project is licensed under the MIT License.