https://github.com/faizkhairi/microservices-demo
Production-grade microservices platform with Nuxt 4 + NestJS โ 7 services demonstrating enterprise architecture patterns
https://github.com/faizkhairi/microservices-demo
api-gateway bullmq docker docker-compose enterprise enterprise-architecture event-driven message-queue microservices nestjs nuxt postgresql prisma redis typescript
Last synced: 2 months ago
JSON representation
Production-grade microservices platform with Nuxt 4 + NestJS โ 7 services demonstrating enterprise architecture patterns
- Host: GitHub
- URL: https://github.com/faizkhairi/microservices-demo
- Owner: faizkhairi
- License: mit
- Created: 2026-02-15T16:18:58.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-03-30T13:47:36.000Z (3 months ago)
- Last Synced: 2026-04-07T21:39:00.620Z (3 months ago)
- Topics: api-gateway, bullmq, docker, docker-compose, enterprise, enterprise-architecture, event-driven, message-queue, microservices, nestjs, nuxt, postgresql, prisma, redis, typescript
- Language: TypeScript
- Homepage: https://github.com/faizkhairi/microservices-demo
- Size: 50.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Microservices Demo

**Production-grade microservices platform** demonstrating enterprise architecture patterns with **Nuxt 4 + NestJS**.
Built by [Faiz Khairi](https://github.com/faizkhairi) to showcase scalable system design, message-driven architecture, and modern DevOps practices.
---
## ๐๏ธ Architecture
**7-Service Microservices Platform:**
```
Frontend (Nuxt 4)
โ
API Gateway (NestJS) โ Routing, Auth, Rate Limiting
โ
โโโโดโโโฌโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโ
โ โ โ โ โ
Auth User Task Notification Queue Worker
:4001 :4002 :4003 :4004 (Background)
โ โ โ โ
Auth User Task Notification
DB DB DB DB
```
### Services
| Service | Port | Responsibility |
|---------|------|----------------|
| **Frontend** | 3000 | Nuxt 4 web app with Shadcn-vue |
| **API Gateway** | 4000 | Single entry point, JWT validation, rate limiting |
| **Auth Service** | 4001 | JWT authentication, refresh tokens, bcrypt password hashing |
| **User Service** | 4002 | User profiles and account management |
| **Task Service** | 4003 | Task CRUD + BullMQ job publishing |
| **Notification Service** | 4004 | Email + in-app notifications |
| **Queue Worker** | โ | Background job processing with BullMQ |
### Infrastructure
- **4 PostgreSQL databases** (one per service โ microservices pattern)
- **Redis** for message queue (BullMQ)
- **Mailpit** for email testing (dev)
- **Docker Compose** orchestrating 12 containers
---
## ๐ Quick Start
### Prerequisites
- [Docker](https://www.docker.com/get-started) 20.10+
- [Docker Compose](https://docs.docker.com/compose/install/) 2.0+
- [Node.js](https://nodejs.org/) 20+ (for local development)
- [pnpm](https://pnpm.io/) 8+ (optional)
### Run the Full Stack
```bash
# Clone the repository
git clone https://github.com/faizkhairi/microservices-demo.git
cd microservices-demo
# Copy environment variables
cp .env.example .env
# Start all services with Docker Compose
docker compose up --build
# Services will be available at:
# - Frontend: http://localhost:3000
# - API Gateway: http://localhost:4000
# - Mailpit UI: http://localhost:8025 (email testing)
```
**First-time setup:** Docker will build all 7 services + databases. This takes ~5-10 minutes.
---
## ๐ฆ Tech Stack
### Frontend
- **Nuxt 4** โ Vue 3 SSR framework
- **Shadcn-vue** โ Copy-paste UI components
- **Tailwind CSS** โ Utility-first styling
- **Pinia** โ State management
- **Axios** โ HTTP client with JWT interceptor
### Backend
- **NestJS** โ Enterprise Node.js framework
- **Prisma ORM** โ Type-safe database client
- **PostgreSQL 16** โ Production-grade relational DB
- **Passport + JWT** โ Authentication strategy
- **BullMQ + Redis** โ Job queue for async processing
- **Nodemailer** โ SMTP email sending
### DevOps
- **Docker** โ Containerization
- **Docker Compose** โ Multi-container orchestration
- **GitHub Actions** โ CI/CD pipeline
- **Mailpit** โ Email testing (catches all emails in dev)
---
## ๐ ๏ธ Development
### Run Services Individually
Each service can be run independently for development:
```bash
# Auth Service
cd services/auth-service
npm install
npm run dev # Runs on port 4001
# User Service
cd services/user-service
npm install
npm run dev # Runs on port 4002
# Frontend
cd frontend
npm install
npm run dev # Runs on port 3000
```
### Database Migrations
```bash
# Auth Service migrations
cd services/auth-service
npx prisma migrate dev --name init
npx prisma generate
# User Service migrations
cd services/user-service
npx prisma migrate dev --name init
npx prisma generate
# Task Service migrations
cd services/task-service
npx prisma migrate dev --name init
npx prisma generate
# Notification Service migrations
cd services/notification-service
npx prisma migrate dev --name init
npx prisma generate
```
---
## ๐งช Testing
```bash
# Run all tests
npm test
# Run tests for specific service
cd services/auth-service
npm test
# E2E tests (Playwright)
cd frontend
npm run test:e2e
```
---
## ๐ Documentation
- [Architecture Design](./ARCHITECTURE.md) โ Detailed system design
- [API Gateway](./services/api-gateway/README.md) โ Routing and authentication
- [Auth Service](./services/auth-service/README.md) โ JWT authentication
- [User Service](./services/user-service/README.md) โ Profile management
- [Task Service](./services/task-service/README.md) โ Task CRUD + queue
- [Notification Service](./services/notification-service/README.md) โ Email + in-app notifications
- [Queue Worker](./services/queue-worker/README.md) โ Background jobs
---
## ๐ Key Features
### Microservices Architecture
- โ
**Database per service** โ Each service owns its data (no shared DB)
- โ
**API Gateway pattern** โ Centralized routing, auth, rate limiting
- โ
**Service decomposition** โ Clear domain boundaries (auth, users, tasks, notifications)
### Message-Driven Architecture
- โ
**BullMQ + Redis** โ Async job processing
- โ
**Event-driven** โ Task creation triggers notification job
- โ
**Decoupled services** โ Task Service doesn't directly call Notification Service
### Security
- โ
**JWT authentication** โ Stateless auth with 15-minute access tokens
- โ
**Refresh tokens** โ 7-day expiration for secure re-authentication
- โ
**Bcrypt password hashing** โ Industry-standard (salt rounds: 10)
- โ
**Rate limiting** โ 100 req/min per IP at API Gateway
- โ
**Owner-only access** โ Users can only access their own data
### DevOps
- โ
**Docker Compose** โ One-command local environment
- โ
**Health checks** โ Every service has `/health` endpoint
- โ
**Structured logging** โ Winston/Pino with correlation IDs
- โ
**CI/CD pipeline** โ GitHub Actions builds all services
---
## ๐ Deployment
### Local Development
```bash
docker compose up
```
### Staging/Production
**Option 1: Docker Compose on VPS**
```bash
# On server (Ubuntu/Debian)
docker compose -f docker-compose.prod.yml up -d
# Services use production environment variables
# PostgreSQL, Redis, and services run in containers
```
**Option 2: Kubernetes (EKS/GKE/AKS)**
```bash
# Deploy to Kubernetes
kubectl apply -f k8s/
# Each service runs as a separate deployment
# RDS for PostgreSQL, ElastiCache for Redis
```
**Frontend Deployment:**
- Netlify (recommended) โ Nuxt SSR with Nitro
- Vercel โ Alternative for Next.js-like SSR
- Self-hosted with Nginx
---
## ๐ Data Flow Examples
### User Registration
```
1. User submits form (frontend)
โ
2. POST /auth/register โ API Gateway
โ
3. API Gateway โ Auth Service
โ
4. Auth Service creates user in auth_db
โ
5. Returns success โ frontend redirects to login
```
### Create Task (with async notification)
```
1. User creates task (frontend)
โ
2. POST /tasks โ API Gateway (validates JWT)
โ
3. API Gateway โ Task Service
โ
4. Task Service:
- Saves task to task_db
- Publishes "task.created" job to BullMQ
โ
5. Queue Worker (background):
- Picks up job from Redis
- Calls Notification Service
โ
6. Notification Service:
- Saves notification to notification_db
- Sends email via Mailpit
```
---
## ๐งฐ Why This Stack?
| Technology | Reason |
|-----------|--------|
| **Nuxt 4** | SSR + Vue 3, production-ready, matches boilerplate |
| **NestJS** | Enterprise-grade, TypeScript-first, modular architecture |
| **PostgreSQL** | ACID compliance, production-grade, one DB per service |
| **Prisma** | Type-safe ORM, auto-migrations, excellent DX |
| **BullMQ** | Industry-standard Node.js job queue, Redis-backed |
| **Docker** | Consistent environments, easy orchestration |
---
## ๐ฏ What This Demonstrates
โ
**Microservices expertise** โ Service decomposition, API Gateway, database per service
โ
**Message-driven architecture** โ BullMQ job queues for async processing
โ
**Modern stack mastery** โ Nuxt 4, NestJS, Prisma, PostgreSQL, Redis
โ
**DevOps capabilities** โ Docker multi-container orchestration
โ
**Enterprise patterns** โ JWT auth, rate limiting, structured logging
โ
**Scalability** โ Each service can scale independently
---
## ๐ License
MIT License โ See [LICENSE](./LICENSE) for details.
---
## ๐ค Author
**Faiz Khairi**
- GitHub: [@faizkhairi](https://github.com/faizkhairi)
- LinkedIn: [linkedin.com/in/faizkhairi](https://www.linkedin.com/in/faizkhairi/)
- Website: [faizkhairi.github.io](https://faizkhairi.github.io)
---
## โญ Support
If you find this project helpful, please give it a star! โญ
Built with โค๏ธ to showcase production-grade microservices architecture.