How grilled-swampert/ecommerce-microservices works
Project Type and Purpose
• This is a container-based microservices application written in Node.js, comprising three core services (order, payment, user).
• It’s designed for deployment on Kubernetes (also supports Docker Compose), uses Kong as an API gateway/ingress controller, and Postgres as the backing datastore.
• The repo also contains load-testing scripts and chaos-engineering experiments to validate resilience and performance.
File Structure
• Top-level directories:
– order-service, payment-service, user-service: each contains a Dockerfile, Node.js code (index.js, logger.js, metrics.js, metricsMiddleware.js), package.json.
– k8s, services: Kubernetes Deployment and Service YAMLs for each microservice, Postgres, Kong rate limiting, and health-monitoring sidecars.
– experiments: chaos-injection manifests (CPU stress, IO chaos, network delay, pod kill).
– microservices-load-tests: JS load-test scripts, configuration, and results.
– ingress-setup.yaml / ingress_setup.txt: instructions for configuring the Kong ingress.
– docker-compose.yml & deploy-all.sh: local multi-container orchestration scripts.
(Minimal) README
• The README (“op”) is a placeholder; no architecture details are provided. All insights must come from the directory layout, file names, and YAMLs.
Main Components and Their Interactions
a. API Gateway (Kong)
– Receives all external HTTP traffic.
– Enforces rate limits (k8s/kong-rate-limiter.yaml).
– Routes requests to the appropriate microservice.
b. Microservices
– order-service, payment-service, user-service run as separate Kubernetes Deployments and Services.
– Each service exposes REST endpoints and a metrics endpoint.
– Services may call each other: e.g., order-service may validate user via user-service and process payment via payment-service.
c. Database
– A single Postgres instance (Deployment in k8s/postgres-deployment.yaml).
– All services connect to this shared database for persistence.
d. Monitoring & Metrics
– metricsMiddleware.js in each service exports application metrics.
– Kubernetes Service manifests (services/*-monitor.yaml) expose monitoring endpoints (for Prometheus).
– Logs captured via logger.js, assume a centralized logging system (e.g., Fluentd or ELK).
e. Load Testing and Chaos Engineering
– microservices-load-tests runs performance tests against the live cluster.
– experiments/*.yaml inject faults to validate resilience.
f. Deployment Orchestration
– docker-compose.yml & deploy-all.sh for local testing.
– Full production deployment via kubectl apply -f k8s/ and services/.
Architectural Patterns and Principles
• Microservices with API Gateway pattern.
• Sidecar pattern for monitoring (metrics scraping).
• Single shared relational database (monolithic datastore) – consider splitting if scale or CQRS needed.
• Chaos-engineering and automated load-testing integrated into CI/CD pipeline.