A comprehensive microservices architecture demonstration featuring multiple deployment strategies, service discovery, and cloud-native patterns.
This project demonstrates a complete microservices ecosystem with:
- Service Discovery: Netflix Eureka Server
- Multiple Technology Stacks: Java (Spring Boot), Node.js (Express), Python (Flask)
- Database: MySQL with connection pooling
- API Documentation: Swagger/OpenAPI integration
- Containerization: Docker & Docker Compose
- Cloud Deployment: AWS with Terraform (ECS, Lambda, RDS)
- Infrastructure as Code: Terraform modules for scalable deployment
| Service | Technology | Port | Description |
|---|---|---|---|
| Eureka Server | Spring Boot | 8761 | Service discovery and registration |
| Java Service | Spring Boot 3 + Java 22 | 8080 | REST API with database integration |
| Node Service | Express.js + Node 20 | 3000 | Lightweight API service |
| Python Service | Flask + Python 3.11 | 5001 | Data processing service |
| MySQL Database | MySQL 8.0 | 3306 | Persistent data storage |
- Java Lambda: Serverless Spring Boot application
- Node Lambda: Lightweight serverless function
- Python Lambda: Data processing serverless function
- Docker & Docker Compose
- Version Managers (for local development):
- SDKMAN (Java)
- NVM (Node.js)
- pyenv (Python)
- AWS CLI (for cloud deployment)
- Terraform (for infrastructure)
# Clone and navigate
git clone <repository-url>
cd demo-microservices
# Start all services
./run.sh docker
# or on Windows
run.bat dockerService URLs:
- Eureka Dashboard: http://localhost:8761
- Java Service API: http://localhost:8080/swagger-ui.html
- Node Service API: http://localhost:3000/api-docs
- Python Service API: http://localhost:5001/apidocs
# Setup with specific versions
./run.sh local --java-version 22 --node-version 20 --python-version 3.11
# Or use defaults
./run.sh local# Deploy full infrastructure
./run.sh aws
# Deploy only Lambda functions
./run.sh lambdaCopy and customize the environment file:
cp .env.example .envKey environment variables:
# Database
MYSQL_ROOT_PASSWORD=rootpass
MYSQL_DATABASE=appdb
MYSQL_USER=appuser
MYSQL_PASSWORD=apppass
# Spring Boot
SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/appdb
EUREKA_SERVER_URL=http://eureka-server:8761/eureka/All services expose similar endpoints for consistency:
GET /info- Service health and metadataPOST /process- Process data (doubles input value)
curl -X POST http://localhost:8080/process \
-H "Content-Type: application/json" \
-d '{"value": 10}'
# Response: {"result": 20}Services automatically register with Eureka Server:
- Java Service:
JAVA-SERVICE - Node Service:
NODE-SERVICE - Python Service:
PYTHON-SERVICE
infra/
βββ modules/
β βββ vpc/ # VPC, subnets, gateways
β βββ instances/ # EC2, security groups
βββ docker/ # ECS deployment
βββ serverless/ # Lambda deployment
βββ *.tf # Main infrastructure
- VPC with public/private subnets
- ECS Cluster for containerized services
- RDS MySQL instance
- Lambda Functions for serverless compute
- API Gateway for Lambda endpoints
- S3 Buckets for artifacts and state
- IAM Roles with least privilege access
The run scripts automatically manage language versions:
# Java with SDKMAN
sdk install java 22
sdk use java 22
# Node.js with NVM
nvm install 20
nvm use 20
# Python with pyenv
pyenv install 3.11
pyenv global 3.11services:
eureka-server: # Service discovery
java-service: # Spring Boot API
node-service: # Express.js API
python-service: # Flask API
mysql: # Database with health checks- Eureka: http://localhost:8761/actuator/health
- Java Service: http://localhost:8080/actuator/health
- Node Service: http://localhost:3000/info
- Python Service: http://localhost:5001/info
- MySQL:
mysqladmin pingwith retry logic - Eureka Server: HTTP health check with 12 retries
- Java Service: Actuator health endpoint monitoring
- All Services: Dependency-based startup ordering
- Automatic Restart:
unless-stoppedpolicy for resilience
# Startup order ensures proper service registration
Eureka Server β Database β Application Services- No Hardcoded Credentials: All secrets use environment variables
- JWT Security: Configurable JWT secrets with production warnings
- Input Validation: Request validation and sanitization
- Environment Configuration: Secure defaults with .env.security template
- Docker Security: All services configured with environment variables
- Persistent Storage: Secure outbox pattern implementation
- Code Injection Prevention: All user inputs properly sanitized
- Database Security: Parameterized queries and connection encryption
- Enable HTTPS/TLS with SSL certificates
- Implement API authentication (JWT/OAuth2)
- Use AWS Secrets Manager for credential rotation
- Enable AWS CloudTrail for audit logging
- Implement rate limiting and DDoS protection
- Add Web Application Firewall (WAF)
- Enable VPC Flow Logs for network monitoring
./run.sh local- Direct service execution
- Hot reloading for development
- Local MySQL container
./run.sh docker- Full containerization
- Service orchestration
- Production-like environment
./run.sh aws- Managed container orchestration
- Auto-scaling capabilities
- Load balancing
./run.sh lambda- Serverless compute
- Event-driven architecture
- Cost-effective for sporadic workloads
- Multiple service instances behind load balancer
- Database read replicas
- Eureka clustering for high availability
- Adjust container resource limits
- Database instance sizing
- Lambda memory allocation
# Java Service
cd demo-java-service && ./mvnw test
# Node Service
cd demo-node-service && npm test
# Python Service
cd demo-python-service && python -m pytest# Test service communication
curl http://localhost:8761/eureka/apps- Java: Spring Boot 3.3.1, Spring Cloud 2023.0.2, Java 22
- Node.js: Express 4.21.1, Eureka JS Client, Node 20
- Python: Flask 3.0.0, py-eureka-client, Python 3.11
- Containerization: Docker, Docker Compose with health checks
- Cloud: AWS (ECS, Lambda, RDS with encryption, API Gateway)
- IaC: Terraform with modular design and sensitive variables
- Database: MySQL 8.0 with encryption and backup retention
- Security: Encrypted storage, restricted security groups, input validation
- API Documentation: Swagger/OpenAPI 3.0
- Version Management: SDKMAN, NVM, pyenv
- Build Tools: Maven, npm, pip
- Deployment: Multi-environment scripts (run.sh/run.bat)
- Fork the repository
- Create feature branch:
git checkout -b feature/new-feature - Commit changes:
git commit -am 'Add new feature' - Push to branch:
git push origin feature/new-feature - Submit pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Services not registering with Eureka:
- Check network connectivity between containers
- Verify Eureka server is healthy before starting services
- Review service configuration for correct Eureka URL
- Check Docker health checks are passing
Database connection failures:
- Ensure MySQL container is running and healthy
- Verify database credentials in
.envfile - Check network connectivity between services and database
- Confirm RDS encryption is properly configured
Port conflicts:
- Ensure ports 3000, 5001, 8080, 8761, 3306 are available
- Modify port mappings in
docker-compose.ymlif needed - Check security group rules for AWS deployments
AWS deployment issues:
- Verify AWS credentials and permissions (marked as sensitive)
- Check Terraform state and plan output
- Review CloudWatch logs for service errors
- Ensure EBS and RDS encryption is enabled
- Validate security group configurations
Dependency vulnerabilities:
- Run
npm audit fixfor Node.js services - Update Python packages:
pip install --upgrade -r requirements.txt - Check for Spring Boot security updates
# Docker logs
docker-compose logs -f [service-name]
# AWS CloudWatch logs
aws logs tail /aws/lambda/[function-name] --follow
# Local service logs
# Check individual service console output