Skip to content

NestJS microservices demonstration with Auth, User, Order, and Payment services

Notifications You must be signed in to change notification settings

Cloud-Jack/nest-services-demo

Repository files navigation

NestJS Microservices Demo

A production-ready microservices architecture built with NestJS, showcasing modern backend development practices.

🚀 Quick Start

# Start all services
npm run docker:up

# Stop services
npm run docker:down

🏗️ Services

Service Port Purpose
Auth Service 3001 JWT authentication & authorization
User Service 3002 User profile management
Order Service 3004 Order processing & management
Payment Service 3005 Payment processing & gateway

🛠️ Tech Stack

  • Backend: NestJS, TypeScript, Node.js
  • Database: PostgreSQL with TypeORM
  • Message Queue: RabbitMQ
  • Cache: Redis
  • Containerization: Docker & Docker Compose
  • API Documentation: Swagger/OpenAPI

📋 Features

  • Microservices Architecture - Domain-separated services with clear boundaries
  • Event-Driven Communication - RabbitMQ-based async messaging
  • JWT Authentication - Role-based access control (RBAC)
  • Database per Service - Independent data stores
  • Health Checks - Kubernetes-ready liveness/readiness probes
  • API Versioning - Backward-compatible REST APIs
  • Comprehensive Logging - Structured logging with correlation IDs
  • Docker Ready - Multi-stage builds with development/production modes

� API Endpoints

Health Checks (All Services)

GET /health          # General health status
GET /health/ready    # Kubernetes readiness probe
GET /health/live     # Kubernetes liveness probe

Authentication

POST /api/v1/auth/register    # User registration
POST /api/v1/auth/login       # User login
POST /api/v1/auth/refresh     # Token refresh

Orders

GET  /api/v1/orders          # List orders
POST /api/v1/orders          # Create order
GET  /api/v1/orders/{id}     # Get order details

Payments

POST /api/v1/payments        # Process payment
GET  /api/v1/payments/{id}   # Get payment status

� Monitoring

  • Swagger UI: http://localhost:3001/api (Auth Service)
  • Health Checks: Available on all service ports
  • Database: PostgreSQL on port 5432
  • RabbitMQ Management: http://localhost:15672 (guest/guest)

🔧 Development

# Install dependencies
npm install

# Run in development mode
npm run start:dev

# Build for production
npm run build

# Run tests
npm run test

📁 Project Structure

apps/                    # Microservices
├── auth-service/        # Authentication & JWT
├── user-service/        # User management
├── order-service/       # Order processing
└── payment-service/     # Payment handling

libs/                    # Shared libraries
├── database/            # TypeORM entities & migrations
├── messaging/           # RabbitMQ constants & config
├── models/              # Shared DTOs & services
└── health-check/        # Pluggable health monitoring

Built with ❤️ using NestJS

About

NestJS microservices demonstration with Auth, User, Order, and Payment services

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published