Microservices Architecture Demo
This project demonstrates a complete microservices architecture with service discovery, API gateway, distributed tracing, and containerized deployment.
Architecture Overview
API Gateway (Nginx/Kong)
↓
Service Discovery (Consul)
↓
┌─────────────┬─────────────┬─────────────┐
│ User │ Product │ Order │
│ Service │ Service │ Service │
└─────────────┴─────────────┴─────────────┘
↓ ↓ ↓
PostgreSQL MongoDB MySQL
Services
1. User Service
- User authentication and management
- JWT token generation
- Profile management
- Tech: Node.js + Express + PostgreSQL
2. Product Service
- Product catalog management
- Inventory tracking
- Search functionality
- Tech: Node.js + MongoDB
3. Order Service
- Order processing
- Payment integration
- Order history
- Tech: Node.js + MySQL
Key Components
API Gateway
- Request routing
- Load balancing
- Rate limiting
- Authentication
Service Discovery (Consul)
- Service registration
- Health checking
- Configuration management
Message Queue (RabbitMQ)
- Asynchronous communication
- Event-driven architecture
- Reliable message delivery
Distributed Tracing (Jaeger)
- Request tracing across services
- Performance monitoring
- Dependency visualization
Docker Deployment
Each service runs in its own container:
version: '3.8'
services:
user-service:
build: ./user-service
ports:
- "3001:3000"
environment:
- DATABASE_URL=postgresql://...
product-service:
build: ./product-service
ports:
- "3002:3000"
environment:
- MONGODB_URI=mongodb://...
Inter-Service Communication
REST API
// Product service calling User service
const user = await axios.get(
`http://user-service:3000/api/users/${userId}`
);
Event-Driven
// Order service publishing event
channel.publish('orders', 'order.created',
Buffer.from(JSON.stringify(order))
);
Running Locally
# Start all services
docker-compose up -d
# Check service health
curl http://localhost:8500/v1/health/state/passing
# Access API Gateway
curl http://localhost:8080/api/users
Current Status
🚧 In Progress: Implementing Kubernetes deployment and CI/CD pipeline
View progress on GitHub.