A microservices-based ecommerce platform built with TypeScript, Node.js, and Express framework, designed for deployment on AWS EKS.
- Node.js (v16 or higher)
- npm or yarn package manager
npm installnpm run devThis starts the server with hot reload using nodemon and ts-node. The server will run on http://localhost:8000
# Build TypeScript to JavaScript
npm run build
# Start production server
npm startnpm run dev- Start development server with hot reloadnpm run build- Compile TypeScript to JavaScriptnpm start- Run production servernpm run lint- Run ESLintnpm run lint-fix- Fix ESLint issues automaticallynpm run prettier- Format code with Prettier
PORT- Server port (default: 8000)NODE_ENV- Environment mode (default: development)PRODUCT_SERVICE_LATENCY- Artificial latency for product service in milliseconds (default: 0)
- User Service (Port 3001) - Authentication and user management
- Product Service (Port 3002) - Product catalog and inventory
- Order Service (Port 3003) - Order processing (calls Product Service sync)
- Payment Service (Port 3004) - Payment processing
- Notification Service (Port 3005) - Email/SMS notifications
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ User Service │ │ Product Service │ │ Payment Service │
│ (Port 3001) │ │ (Port 3002) │ │ (Port 3004) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ ▲ │
│ │ │
▼ │ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Main App │ │ Order Service │ │ Notification │
│ (Port 8000) │◄───┤ (Port 3003) ├───►│ Service │
│ [Proxy/ALB] │ │ │ │ (Port 3005) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
│ HTTP GET /api/products
│ (inventory check)
▼
┌─────────────────┐
│ Product Service │
│ (Port 3002) │
└─────────────────┘
Flow:
- Client → Main App (ALB/Proxy)
- Order Service → Product Service (sync inventory check)
- All services communicate via REST APIs
- Service discovery using environment variables
Run all services at once:
./start-all.shFor debugging specific services:
# Stop all services first
lsof -ti:3001,3002,3003,3004,3005 | xargs kill -9
# Start only the services you need
PORT=3002 SERVICE_NAME=product-service npm run dev & # Dependency
PORT=3003 SERVICE_NAME=order-service PRODUCT_SERVICE_URL=http://localhost:3002 npm run dev # Debug targetAdd artificial latency to product service for testing:
# Add 2 second latency to product service
PORT=3002 SERVICE_NAME=product-service PRODUCT_SERVICE_LATENCY=6000 npm run dev &
# Test order service with slow product dependency
PORT=3003 SERVICE_NAME=order-service PRODUCT_SERVICE_URL=http://localhost:3002 npm run devRun comprehensive service tests:
./test-services.shDaily cycle:
- Start:
./start-all.sh - Test:
./test-services.sh - Stop:
lsof -ti:3001,3002,3003,3004,3005 | xargs kill -9
# Deploy all microservices
kubectl apply -f web-app.yaml
# Check deployment status
kubectl get pods -n ecommerce
kubectl get ingress -n ecommerce# Test all services via ALB
./test-eks.sh
# Manual testing
ALB_URL=$(kubectl get ingress ecommerce-ingress -n ecommerce -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
curl http://$ALB_URL/api/users# Add 6 second latency to product service
kubectl set env deployment/product-service PRODUCT_SERVICE_LATENCY=6000 -n ecommerce
# Remove latency (set to 0)
kubectl set env deployment/product-service PRODUCT_SERVICE_LATENCY=0 -n ecommerce
# Check current environment variables
kubectl describe deployment/product-service -n ecommerce | grep -A 10 Environment# Check pod logs
kubectl logs -f deployment/user-service -n ecommerce
# Check service connectivity
kubectl exec -it deployment/order-service -n ecommerce -- curl http://product-service:3002/api/products
# Port forward for direct testing
kubectl port-forward service/user-service 3001:3001 -n ecommerce