A comprehensive microservices-based e-commerce application built with best practices for training AI models on microservices repository projects. This monorepo demonstrates modern microservices architecture, containerization, orchestration, and CI/CD pipelines.
This project implements a microservices architecture for an e-commerce platform with the following services:
┌─────────────────────────────────────────────────────────────┐
│ API Gateway │
│ (Port: 8000) │
└────────────┬────────────────────────────────────────────────┘
│
┌────────┴────────┬────────────┬───────────┬──────────────┐
│ │ │ │ │
┌───▼────┐ ┌──────▼─────┐ ┌──▼─────┐ ┌──▼────┐ ┌────▼──────┐
│ User │ │ Product │ │ Order │ │Payment│ │Notification│
│Service │ │ Service │ │Service │ │Service│ │ Service │
│(3001) │ │ (3002) │ │ (3003) │ │(3004) │ │ (3005) │
└───┬────┘ └──────┬─────┘ └───┬────┘ └───┬───┘ └────┬───────┘
│ │ │ │ │
└────────┬───────┴────────────┴────────────┴────────────┘
│
┌────────▼─────────┐ ┌──────────────┐
│ PostgreSQL │ │ Redis │
│ (Port: 5432) │ │ (Port: 6379) │
└──────────────────┘ └──────────────┘
- Entry point for all client requests
- Route management and load balancing
- Authentication and authorization
- Rate limiting and request validation
- User registration and authentication
- User profile management
- JWT token generation and validation
- Password hashing and security
- Product catalog management
- Product search and filtering
- Inventory management
- Product categories and tags
- Order creation and management
- Order status tracking
- Cart management
- Order history
- Payment processing simulation
- Payment method management
- Transaction history
- Refund handling
- Email notifications
- Order confirmation emails (triggered by Order Service)
- Payment confirmation emails (triggered by Payment Service)
- User registration emails
- REST API-based notifications
- Languages: Python (Flask), Node.js (Express)
- Databases: PostgreSQL, Redis
- Communication: Synchronous REST API calls (HTTP/JSON)
- Containerization: Docker, Docker Compose
- API Gateway: Node.js/Express
- CI/CD: GitHub Actions
- Monitoring: Prometheus, Grafana (configuration included)
This project uses synchronous REST API communication between microservices:
- All services communicate via HTTP REST APIs
- Order Service → Product Service (product validation)
- Order Service → Notification Service (order confirmations)
- Payment Service → Notification Service (payment confirmations)
- API Gateway → All Services (request routing)
RabbitMQ infrastructure is available but not currently used, allowing for future async patterns if needed.
.
├── services/
│ ├── api-gateway/ # API Gateway service
│ ├── user-service/ # User management service
│ ├── product-service/ # Product catalog service
│ ├── order-service/ # Order management service
│ ├── payment-service/ # Payment processing service
│ └── notification-service/ # Notification service
├── shared/
│ ├── proto/ # Protocol buffers (if using gRPC)
│ ├── utils/ # Shared utilities
│ └── config/ # Shared configuration
├── infrastructure/
│ ├── docker/ # Docker configurations
│ └── k8s/ # Kubernetes manifests (optional)
├── scripts/
│ ├── setup.sh # Setup script
│ ├── start-all.sh # Start all services
│ └── test-all.sh # Run all tests
├── .github/
│ └── workflows/ # CI/CD pipelines
├── docker-compose.yml # Docker Compose orchestration
├── docker-compose.dev.yml # Development environment
└── README.md # This file
- Docker (v20.10+)
- Docker Compose (v2.0+)
- Node.js (v16+) - for local development
- Python (v3.9+) - for local development
- Git
git clone https://github.com/AutoIntAPI/microservices-project-test-ground.git
cd microservices-project-test-ground# Start all services in detached mode
docker-compose up -d
# View logs
docker-compose logs -f
# Stop all services
docker-compose down- API Gateway: http://localhost:8000
- User Service: http://localhost:3001
- Product Service: http://localhost:3002
- Order Service: http://localhost:3003
- Payment Service: http://localhost:3004
- Notification Service: http://localhost:3005
# Register a new user
curl -X POST http://localhost:8000/api/users/register \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "password123", "name": "John Doe"}'
# Login
curl -X POST http://localhost:8000/api/users/login \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "password123"}'
# Get products
curl http://localhost:8000/api/products
# Create an order (requires authentication token)
curl -X POST http://localhost:8000/api/orders \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{"items": [{"product_id": 1, "quantity": 2}]}'Each service can be run independently for development:
# User Service
cd services/user-service
npm install # or pip install -r requirements.txt
npm run dev # or python app.py
# Product Service
cd services/product-service
npm install
npm run dev
# And so on for other services...# Run all tests
./scripts/test-all.sh
# Run tests for a specific service
cd services/user-service
npm test # or pytest# Run migrations for all services
docker-compose exec user-service npm run migrate
docker-compose exec product-service npm run migrate
docker-compose exec order-service npm run migrateThe project includes GitHub Actions workflows for:
- Continuous Integration: Automated testing on push/PR
- Code Quality: Linting and code style checks
- Docker Build: Build and push Docker images
- Deployment: Automated deployment to staging/production
Workflow files are located in .github/workflows/.
API documentation is available at:
- Swagger UI: http://localhost:8000/api-docs
- Each service also exposes its own API docs at
/api-docs
Each service requires specific environment variables. Example .env files are provided in each service directory as .env.example.
Key environment variables:
DATABASE_URL: PostgreSQL connection stringREDIS_URL: Redis connection stringJWT_SECRET: Secret for JWT token generationSERVICE_PORT: Port for the service to listen onNOTIFICATION_SERVICE_URL: Notification service URL (for order/payment services)PRODUCT_SERVICE_URL: Product service URL (for order service)USER_SERVICE_URL: User service URL (for API gateway)
- Logs: All services log to stdout/stderr (accessible via
docker-compose logs) - Prometheus: Metrics endpoint available at each service's
/metricsendpoint - Health Checks: Each service exposes a
/healthendpoint
- Containerization: Each service has its own Dockerfile
- Service Independence: Each service has its own database schema
- API Gateway Pattern: Centralized entry point
- Environment Configuration: Environment-based configuration
- Health Checks: Kubernetes-ready health check endpoints
- Graceful Shutdown: Proper signal handling
- Logging: Structured logging with log levels
- Error Handling: Consistent error response format
- Security: JWT authentication, password hashing, input validation
- Testing: Unit and integration tests for each service
- Documentation: API documentation with Swagger/OpenAPI
- CI/CD: Automated testing and deployment pipelines
This is a test ground project for training AI models. Contributions are welcome to add more features, improve architecture, or enhance documentation.
MIT License - See LICENSE file for details
For issues, questions, or contributions, please open an issue on GitHub.