⬡ Hub
Skip to content

End-to-End E-Commerce Microservices Reference Architecture

Overview

This project represents a Enterprise-Grade Cloud Native Architecture. It demonstrates a complete E-Commerce platform deployed on AWS EKS, with full Automation, Testing, and Observability.

Key Features

  • Infrastructure: 30+ AWS Resources (EKS, RDS, WAF, etc.) via Terraform.
  • Application: Spring Boot Microservices with Redis Caching, RabbitMQ, and OpenTelemetry.
  • DevOps: CI/CD via Jenkins & GitHub Actions (Self-Hosted), GitOps via ArgoCD.
  • Quality Assurance: Selenium Grid (Cross-Browser) + SauceLabs Integration, Cucumber (BDD), RestAssured (API), JMeter (Performance).
  • Observability: Prometheus, Grafana, ELK Stack, Jaeger.

1. Architecture

graph TD
    User -->|HTTPS| CloudFront[CloudFront CDN]
    CloudFront -->|WAF| APIGW[API Gateway]
    APIGW -->|VPC Link| NLB[Network Load Balancer]
    NLB -->|Traffic| Ingress[Ingress Controller]

    subgraph "EKS Cluster (VPC Private Subnets)"
        Ingress --> OrderSvc[Order Service]
        Ingress --> ProductSvc[Product Service]

        OrderSvc -->|Async Event| RabbitMQ[RabbitMQ / Amazon MQ]
        RabbitMQ --> InventorySvc[Inventory Service]

        OrderSvc -->|Read/Write| RDS[RDS PostgreSQL]
        ProductSvc -->|Cache| Redis[ElastiCache Redis]
    end

    subgraph "Observability"
        Prometheus -->|Scrape| OrderSvc
        Filebeat -->|Ship Logs| ElasticSearch[OpenSearch]
        Grafana -->|Query| Prometheus
    end

    subgraph "CI/CD & Testing"
        Jenkins -->|Build| ECR[Amazon ECR]
        SeleniumGrid -->|Test UI| CloudFront
        SauceLabs -->|Cloud Test| CloudFront
    end

2. Project Structure

Directory Description
infra/ Terraform code for AWS (VPC, EKS, RDS, WAF, etc.).
app/ Spring Boot with OTel Agent (Dockerfile).
testing/ Automation: DriverFactory (SauceLabs), Cucumber (.feature).
cicd/ Pipelines: Jenkinsfile, GHA, ArgoCD (application.yaml).
observability/ Monitoring: servicemonitor.yaml, Prometheus Values.

3. Detailed Implementation Steps

Step 1: Provision Infrastructure (Terraform)

  1. Navigate to infra/.
  2. Run terraform init to download providers.
  3. Run terraform apply. This creates:
    • VPC: Private subnets for EKS/RDS.
    • EKS: Control Plane and Fargate Profiles.
    • Databases: RDS and OpenSearch.
  4. Output: Note the cluster_endpoint and nlb_dns_name.

Step 2: Configure EKS & Observability

  1. Update local kubeconfig: aws eks update-kubeconfig --name ecommerce-prod-cluster.
  2. Install Prometheus Operator: bash helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm install prometheus prometheus-community/kube-prometheus-stack -f observability/prometheus-values.yaml
    • Scraping Logic: We use a ServiceMonitor (see infra/k8s/servicemonitor.yaml). This CRD tells Prometheus "Find any Service with label app: ecommerce-service and scrape port 8080 path /actuator/prometheus".
  3. Install Log Shipping: bash kubectl apply -f observability/filebeat-kubernetes.yaml
    • This DaemonSet reads /var/log/containers/*.log and sends them to the OpenSearch domain created by Terraform.

Step 3: Application Telemetry (OpenTelemetry)

We use the OpenTelemetry Java Agent for zero-code instrumentation. 1. Where: In app/Dockerfile, we download opentelemetry-javaagent.jar. 2. How: The app starts with -javaagent:/app/opentelemetry-javaagent.jar. 3. Config: Environment variables in Kubernetes Deployment (OTEL_TRACES_EXPORTER=otlp) point to the Jaeger/Tempo collector. 4. Result: Every API call generates a Trace ID that propagates through API GW -> Order Service -> RabbitMQ -> Inventory.

Step 4: Testing & Automation

  1. API Testing:
    • The API is exposed via AWS API Gateway.
    • Get the Endpoint: terraform output api_endpoint.
    • Run Tests: mvn test -DbaseURI=<API_ENDPOINT>.
  2. Cross-Browser Testing (SauceLabs):
    • We use DriverFactory.java.
    • Set Env Vars: export SAUCE_USERNAME=user SAUCE_ACCESS_KEY=key.
    • Run: mvn test -Dplatform=saucelabs.
    • The tests connect to the SauceLabs Cloud Grid instead of local Docker.

Step 5: CI/CD (GitOps)

  1. Push Code: Commit changes to Git.
  2. Jenkins/GHA: Builds Docker image -> Pushes to ECR -> Updates Helm Chart version in Git.
  3. ArgoCD: Detects the change in Git and syncs the EKS cluster to the new version automatically.