A production-ready, scalable microservices-based e-commerce platform deployed on AWS
Features β’ Architecture β’ Tech Stack β’ Getting Started β’ API Docs β’ Deployment
- Overview
- Features
- Architecture
- Tech Stack
- Project Structure
- Getting Started
- AWS Services
- API Documentation
- Security
- Monitoring & Logging
- Contributing
- License
CloudRetail is a full-stack, cloud-native e-commerce platform built with modern microservices architecture. Designed for scalability, reliability, and security, it demonstrates enterprise-level cloud deployment practices using AWS services.
This project showcases:
- β Microservices Architecture - Independent, scalable services
- β Event-Driven Design - Asynchronous communication using AWS EventBridge
- β Saga Pattern - Distributed transaction management
- β Cloud-Native Deployment - Containerized services on AWS ECS
- β Production-Ready - Complete CI/CD, monitoring, and security
- π User Authentication - JWT-based auth with Amazon Cognito
- π¦ Product Catalog - Browse products with advanced search and filtering
- π Shopping Cart - Real-time cart management
- π³ Multiple Payment Methods - Credit Card, PayPal, Bank Transfer
- π§ Order Notifications - Email updates via Amazon SES
- π€ User Profile - Manage account details and order history
- β Product Reviews - Rate and review products
- π Analytics Dashboard - Real-time sales and inventory metrics
- π¦ Inventory Management - Low stock alerts and automatic notifications
- π·οΈ Product Management - CRUD operations for products
- π Order Management - Track and update order statuses
- π₯ User Management - Customer accounts administration
- π Event-Driven Architecture - EventBridge for service communication
- π Saga Orchestration - Reliable distributed transactions
- π³ Containerization - Docker containers on AWS ECS
- ποΈ Database Persistence - MySQL on Amazon RDS
- π CDN Distribution - Amazon CloudFront for static assets
- π Security - WAF protection, encryption at rest/transit
- π Monitoring - CloudWatch metrics and alarms
- πΎ Automated Backups - AWS Backup for data protection
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β USER LAYER β
β ββββββββββββββββ ββββββββββββββββ β
β β Browser ββββββββββββββββββββββββββββ Mobile App β β
β ββββββββββββββββ ββββββββββββββββ β
ββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ¬ββββββββββββ
β β
βββββββββββββββββββ¬ββββββββββββββββββββββββ
β HTTPS
ββββββββββββΌβββββββββββ
β Amazon CloudFront β β CDN
β + AWS WAF β β Security
ββββββββββββ¬βββββββββββ
β
ββββββββββββΌβββββββββββ
β AWS API Gateway β β API Management
ββββββββββββ¬βββββββββββ
β
ββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββ
β MICROSERVICES LAYER (ECS) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β User β β Product β β Order β β
β β Service β β Service β β Service β β
β β (Port 3001) β β (Port 3003) β β (Port 3002) β β
β ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ β
β β β β β
β ββββββββ΄ββββββββ ββββββββ΄ββββββββ ββββββββ΄ββββββββ β
β β Payment β β Inventory β β Customer β β
β β Service β β Service β β Products β β
β β (Port 3005) β β (Port 3004) β β Service β β
β ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ β
β β β β β
β ββββββββββββββββββββ΄βββββββββββββββββββ β
β β β
β ββββββββββΌβββββββββ β
β β Saga β β
β β Orchestrator β β
β ββββββββββ¬βββββββββ β
ββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββ
β β
βββββββββββΌββββββββββ β
β Amazon EventBridgeβ β Event Bus β
βββββββββββ¬ββββββββββ β
β β
ββββββββββββββββΌβββββββββββββββ β
β β β β
ββββββββββΌββββββββ βββββΌβββββββ ββββββΌβββββββ β
β AWS Lambda β β Lambda β β Lambda β β
β Order Event β β Welcome β β Payment β β
β Handler β β Email β βConfirmationβ β
ββββββββββ¬ββββββββ βββββ¬βββββββ ββββββ¬βββββββ β
β β β β
βββββββββββββββ΄βββββββββββββββ β
β β
ββββββββββΌβββββββββ β
β Amazon SES β β Email Service β
βββββββββββββββββββ β
β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DATA LAYER β
β ββββββββββββββββββββ ββββββββββββββββββββ β
β β Amazon RDS βββββββββββ AWS Backup β β
β β (MySQL 8.0) β β (Daily Backups) β β
β ββββββββββββββββββββ ββββββββββββββββββββ β
β ββββββββββββββββββββ ββββββββββββββββββββ β
β β Amazon S3 β β Amazon ECR β β
β β (Images/Assets) β β (Docker Images) β β
β ββββββββββββββββββββ ββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- π― Microservices Pattern - Independent, loosely coupled services
- π Event-Driven Architecture - Asynchronous messaging via EventBridge
- π Saga Pattern - Distributed transaction coordination
- π API Gateway Pattern - Centralized API management
- πͺ CQRS Lite - Separation of concerns in data operations
- πΎ Database per Service - Each service manages its own data
- Framework: Vue.js 3.x
- State Management: Vuex
- HTTP Client: Axios
- Routing: Vue Router
- UI Components: Custom + Bootstrap
- Runtime: Node.js (v18.x)
- Framework: Express.js
- Database: MySQL 8.0
- Authentication: JWT + bcrypt
- ORM: Raw SQL with connection pooling
- API Specs: OpenAPI 3.0 (Swagger)
- Containerization: Docker
- Cloud Platform: AWS
- Version Control: Git/GitHub
- Scripts: PowerShell, Bash
| Service | Purpose | Configuration |
|---|---|---|
| Amazon ECS | Container orchestration for microservices | EC2 launch type, 7 services |
| Amazon EC2 | Compute instances for ECS tasks | t3.small instance |
| Amazon RDS | Managed MySQL database | db.t3.micro, Multi-AZ ready |
| AWS Lambda | Serverless event handlers | 7 functions (Node.js 18.x) |
| Amazon EventBridge | Event bus for service communication | Custom event patterns |
| Amazon API Gateway | REST API management | Regional endpoint |
| Amazon CloudFront | CDN for frontend assets | Global edge locations |
| Amazon S3 | Static asset storage | 2 buckets with versioning |
| Amazon ECR | Docker image registry | 14 repositories |
| AWS WAF | Web application firewall | CloudFront protection |
| Amazon Cognito | User authentication | User pool with JWT |
| Amazon SES | Email notifications | Verified domains |
| Amazon CloudWatch | Monitoring and logging | Custom metrics, alarms |
| AWS Backup | Automated database backups | Daily backups, 7-day retention |
| AWS IAM | Identity and access management | Least privilege policies |
| AWS KMS | Encryption key management | Data encryption at rest |
CloudRetail/
βββ π frontend/ # Vue.js Frontend Application
β βββ src/
β β βββ components/ # Reusable Vue components
β β βββ views/ # Page components
β β βββ router/ # Vue Router configuration
β β βββ store/ # Vuex state management
β β βββ services/ # API service layer
β β βββ App.vue # Root component
β βββ public/ # Static assets
β βββ package.json
β βββ Dockerfile
β
βββ π backend/ # Microservices Backend
β βββ api-gateway/ # API Gateway Service (Port 3000)
β β βββ index.js
β β βββ package.json
β β βββ Dockerfile
β β
β βββ user-service/ # User Management (Port 3001)
β β βββ index.js
β β βββ routes/
β β βββ controllers/
β β βββ models/
β β βββ Dockerfile
β β
β βββ product-service/ # Product Catalog (Port 3003)
β β βββ index.js
β β βββ routes/
β β βββ Dockerfile
β β
β βββ order-service/ # Order Processing (Port 3002)
β β βββ index.js
β β βββ routes/
β β βββ Dockerfile
β β
β βββ payment-service/ # Payment Processing (Port 3005)
β β βββ index.js
β β βββ Dockerfile
β β
β βββ inventory-service/ # Inventory Management (Port 3004)
β β βββ index.js
β β βββ Dockerfile
β β
β βββ customer-products-service/ # Seller Products (Port 3006)
β β βββ index.js
β β βββ Dockerfile
β β
β βββ saga-orchestrator/ # Distributed Transaction Coordinator
β β βββ index.js
β β βββ Dockerfile
β β
β βββ database/ # Database Scripts
β β βββ schema.sql
β β βββ init.sql
β β βββ migrations/
β β
β βββ eventbridge-simulator.js # Local EventBridge testing
β
βββ π lambda-functions/ # AWS Lambda Functions
β βββ order-notification/
β βββ welcome-email/
β βββ payment-confirmation/
β βββ low-inventory-alert/
β βββ order-status-update/
β βββ product-notification/
β
βββ π infrastructure/ # Infrastructure as Code
β βββ cloudformation/ # CloudFormation templates
β βββ terraform/ # Terraform configurations (optional)
β βββ diagrams/ # Architecture diagrams
β
βββ π ecs-tasks/ # ECS Task Definitions
β βββ user-service.json
β βββ product-service.json
β βββ order-service.json
β βββ ... (other services)
β
βββ π deployment-scripts/ # Deployment Automation
β βββ deploy-to-aws.ps1
β βββ setup-ecs.ps1
β βββ setup-rds.ps1
β βββ deploy-lambda.ps1
β βββ stop-all-aws.ps1
β
βββ π configs/ # Configuration Files
β βββ CloudRetail-API.postman_collection.json
β βββ cloudwatch-dashboard.json
β βββ waf-config.json
β βββ grafana-dashboard-k6.json
β
βββ π scripts/ # Utility Scripts
β βββ populate-db.js
β βββ backup-db.sh
β βββ health-check.ps1
β
βββ π testing-showcase/ # Testing & Load Tests
β βββ k6/ # Load testing scripts
β βββ integration/ # Integration tests
β
βββ π docker-compose.yml # Local development setup
βββ π swagger.yaml # API documentation (OpenAPI 3.0)
βββ π package.json # Root package configuration
βββ π README.md # This file
βββ π .gitignore
- Node.js v18.x or higher
- Docker & Docker Compose
- MySQL 8.0 (or use Docker)
- AWS Account (for cloud deployment)
- AWS CLI configured
git clone https://github.com/yourusername/CloudRetail.git
cd CloudRetail# Install root dependencies
npm install
# Install backend dependencies
cd backend/user-service && npm install
cd ../product-service && npm install
cd ../order-service && npm install
# ... repeat for other services
# Install frontend dependencies
cd ../../frontend
npm installCreate .env files in each service directory:
# backend/user-service/.env
PORT=3001
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=cloudretail
JWT_SECRET=your_jwt_secret_key
AWS_REGION=us-east-1
EVENTBRIDGE_BUS_NAME=cloudretail-events# Start MySQL using Docker
docker-compose up -d mysql
# Import database schema
mysql -u root -p cloudretail < backend/database/schema.sql
# Populate with sample data (optional)
node scripts/populate-db.jsOption A: Using Docker Compose
docker-compose up --buildOption B: Manual Start
# Terminal 1 - User Service
cd backend/user-service
npm start
# Terminal 2 - Product Service
cd backend/product-service
npm start
# Terminal 3 - Order Service
cd backend/order-service
npm start
# Terminal 4 - Payment Service
cd backend/payment-service
npm start
# Terminal 5 - Inventory Service
cd backend/inventory-service
npm start
# Terminal 6 - API Gateway
cd backend/api-gateway
npm start
# Terminal 7 - Frontend
cd frontend
npm run serve- Frontend: http://localhost:8080
- API Gateway: http://localhost:3000
- Swagger UI: http://localhost:3000/api-docs
- Health Check: http://localhost:3000/health
- AWS CLI configured with appropriate credentials
- Docker installed for building images
- PowerShell (for Windows) or Bash (for Linux/Mac)
# 1. Build and push Docker images to ECR
.\deployment-scripts\build-and-push-ecr.ps1
# 2. Set up RDS database
.\deployment-scripts\setup-rds.ps1
# 3. Deploy ECS services
.\deployment-scripts\setup-ecs.ps1
# 4. Deploy Lambda functions
.\deployment-scripts\deploy-lambda.ps1
# 5. Configure API Gateway
.\deployment-scripts\setup-api-gateway.ps1
# 6. Deploy frontend to S3 + CloudFront
.\deployment-scripts\deploy-frontend.ps11. Create ECR Repositories
aws ecr create-repository --repository-name cloudretail/user-service
aws ecr create-repository --repository-name cloudretail/product-service
# ... create for all services2. Build and Push Docker Images
# Login to ECR
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <account-id>.dkr.ecr.us-east-1.amazonaws.com
# Build and push each service
cd backend/user-service
docker build -t cloudretail/user-service .
docker tag cloudretail/user-service:latest <account-id>.dkr.ecr.us-east-1.amazonaws.com/cloudretail/user-service:latest
docker push <account-id>.dkr.ecr.us-east-1.amazonaws.com/cloudretail/user-service:latest3. Create ECS Cluster
aws ecs create-cluster --cluster-name cloudretail-cluster4. Register Task Definitions
aws ecs register-task-definition --cli-input-json file://ecs-tasks/user-service.json
aws ecs register-task-definition --cli-input-json file://ecs-tasks/product-service.json
# ... register all task definitions5. Create ECS Services
aws ecs create-service \
--cluster cloudretail-cluster \
--service-name user-service \
--task-definition user-service:1 \
--desired-count 1 \
--launch-type EC26. Deploy Lambda Functions
cd lambda-functions/order-notification
zip -r function.zip .
aws lambda create-function \
--function-name order-notification \
--runtime nodejs18.x \
--role arn:aws:iam::<account>:role/lambda-role \
--handler index.handler \
--zip-file fileb://function.zipAccess Swagger UI at: http://localhost:3000/api-docs (local) or your API Gateway URL
Production: https://aygfmjsp82.execute-api.us-east-1.amazonaws.com/prod
Local: http://localhost:3000
Most endpoints require JWT authentication. Include the token in the Authorization header:
Authorization: Bearer <your-jwt-token>POST /users/register # Register new user
POST /users/login # Login
GET /users/profile # Get user profile (Auth required)
PUT /users/profile # Update profile (Auth required)GET /products # List all products
GET /products/:id # Get product details
POST /products # Create product (Admin)
PUT /products/:id # Update product (Admin)
DELETE /products/:id # Delete product (Admin)
GET /products/search?q= # Search productsPOST /orders # Create new order (Auth required)
GET /orders # Get user orders (Auth required)
GET /orders/:id # Get order details (Auth required)
PUT /orders/:id/status # Update order status (Admin)
POST /orders/:id/cancel # Cancel order (Auth required)POST /payments # Process payment (Auth required)
GET /payments/:id # Get payment details (Auth required)
POST /payments/:id/refund # Refund payment (Admin)GET /inventory/:productId # Check stock availability
PUT /inventory/:productId # Update stock (Admin)
POST /inventory/alerts # Configure low-stock alerts (Admin)Success Response:
{
"success": true,
"data": {
// ... response data
}
}Error Response:
{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "Human-readable error message"
}
}- π JWT Tokens - Stateless authentication
- π€ Amazon Cognito - User pool management
- π bcrypt - Password hashing (10 salt rounds)
- π« Role-Based Access Control (RBAC) - Admin vs. Customer roles
- π Encryption at Rest - AWS KMS for RDS encryption
- π Encryption in Transit - TLS/SSL everywhere
- π‘οΈ AWS WAF - Protection against common web exploits
- π Input Validation - SQL injection prevention
- π« CORS Configuration - Controlled cross-origin requests
- π VPC Isolation - Private subnets for backend services
- π Security Groups - Strict firewall rules
- π‘οΈ WAF Rules - Rate limiting, IP filtering
- π Secrets Management - AWS Secrets Manager
- β Principle of least privilege (IAM policies)
- β Regular security updates
- β Database connection pooling with limits
- β Request rate limiting
- β SQL injection prevention (parameterized queries)
- β XSS protection
- β CSRF tokens for state-changing operations
-
Metrics Collected:
- API Gateway request count, latency, 4XX/5XX errors
- ECS CPU/Memory utilization per service
- RDS connections, CPU, storage
- Lambda invocations, errors, duration
-
CloudWatch Alarms:
- High API error rate (>5% 5XX errors)
- High API latency (>3 seconds)
- High ECS CPU (>80%)
- Lambda errors
- Low RDS storage
- Service Logs: CloudWatch Logs for all ECS services
- Lambda Logs: Automatic CloudWatch Logs integration
- API Gateway Logs: Access logs and execution logs
- Structured Logging: JSON format for easy parsing
# Check all services health
curl http://localhost:3000/health
# Individual service health
curl http://localhost:3001/health # User Service
curl http://localhost:3002/health # Order Service
curl http://localhost:3003/health # Product Servicecd testing-showcase/k6
k6 run load-test.jsnpm testImport the collections from /configs directory:
CloudRetail-API.postman_collection.json- API testingCloudRetail-Complete-Workflow.postman_collection.json- End-to-end flows
- API Response Time: < 200ms average
- Database Queries: < 50ms average
- Order Processing: < 2 seconds end-to-end
- Concurrent Users: Tested up to 1000 simultaneous users
- Throughput: 500+ requests/second
- Database connection pooling
- Redis caching (ready for implementation)
- CDN for static assets (CloudFront)
- Horizontal scaling with ECS
- Async event processing with EventBridge
- Database indexes on frequently queried columns
1. Services can't connect to database
# Check RDS security group allows ECS security group
# Verify connection string in environment variables
# Test connectivity from EC2 instance2. ECS services stuck in "PENDING"
# Check ECS task logs
aws ecs describe-tasks --cluster cloudretail-cluster --tasks <task-id>
# Common causes: Docker image pull failures, port conflicts3. Lambda function timeouts
# Increase timeout in function configuration
# Check CloudWatch Logs for errors
# Verify VPC configuration if using VPCContributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Use ESLint configuration (
.eslintrc.js) - Follow JavaScript Standard Style
- Write meaningful commit messages
- Add tests for new features
This project is licensed under the MIT License - see the LICENSE file for details.
Nimsha Fernando
- GitHub: nimshafernando
- LinkedIn: Nimsha Fernando
- Email: nimsha.fernando@gmail.com
- AWS Documentation and Best Practices
- Node.js and Express.js communities
- Vue.js ecosystem
- Open source contributors
For support and questions:
- π§ Email: nimsha.riveen@gmail.com
- π¬ Issues: GitHub Issues
- π Documentation: Wiki