Microservices
A lightweight microservice backend for testing, featuring mock APIs, error simulation, and easy configuration for development and CI/CD pipelines.
Install / Use
/learn @sajadfallahdoost/MicroservicesREADME
Multi-Service Marketplace Platform
A modular e-commerce microservices platform demonstrating polyglot persistence, event-driven architecture, and modern DevOps practices across multiple technologies.
🏗️ Architecture
┌─────────────────────┐
│ API Gateway │
│ (Nginx) │
│ Port: 8080 │
└──────────┬──────────┘
│
┌────────────────────────────┼────────────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Auth │ │ Product │ │ Order │
│ (Django) │ │ (Go) │ │ (FastAPI) │
│ Port: 8000 │ │ Port: 8080 │ │ Port: 8001 │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │
▼ ▼ ▼
PostgreSQL MongoDB PostgreSQL
+ Redis
│
▼
┌──────────────┐
│ RabbitMQ │
│ Message │
│ Broker │
└──────┬───────┘
│
┌───────────────────────────┼───────────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Analytics │ │Notification │ │ Payment │
│ (Go) │ │ (Node.js) │ │ (C#) │
│ Port: 8082 │ │ Port: 8070 │ │ Port: 8083 │
└──────┬──────┘ └─────────────┘ └──────┬──────┘
│ │
▼ ▼
PostgreSQL Oracle DB
┌─────────────┐
│ Invoice │
│ (Django) │
│ Port: 8085 │
└──────┬──────┘
│
▼
PostgreSQL
🚀 Quick Start
Prerequisites
- Docker and Docker Compose
- Git
Start All Services
# Clone the repository
git clone <repository-url>
cd microservice/backend
# Start all services
docker-compose --profile all up -d
# Check service status
docker-compose ps
# View logs
docker-compose logs -f
Start Individual Services
# Start only the Auth service
docker-compose --profile auth up -d
# Start only the Product service
docker-compose --profile product up -d
# Start only the Order service
docker-compose --profile order up -d
# Start only the Payment service
docker-compose --profile payment up -d
# Start only the Notification service
docker-compose --profile notification up -d
# Start only the Analytics service
docker-compose --profile analytics up -d
# Start only the Invoice service
docker-compose --profile invoice up -d
# Start monitoring stack
docker-compose --profile monitoring up -d
# Start API Gateway
docker-compose --profile gateway up -d
📦 Services Overview
| Service | Technology | Database | Port | Profile |
|---------|-----------|----------|------|---------|
| Auth | Django + DRF | PostgreSQL | 8000 | auth |
| Product | Go + Fiber | MongoDB | 8080 | product |
| Order | FastAPI | PostgreSQL + Redis | 8001 | order |
| Payment | ASP.NET Core | Oracle | 8083 | payment |
| Notification | Node.js + TypeScript | - | 8070 | notification |
| Analytics | Go | PostgreSQL | 8082 | analytics |
| Invoice | Django + DRF | PostgreSQL | 8085 | invoice |
| Gateway | Nginx | - | 8080 | gateway |
1. Authentication Service
Django-based service for user management and JWT authentication
- User registration and login
- JWT token generation and validation
- Role-based access control (admin, vendor, customer)
- Password reset and email verification
Documentation: services/auth/README.md
# Start service
docker-compose --profile auth up -d
# Health check
curl http://localhost:8000/api/users/health/
2. Product Catalog Service
Go-based high-performance product catalog with MongoDB
- Product CRUD operations
- Inventory management
- Category management
- Fast search and filtering
Documentation: services/product/README.md
# Start service
docker-compose --profile product up -d
# Health check
curl http://localhost:8080/internal/health
3. Order Management Service
FastAPI service with Redis caching and RabbitMQ events
- Shopping cart management (Redis)
- Order creation and tracking
- Order status updates
- Event publishing to RabbitMQ
Documentation: services/order/README.md
# Start service
docker-compose --profile order up -d
# Health check
curl http://localhost:8001/api/v1/internal/health
4. Payment Service
ASP.NET Core service with Oracle Database
- Payment processing with mock gateway
- Refund handling
- Transaction logging
- Payment status tracking
Documentation: services/payment/README.md
# Start service
docker-compose --profile payment up -d
# Health check (wait ~60s for Oracle to initialize)
curl http://localhost:8083/health
5. Notification Service
Node.js service consuming RabbitMQ events
- Email/SMS notifications
- Order event handling
- Payment event handling
- Event-driven architecture
Documentation: services/notification/README.md
# Start service
docker-compose --profile notification up -d
# Health check
curl http://localhost:8070/health
6. Analytics Service
Go service for event tracking and metrics
- Event ingestion and storage
- Metrics collection
- Data aggregation
- RabbitMQ event consumption
Documentation: services/analytics/README.md
# Start service
docker-compose --profile analytics up -d
# Health check
curl http://localhost:8082/internal/health
7. Invoice Service
Django service aggregating data from multiple services
- Invoice generation for delivered orders
- Service orchestration (Order, Product, Auth)
- Automatic tax calculation (10%)
- Duplicate prevention
Documentation: services/invoice/README.md
# Start service
docker-compose --profile invoice up -d
# Health check
curl http://localhost:8085/api/health/
📚 Documentation
Comprehensive documentation is available in the /docs folder:
- Quick Start Guide - Get started quickly
- Architecture Overview - System design and patterns
- API Guide - API usage examples
- Invoice Service - Invoice service details
- Testing Guide - Testing scenarios and scripts
- Docker Commands - Docker reference
- RabbitMQ Info - Message queue setup
- Service Communication - Inter-service communication
🔧 Infrastructure
Message Broker
- RabbitMQ: http://localhost:15672 (guest/guest)
- Event-driven async communication
- Order and payment events
Monitoring
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3001 (admin/admin)
API Gateway
- Nginx: http://localhost:8080
- Routes requests to appropriate services
🧪 Testing
Test scripts are available in the /scripts folder:
# Test complete flow (all services)
bash scripts/test_complete_flow.sh
# Test API flow
bash scripts/test_api_flow.sh
# Test invoice flow
bash scripts/test_invoice_flow.sh
# Windows PowerShell
powershell scripts/test_invoice_flow.ps1
🌐 API Access
Through API Gateway (Port 8080)
- Auth:
http://localhost:8080/auth/api/v1/auth/* - Product:
http://localhost:8080/products/* - Order:
http://localhost:8080/orders/api/v1/* - Payment:
http://localhost:8080/payments/api/v1/* - Analytics:
http://localhost:8080/metrics/* - Invoice:
http://localhost:8080/invoices/api/*
Direct Service Access
- Auth: http://localhost:8000
- Product: http://localhost:8080
- Order: http://localhost:8001
- Payment: http://localhost:8083
- Notification: http://localhost:8070
- Analytics: http://localhost:8082
- Invoice: http://localhost:8085
📖 API Documentation
Each service provides interactive API documentation:
- Auth: http://localhost:8000/swagger/
- Product: http://localhost:8080/swagger
- Order: http://localhost:8001/docs
- Analytics: http://localhost:8082/swagger (when available)
- Invoice: http://localhost:8085/swagger/
🔐 Admin Interfaces
- Auth Admin: http://localhost:8000/admin
- Order Admin: http://localhost:8001/admin
- Product Admin: http://localhost:8080/admin
- Invoice Admin: http://localhost:8085/admin
- RabbitMQ Management: http://localhost:15672
- Grafana Dashboards: http://localhost:3001
🗃️ Database Technologies
| Database | Services | Purpose | |----------|----------|---
