# arjunmnn/twsthreetierappchallenge architecture

> Architecture diagram of the GitHub repository arjunmnn/twsthreetierappchallenge, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-03-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arjunmnn/twsthreetierappchallenge
- Repository: https://github.com/arjunmnn/twsthreetierappchallenge

## Overview

##### What this project is (type + purpose)
This is a **three-tier web application** intended as a **Kubernetes-on-AWS EKS deployment challenge**:
- **Frontend:** React SPA (in `frontend/`)
- **Backend:** Node.js/Express API (in `backend/`)
- **Database:** MongoDB (deployed via Kubernetes manifests in `k8s_manifests/mongo/`)
- **Platform/Deployment:** Dockerized services deployed to **AWS EKS**, exposed via **AWS Load Balancer Controller** (see `k8s_manifests/full_stack_lb.yaml` and README steps)
- **CI/CD hint:** A `Jenkinsfile` exists at repo root, implying a pipeline that likely builds/pushes images and/or applies manifests.

##### Frontend (React)
Key files:
- `frontend/src/App.js`, `frontend/src/Tasks.js`
- `frontend/src/services/taskServices.js` → strongly implies the frontend calls backend “tasks” endpoints
- Dockerized via `frontend/Dockerfile`

##### Backend (Node/Express + Mongo)
Key files:
- `backend/index.js` (likely Express server entry)
- `backend/routes/tasks.js` (REST endpoints)
- `backend/models/task.js` (Mongo model/schema)
- `backend/db.js` (Mongo connection)
- Dockerized via `backend/Dockerfile`

##### Kubernetes manifests (EKS deployment)
Key files:
- `k8s_manifests/frontend-deployment.yaml`, `frontend-service.yaml`
- `k8s_manifests/backend-deployment.yaml`, `backend-service.yaml`
- `k8s_manifests/mongo/deploy.yaml`, `service.yaml`, `secrets.yaml`
- `k8s_manifests/full_stack_lb.yaml` → ingress/load balancer resource to expose full stack
- README explicitly deploys AWS Load Balancer Controller (ALB/NLB integration)

- Deployments → Pods
- Services (ClusterIP/LoadBalancer) for internal routing
- Ingress (or equivalent) fronted by AWS ALB provisioned by the controller
- Mongo Secret feeding Mongo deployment via env vars

##### Jenkinsfile
- Source → Jenkins pipeline → Docker build → push to registry (ECR/DockerHub) → `kubectl apply` / GitOps

##### React Frontend (SPA)
- “serves static assets; calls backend API”
##### Node.js/Express Backend API
- “tasks routes; task model; connects to Mongo”
##### (Optional but recommended) External/Platform services

- Browser → Frontend: `HTTP GET / (static content)`
- Frontend → Backend: `HTTP/JSON (e.g., /api/tasks)`
- Backend → MongoDB: `MongoDB wire protocol (read/write tasks)`

- `frontend/src/services/taskServices.js` (frontend→backend)
- `backend/routes/tasks.js` (API endpoints)
- `backend/db.js` + `backend/models/task.js` (backend→mongo)

Purpose: show how the above containers run on EKS and how traffic enters the cluster.

As separate nodes/areas:
- **AWS Account / Region**
- **EKS Cluster**
- **Namespace: workshop** (README uses this)
- **Frontend Deployment → Frontend Pods**
- **Frontend Service**
- **Backend Deployment → Backend Pods**
- **Backend Service**
- **Mongo Deployment/StatefulSet (as defined) → Mongo Pod(s)**
- **Mongo Service**
- **Mongo Secret** (`k8s_manifests/mongo/secrets.yaml`)
- **kube-system namespace**
- **AWS Load Balancer Controller** (deployed via Helm per README)

At the edge:
- **AWS ALB (provisioned by controller)**
created/managed from `full_stack_lb.yaml` (likely Ingress)
- **Internet / Users**

- Internet → ALB: `HTTPS/HTTP`
- ALB → (K8s) Ingress target → Frontend Service: `HTTP`
- Frontend Pod → Backend Service: `HTTP`
- Backend Pod → Mongo Service: `TCP 27017`
- Mongo Pod reads credentials from **Secret**

Key accuracy details to include explicitly (since they’re central to this challenge repo):
- **Ingress (or ALB-backed entry resource)** as the link between ALB and K8s services.
- **Services as stable endpoints** in front of ephemeral pods.
- **Secrets feeding Mongo** (and possibly backend, depending on manifests).

Purpose: show how changes become running pods on EKS.

Include:
- **Git repo (this repo)**
- **Jenkins**
- stages: test (optional), build Docker images, push images, deploy manifests
- **Container Registry** (ECR or DockerHub; choose what you actually use)
- **EKS API Server** (deployment action)
- **Kubernetes Deployments** rolling out new pods

- Git push/PR → Jenkins
- Jenkins → Docker build (frontend/backend)
- Jenkins → Registry push
- Jenkins → `kubectl apply` / Helm / manifest update → EKS cluster

##### Main components to enumerate (don’t merge them—separate them)
- React UI (code) vs Frontend container image vs Frontend pod(s)
- Express API (code) vs Backend container image vs Backend pod(s)
- MongoDB process vs Mongo pod vs Mongo service
- Ingress resource vs AWS ALB vs AWS Load Balancer Controller
- Kubernetes namespace boundary (`workshop`)
- Secrets/config (Mongo secrets; any ConfigMaps if present later)
- CI/CD (Jenkins) and registry

This matches your instruction “simply separating the project into as many components as possible is best.”

##### Relationships / interactions to capture
- “HTTP GET static assets”
- “HTTP JSON REST: create/read/update/delete tasks”
- “MongoDB TCP 27017”
- “K8s Service routing (kube-proxy/IPVS)”
- “Controller provisions ALB via AWS APIs”

##### Architectural patterns to call out
- **Three-tier architecture** (presentation → API → data)
- **Stateless frontend/backend** behind Services (scale horizontally)
- **Kubernetes declarative deployments** via manifests
- **Externalized configuration/secrets** for Mongo credentials
- **Cloud-native ingress** using AWS Load Balancer Controller

##### Technologies to label on components
- Frontend: React
- Backend: Node.js + Express (implied by routing structure)
- DB: MongoDB + (likely Mongoose via `models/task.js`)
- Containers: Docker
- Orchestration: Kubernetes on AWS EKS
- Ingress/LB: AWS Load Balancer Controller + ALB
- CI/CD: Jenkins

##### Labels
- Name (e.g., “backend-service”)
- Type (Deployment/Service/Pod/Secret/Ingress)
- Tech (Node.js, React, MongoDB)

- Direction
- Protocol/port (HTTP 80/443, Mongo 27017)
- Intent (“List tasks”, “Create task”)

##### Boundaries (important for EKS)
- AWS Account/Region
- EKS Cluster
- Namespace: workshop
- Namespace: kube-system (LB controller)

This makes the “where does it run” question unambiguous.

Deliver these artifacts:
##### C4 Container view: Browser → React → Node API → Mongo
2. **EKS Deployment view:** ALB → Ingress → Services → Pods → Mongo (+ Secrets, namespaces, controller)
##### CI/CD view: Git → Jenkins → Registry → EKS rollout

Together they’ll be detailed, accurate, and directly traceable to the repo structure and README deployment flow.

## Diagram (Mermaid)

```mermaid
flowchart TD

%% =======================
%% Diagram A: Logical / C4 Container View
%% =======================
subgraph A["A) Logical Application Architecture (C4 Container View)"]
direction TB

U["User (Browser)"]:::client

subgraph A1["Frontend (React SPA)"]
direction TB
FE_Static["Static assets (index.html)"]:::frontend
FE_App["React App (App.js)"]:::frontend
FE_Tasks["Tasks UI (Tasks.js)"]:::frontend
FE_Client["API Client (taskServices.js)"]:::frontend
end

subgraph A2["Backend (Node.js/Express API)"]
direction TB
BE_Entry["API Server (index.js)"]:::backend
BE_Routes["Tasks REST routes (routes/tasks.js)"]:::backend
BE_Model["Task model/schema (models/task.js)"]:::backend
BE_DB["Mongo connection (db.js)"]:::backend
end

DB["MongoDB (Tasks data)"]:::datastore

U -->|"HTTP_GET_/ (static)"| FE_Static
FE_Static -->|"loads"| FE_App
FE_App -->|"renders"| FE_Tasks
FE_Tasks -->|"calls"| FE_Client
FE_Client -->|"HTTP_JSON_REST_/api/tasks"| BE_Entry
BE_Entry -->|"routes_/tasks"| BE_Routes
BE_Routes -->|"uses"| BE_Model
BE_Entry -->|"connects_via"| BE_DB
BE_DB -->|"MongoDB_TCP_27017"| DB
BE_Routes -->|"CRUD_tasks"| DB
end

%% =======================
%% Diagram B: EKS Deployment / Runtime View
%% =======================
subgraph B["B) Deployment Architecture (AWS EKS Runtime View)"]
direction TB

INET["Internet / Public users"]:::external

subgraph AWS["AWS Account / Region"]
direction TB

ALB["AWS ALB (provisioned)"]:::aws
AWSAPI["AWS APIs (ELBv2/IAM/EC2)"]:::aws

subgraph EKS["Amazon EKS Cluster"]
direction TB

APISERVER["Kubernetes API Server / Control Plane"]:::aws

subgraph KSYS["Namespace: kube-system"]
direction TB
LBC["AWS Load Balancer Controller (Helm)"]:::platform
end

subgraph WS["Namespace: workshop"]
direction TB

ING["Ingress / LB entry (full_stack_lb.yaml)"]:::network

subgraph FE_NS["Frontend workload"]
direction TB
FE_DEP["Deployment: frontend"]:::k8s
FE_PODS["Pods: frontend (replicas)"]:::pod
FE_SVC["Service: frontend-service"]:::network
end

subgraph BE_NS["Backend workload"]
direction TB
BE_DEP["Deployment: backend"]:::k8s
BE_PODS["Pods: backend (replicas)"]:::pod
BE_SVC["Service: backend-service"]:::network
end

subgraph MO_NS["MongoDB workload"]
direction TB
MO_SEC["Secret: mongo-secrets"]:::secret
MO_DEP["Deployment/Workload: mongo"]:::k8s
MO_POD["Pod: mongo"]:::pod
MO_SVC["Service: mongo-service"]:::network
end

end
end
end

INET -->|"HTTP/HTTPS_80/443"| ALB
LBC -->|"watches_Ingress"| ING
LBC -->|"provisions/updates"| AWSAPI
AWSAPI -->|"creates/updates"| ALB

ALB -->|"routes_to"| ING
ING -->|"HTTP_to_Service"| FE_SVC
FE_SVC -->|"k8s_service_routing"| FE_PODS
FE_PODS -->|"HTTP_JSON_REST_to_backend-service"| BE_SVC
BE_SVC -->|"k8s_service_routing"| BE_PODS
BE_PODS -->|"MongoDB_TCP_27017"| MO_SVC
MO_SVC -->|"k8s_service_routing"| MO_POD

MO_SEC -->|"env_vars/credentials"| MO_DEP
MO_DEP -->|"creates"| MO_POD

APISERVER -->|"applies_manifests"| WS
APISERVER -->|"runs_controller"| KSYS
end

%% =======================
%% Diagram C: CI/CD / Delivery Pipeline View
%% =======================
subgraph C["C) CI/CD Delivery Pipeline (Jenkins)"]
direction TB

DEV["Developer"]:::external
GIT["Git Repository (this repo)"]:::external
JEN["Jenkins Pipeline (Jenkinsfile)"]:::cicd
REG["Container Registry (abstract)"]:::cicd

subgraph BUILD["Build Artifacts"]
direction TB
FE_IMG["Frontend Docker image (frontend/Dockerfile)"]:::cicd
BE_IMG["Backend Docker image (backend/Dockerfile)"]:::cicd
K8S_MAN["Kubernetes manifests (k8s_manifests/*)"]:::cicd
DOCS["Deployment instructions (README)"]:::cicd
end

DEV -->|"git_push/PR"| GIT
GIT -->|"webhook/poll"| JEN
JEN -->|"build"| FE_IMG
JEN -->|"build"| BE_IMG
JEN -->|"push"| REG
FE_IMG -->|"stored_as_tagged_image"| REG
BE_IMG -->|"stored_as_tagged_image"| REG
JEN -->|"kubectl_apply"| K8S_MAN
K8S_MAN -->|"deploy_to"| APISERVER
DOCS -->|"guides_manual_steps"| DEV
end

%% =======================
%% Click events (from component_mapping)
%% =======================
click FE_App "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/frontend/src/App.js"
click FE_Tasks "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/frontend/src/Tasks.js"
click FE_Client "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/frontend/src/services/taskServices.js"
click FE_Static "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/frontend/public/index.html"
click FE_IMG "https://github.com/arjunmnn/twsthreetierappchallenge/tree/main/frontend/Dockerfile"

click BE_Entry "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/backend/index.js"
click BE_Routes "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/backend/routes/tasks.js"
click BE_Model "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/backend/models/task.js"
click BE_DB "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/backend/db.js"
click BE_IMG "https://github.com/arjunmnn/twsthreetierappchallenge/tree/main/backend/Dockerfile"

click FE_DEP "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/k8s_manifests/frontend-deployment.yaml"
click FE_SVC "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/k8s_manifests/frontend-service.yaml"
click BE_DEP "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/k8s_manifests/backend-deployment.yaml"
click BE_SVC "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/k8s_manifests/backend-service.yaml"
click MO_DEP "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/k8s_manifests/mongo/deploy.yaml"
click MO_SVC "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/k8s_manifests/mongo/service.yaml"
click MO_SEC "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/k8s_manifests/mongo/secrets.yaml"
click ING "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/k8s_manifests/full_stack_lb.yaml"

click JEN "https://github.com/arjunmnn/twsthreetierappchallenge/tree/main/Jenkinsfile"
click DOCS "https://github.com/arjunmnn/twsthreetierappchallenge/blob/main/README.md"

%% =======================
%% Styles
%% =======================
classDef client fill:#E5E7EB,stroke:#6B7280,color:#111827,stroke-width:1px
classDef external fill:#F3F4F6,stroke:#9CA3AF,color:#111827,stroke-width:1px
classDef frontend fill:#DBEAFE,stroke:#2563EB,color:#0F172A,stroke-width:1px
classDef backend fill:#BFDBFE,stroke:#1D4ED8,color:#0F172A,stroke-width:1px
classDef datastore fill:#DCFCE7,stroke:#16A34A,color:#052E16,stroke-width:1px
classDef network fill:#E9D5FF,stroke:#7C3AED,color:#1F1035,stroke-width:1px
classDef k8s fill:#CFFAFE,stroke:#0891B2,color:#083344,stroke-width:1px
classDef pod fill:#A5F3FC,stroke:#0E7490,color:#083344,stroke-width:1px
classDef secret fill:#FCE7F3,stroke:#DB2777,color:#500724,stroke-width:1px
classDef aws fill:#FFEDD5,stroke:#F97316,color:#7C2D12,stroke-width:1px
classDef platform fill:#FEF9C3,stroke:#CA8A04,color:#422006,stroke-width:1px
classDef cicd fill:#FEF3C7,stroke:#D97706,color:#451A03,stroke-width:1px
```
