# nhutkhanh24520782/eks-event-driven-autoscaling architecture

> Architecture diagram of the GitHub repository nhutkhanh24520782/eks-event-driven-autoscaling, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nhutkhanh24520782/eks-event-driven-autoscaling
- Repository: https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling

## Overview

This repository implements an EKS-hosted asynchronous job system and its autoscaling/chaos demonstration: clients submit jobs through the API, SQS buffers them, and worker pods process them while KEDA can scale from queue depth. Terraform and Kubernetes manifests provide the deployment foundation; the frontend, observability stack, and experiment tools support operation and evaluation. The README explicitly notes that some latency instrumentation and queue-depth monitoring pieces are incomplete. Links reflect documented behavior and the sampled API/worker code; unsampled subsystem internals are not inferred.

Main entry points: [`apps/backend/worker-service/src/main.js`](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/blob/main/apps/backend/worker-service/src/main.js) (Job worker), [`apps/backend/api-service/src/main.js`](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/blob/main/apps/backend/api-service/src/main.js) (Job API), [`infra/envs/dev`](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/infra/envs/dev) (AWS infrastructure), [`apps/frontend`](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/apps/frontend) (Chaos dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["Job application"]
  node_frontend["Chaos dashboard"]
  node_api["Job API<br/>[main.js]"]
  node_worker["Job worker<br/>[main.js]"]
  node_sqs["SQS jobs and DLQ"]
end

subgraph group_platform["EKS platform"]
  node_alb["AWS ALB"]
  node_terraform["AWS infrastructure"]
  node_k8s["Kubernetes workloads"]
  node_keda["KEDA scaling"]
  node_hpa["CPU HPA option<br/>[hpa-baseline.yaml]"]
end

subgraph group_observability["Telemetry"]
  node_prometheus[("Prometheus")]
  node_grafana["Grafana dashboards"]
  node_promtail["Promtail log collection"]
  node_loki[("Loki logs")]
end

subgraph group_experiments["Experiments"]
  node_loadgen["Load generator<br/>[k6-workload.js]"]
  node_analyzer["Latency analyzer"]
  node_evidence["Experiment evidence"]
end

node_client(("Client"))
node_aws["AWS services"]
node_kubernetes["Kubernetes cluster"]

node_client -->|"sends requests"| node_alb
node_alb -->|"serves root"| node_frontend
node_alb -->|"routes API"| node_api
node_frontend -->|"triggers scenarios"| node_api
node_api -->|"publishes jobs"| node_sqs
node_worker -->|"polls and deletes"| node_sqs
node_sqs -->|"delivers jobs"| node_worker
node_sqs -->|"routes failed jobs"| node_sqs
node_terraform -->|"provisions services"| node_aws
node_terraform -->|"provisions EKS"| node_kubernetes
node_k8s -->|"deploys workloads"| node_kubernetes
node_keda -->|"scales from backlog"| node_worker
node_hpa -.->|"scales by CPU"| node_worker
node_worker -->|"exposes metrics"| node_prometheus
node_prometheus -->|"supplies metrics"| node_grafana
node_kubernetes -->|"provides logs"| node_promtail
node_promtail -->|"ships logs"| node_loki
node_loki -->|"supplies logs"| node_grafana
node_client -->|"runs workload"| node_loadgen
node_loadgen -->|"submits jobs"| node_api
node_analyzer -->|"reads captured data"| node_evidence

click node_frontend "https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/apps/frontend"
click node_api "https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/blob/main/apps/backend/api-service/src/main.js"
click node_worker "https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/blob/main/apps/backend/worker-service/src/main.js"
click node_terraform "https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/infra/envs/dev"
click node_k8s "https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/k8s/base"
click node_keda "https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/blob/main/k8s/autoscaling/keda-scaledobject.yaml"
click node_hpa "https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/blob/main/k8s/autoscaling/hpa-baseline.yaml"
click node_prometheus "https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/observability/prometheus"
click node_grafana "https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/observability/grafana"
click node_promtail "https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/observability/loki"
click node_loki "https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/observability/loki"
click node_loadgen "https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/blob/main/scripts/load-test/k6-workload.js"
click node_analyzer "https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/blob/main/scripts/metrics/analyze-control-loop-latency.py"
click node_evidence "https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/docs/evidence"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend,node_api,node_worker,node_sqs,node_client toneBlue
class node_alb,node_terraform,node_k8s,node_keda,node_hpa toneAmber
class node_prometheus,node_grafana,node_promtail,node_loki toneMint
class node_loadgen,node_analyzer,node_evidence toneRose
class node_aws,node_kubernetes toneIndigo
```

## Components

### Job application

- [Chaos dashboard](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/apps/frontend): `apps/frontend`
- [Job API](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/blob/main/apps/backend/api-service/src/main.js): `apps/backend/api-service/src/main.js`
- [Job worker](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/blob/main/apps/backend/worker-service/src/main.js): `apps/backend/worker-service/src/main.js`
- **SQS jobs and DLQ**

### EKS platform

- **AWS ALB**
- [AWS infrastructure](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/infra/envs/dev): `infra/envs/dev`
- [Kubernetes workloads](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/k8s/base): `k8s/base`
- [KEDA scaling](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/blob/main/k8s/autoscaling/keda-scaledobject.yaml): `k8s/autoscaling/keda-scaledobject.yaml`
- [CPU HPA option](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/blob/main/k8s/autoscaling/hpa-baseline.yaml): `k8s/autoscaling/hpa-baseline.yaml`

### Telemetry

- [Prometheus](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/observability/prometheus): `observability/prometheus`
- [Grafana dashboards](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/observability/grafana): `observability/grafana`
- [Promtail log collection](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/observability/loki): `observability/loki`
- [Loki logs](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/observability/loki): `observability/loki`

### Experiments

- [Load generator](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/blob/main/scripts/load-test/k6-workload.js): `scripts/load-test/k6-workload.js`
- [Latency analyzer](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/blob/main/scripts/metrics/analyze-control-loop-latency.py): `scripts/metrics/analyze-control-loop-latency.py`
- [Experiment evidence](https://github.com/nhutkhanh24520782/eks-event-driven-autoscaling/tree/main/docs/evidence): `docs/evidence`

### Other components

- **Client**
- **AWS services**
- **Kubernetes cluster**

## Connections

- Client → AWS ALB: sends requests (evidence: `README.md`)
- AWS ALB → Chaos dashboard: serves root (evidence: `README.md`)
- AWS ALB → Job API: routes API (evidence: `README.md`)
- Chaos dashboard → Job API: triggers scenarios (evidence: `README.md`)
- Job API → SQS jobs and DLQ: publishes jobs (evidence: `apps/backend/api-service/src/main.js`)
- Job worker → SQS jobs and DLQ: polls and deletes (evidence: `apps/backend/worker-service/src/main.js`)
- SQS jobs and DLQ → Job worker: delivers jobs (evidence: `README.md`)
- SQS jobs and DLQ → SQS jobs and DLQ: routes failed jobs (evidence: `README.md`)
- AWS infrastructure → AWS services: provisions services (evidence: `README.md`)
- AWS infrastructure → Kubernetes cluster: provisions EKS (evidence: `README.md`)
- Kubernetes workloads → Kubernetes cluster: deploys workloads (evidence: `README.md`)
- KEDA scaling → Job worker: scales from backlog (evidence: `README.md`)
- CPU HPA option → Job worker: scales by CPU (evidence: `README.md`)
- Job worker → Prometheus: exposes metrics (evidence: `README.md`)
- Prometheus → Grafana dashboards: supplies metrics (evidence: `README.md`)
- Kubernetes cluster → Promtail log collection: provides logs (evidence: `README.md`)
- Promtail log collection → Loki logs: ships logs (evidence: `README.md`)
- Loki logs → Grafana dashboards: supplies logs (evidence: `README.md`)
- Client → Load generator: runs workload (evidence: `README.md`)
- Load generator → Job API: submits jobs (evidence: `scripts/load-test/k6-workload.js`)
- Latency analyzer → Experiment evidence: reads captured data (evidence: `scripts/metrics/analyze-control-loop-latency.py`)
