# oparag-dev/secure-gitops-k8s-delivery architecture

> Architecture diagram of the GitHub repository oparag-dev/secure-gitops-k8s-delivery, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/oparag-dev/secure-gitops-k8s-delivery
- Repository: https://github.com/oparag-dev/secure-gitops-k8s-delivery

## Overview

#### Purpose and topology
This is a DevSecOps reference repository that provisions AWS infrastructure and deploys a task-management application through GitOps. The runtime path is public TLS load balancer → Nginx-hosted React SPA → internal Flask API → private Amazon RDS PostgreSQL. The application is packaged and deployed separately from its cloud and cluster foundations.

#### Application entry points
- Flask starts through `app/taskapp_backend/run.py`; API routing, authentication, and persistence are centered in `app/taskapp_backend/app/routes.py`, `app/taskapp_backend/app/auth.py`, and `app/taskapp_backend/app/models.py`.
- The React/Vite client starts at `app/taskapp_frontend/src/main.tsx`, with routing/application composition in `app/taskapp_frontend/src/App.tsx`.
- Browser-to-API integration is centralized in `app/taskapp_frontend/src/services/api.ts`; production Nginx proxies `/api/` to the backend via `app/taskapp_frontend/nginx-production.conf`.

#### User, auth, and task flow
The SPA owns login state through `app/taskapp_frontend/src/contexts/AuthContext.tsx` and gates authenticated UI using `app/taskapp_frontend/src/components/ProtectedRoute.tsx`. Dashboard/Kanban interactions originate in `app/taskapp_frontend/src/pages/Dashboard.tsx` and task UI components. Requests reach Flask REST endpoints, where JWT authentication protects task operations; SQLAlchemy models form the boundary to PostgreSQL. Database schema evolution is managed with Alembic under `app/taskapp_backend/migrations/env.py` and `app/taskapp_backend/migrations/versions/d5edfb30a373_initial_migration.py`.

#### Container and Kubernetes application boundary
Each tier has an independent container build definition: `app/taskapp_backend/Dockerfile` and `app/taskapp_frontend/Dockerfile`. Helm is the deployable application contract:
- Backend Deployment and internal ClusterIP service: `helm/taskapp/templates/backend-deployment.yaml`, `helm/taskapp/templates/backend-service.yaml`.
- Frontend Deployment, public service, and Nginx configuration: `helm/taskapp/templates/frontend-deployment.yaml`, `helm/taskapp/templates/frontend-service.yaml`, `helm/taskapp/templates/frontend-nginx-configmap.yaml`.
- Environment-specific image tags, RDS host, and load-balancer/TLS settings are supplied through `helm/taskapp/values.yaml`. Backend database credentials and JWT key are intentionally external Kubernetes Secrets.

#### GitOps delivery control flow
GitHub Actions validates, builds, scans, publishes immutable commit-SHA images to Docker Hub, and updates Helm image tags through `.github/workflows/ci.yml`. Argo CD watches the repository and reconciles the Helm chart into the `taskapp` namespace using `argocd/taskapp-application.yaml`; reconciliation includes automated drift correction/pruning. This makes Git and chart values the desired-state boundary, while Docker Hub is the image distribution dependency.

#### AWS and cluster foundation
Terraform bootstraps protected remote state separately in `terraform/bootstrap/backend/main.tf`, then composes the main environment from `terraform/root/main.tf` and reusable modules. Architecturally material modules include private networking (`terraform/modules/vpc/main.tf`), managed PostgreSQL (`terraform/modules/rds/main.tf`), DNS (`terraform/modules/dns/main.tf`), and state/object storage (`terraform/modules/s3/main.tf`). kOps defines the AWS Kubernetes control plane and workers in `kops/cluster.yaml`; workloads run on that cluster rather than directly on Terraform-managed compute.

#### Security and observability guardrails
Kyverno admission enforcement is defined in `kyverno/policies/taskapp-deployment-security.yaml`, requiring versioned images and hardened, resource-bounded pod settings for TaskApp deployments. Namespace separation begins in `k8s/namespaces.yaml`. Prometheus/Grafana are installed as platform services with configuration in `monitoring/kube-prometheus-stack-values.yaml`; the TaskApp chart exposes monitoring integration through `helm/taskapp/templates/servicemonitor.yaml`. Guarded lifecycle orchestration is provided by `scripts/deploy.sh` and `scripts/destroy.sh`.

Main entry points: [`helm/taskapp/values.yaml`](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/helm/taskapp/values.yaml) (TaskApp Helm Chart), [`helm/taskapp/templates/frontend-deployment.yaml`](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/helm/taskapp/templates/frontend-deployment.yaml) (Frontend Deployment), [`kops/cluster.yaml`](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/kops/cluster.yaml) (kOps Kubernetes Cluster), [`terraform/root/main.tf`](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/terraform/root/main.tf) (Terraform Environment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["TaskApp"]
  node_frontend["Frontend Deployment<br/>Nginx React workload"]
  node_react_spa["React SPA<br/>Vite client<br/>[main.tsx]"]
  node_api_client["API Client<br/>browser API layer<br/>[api.ts]"]
  node_backend["Backend Deployment<br/>Flask workload"]
  node_api_auth["REST API &amp; JWT Auth<br/>Flask routes<br/>[routes.py]"]
  node_models["SQLAlchemy Models<br/>persistence layer<br/>[models.py]"]
  node_alembic["Alembic Migrations<br/>schema migration<br/>[env.py]"]
end

subgraph group_delivery["GitOps Delivery"]
  node_helm_chart["TaskApp Helm Chart<br/>deployment contract<br/>[values.yaml]"]
  node_ci["GitHub Actions CI<br/>build and publish pipeline<br/>[ci.yml]"]
  node_dockerhub[("Docker Hub<br/>image registry")]
  node_argocd["Argo CD<br/>GitOps reconciler"]
end

subgraph group_platform["AWS Platform"]
  node_load_balancer{{"Public TLS Load Balancer<br/>AWS ingress<br/>[values.yaml]"}}
  node_postgres[("RDS PostgreSQL<br/>managed database<br/>[main.tf]")]
  node_kops_cluster{{"kOps Kubernetes Cluster<br/>AWS Kubernetes runtime<br/>[cluster.yaml]"}}
  node_terraform["Terraform Environment<br/>infrastructure composition<br/>[main.tf]"]
  node_vpc["Private VPC Networking<br/>network module<br/>[main.tf]"]
  node_remote_state[("Terraform Remote State<br/>bootstrap storage<br/>[main.tf]")]
end

subgraph group_operations["Guardrails"]
  node_kyverno["Kyverno Policies<br/>admission control"]
  node_monitoring["Prometheus &amp; Grafana<br/>platform observability"]
  node_servicemonitor["TaskApp ServiceMonitor<br/>metrics integration"]
end

node_users(("Users<br/>actor"))

node_users -->|"HTTPS"| node_load_balancer
node_load_balancer -->|"public service"| node_frontend
node_frontend -->|"serves"| node_react_spa
node_react_spa -->|"task requests"| node_api_client
node_api_client -->|"/api/"| node_frontend
node_frontend -->|"Nginx proxy"| node_backend
node_backend -->|"routes requests"| node_api_auth
node_api_auth -->|"persists tasks"| node_models
node_models -->|"SQL"| node_postgres
node_alembic -->|"evolves schema"| node_postgres
node_ci -->|"publishes SHA images"| node_dockerhub
node_ci -->|"updates image tags"| node_helm_chart
node_helm_chart -->|"desired state"| node_argocd
node_argocd -->|"reconciles taskapp namespace"| node_kops_cluster
node_dockerhub -->|"image pulls"| node_kops_cluster
node_helm_chart -->|"renders workload"| node_frontend
node_helm_chart -->|"renders workload"| node_backend
node_terraform -->|"provisions"| node_vpc
node_terraform -->|"provisions"| node_postgres
node_remote_state -.->|"stores state"| node_terraform
node_vpc -->|"network foundation"| node_kops_cluster
node_kyverno -->|"admission enforcement"| node_kops_cluster
node_servicemonitor -->|"scrape target"| node_monitoring
node_helm_chart -->|"renders"| node_servicemonitor

click node_load_balancer "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/helm/taskapp/values.yaml"
click node_frontend "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/helm/taskapp/templates/frontend-deployment.yaml"
click node_react_spa "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/app/taskapp_frontend/src/main.tsx"
click node_api_client "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/app/taskapp_frontend/src/services/api.ts"
click node_backend "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/helm/taskapp/templates/backend-deployment.yaml"
click node_api_auth "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/app/taskapp_backend/app/routes.py"
click node_models "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/app/taskapp_backend/app/models.py"
click node_postgres "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/terraform/modules/rds/main.tf"
click node_alembic "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/app/taskapp_backend/migrations/env.py"
click node_helm_chart "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/helm/taskapp/values.yaml"
click node_ci "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/.github/workflows/ci.yml"
click node_argocd "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/argocd/taskapp-application.yaml"
click node_kops_cluster "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/kops/cluster.yaml"
click node_terraform "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/terraform/root/main.tf"
click node_vpc "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/terraform/modules/vpc/main.tf"
click node_remote_state "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/terraform/bootstrap/backend/main.tf"
click node_kyverno "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/kyverno/policies/taskapp-deployment-security.yaml"
click node_monitoring "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/monitoring/kube-prometheus-stack-values.yaml"
click node_servicemonitor "https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/helm/taskapp/templates/servicemonitor.yaml"

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_react_spa,node_api_client,node_backend,node_api_auth,node_models,node_alembic toneBlue
class node_helm_chart,node_ci,node_dockerhub,node_argocd toneAmber
class node_load_balancer,node_postgres,node_kops_cluster,node_terraform,node_vpc,node_remote_state toneMint
class node_kyverno,node_monitoring,node_servicemonitor toneRose
class node_users toneNeutral
```

## Components

### TaskApp

- [Frontend Deployment](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/helm/taskapp/templates/frontend-deployment.yaml): Nginx React workload · Serves the SPA and proxies /api/ to the backend. · `helm/taskapp/templates/frontend-deployment.yaml`
- [React SPA](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/app/taskapp_frontend/src/main.tsx): Vite client · Owns login state, protected routes, and task UI. · `app/taskapp_frontend/src/main.tsx`
- [API Client](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/app/taskapp_frontend/src/services/api.ts): browser API layer · `app/taskapp_frontend/src/services/api.ts`
- [Backend Deployment](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/helm/taskapp/templates/backend-deployment.yaml): Flask workload · Internal ClusterIP API service. · `helm/taskapp/templates/backend-deployment.yaml`
- [REST API & JWT Auth](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/app/taskapp_backend/app/routes.py): Flask routes · Protects task operations and handles API requests. · `app/taskapp_backend/app/routes.py`
- [SQLAlchemy Models](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/app/taskapp_backend/app/models.py): persistence layer · `app/taskapp_backend/app/models.py`
- [Alembic Migrations](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/app/taskapp_backend/migrations/env.py): schema migration · `app/taskapp_backend/migrations/env.py`

### GitOps Delivery

- [TaskApp Helm Chart](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/helm/taskapp/values.yaml): deployment contract · Defines workloads, services, Nginx, and monitoring integration. · `helm/taskapp/values.yaml`
- [GitHub Actions CI](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/.github/workflows/ci.yml): build and publish pipeline · Validates, scans, publishes SHA images, and updates chart tags. · `.github/workflows/ci.yml`
- **Docker Hub**: image registry
- [Argo CD](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/argocd/taskapp-application.yaml): GitOps reconciler · Automatically syncs, corrects drift, and prunes TaskApp resources. · `argocd/taskapp-application.yaml`

### AWS Platform

- [Public TLS Load Balancer](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/helm/taskapp/values.yaml): AWS ingress · `helm/taskapp/values.yaml`
- [RDS PostgreSQL](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/terraform/modules/rds/main.tf): managed database · Private application database. · `terraform/modules/rds/main.tf`
- [kOps Kubernetes Cluster](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/kops/cluster.yaml): AWS Kubernetes runtime · Hosts TaskApp and platform workloads. · `kops/cluster.yaml`
- [Terraform Environment](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/terraform/root/main.tf): infrastructure composition · Composes reusable AWS foundation modules. · `terraform/root/main.tf`
- [Private VPC Networking](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/terraform/modules/vpc/main.tf): network module · `terraform/modules/vpc/main.tf`
- [Terraform Remote State](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/terraform/bootstrap/backend/main.tf): bootstrap storage · Protected state backend bootstrapped separately. · `terraform/bootstrap/backend/main.tf`

### Guardrails

- [Kyverno Policies](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/kyverno/policies/taskapp-deployment-security.yaml): admission control · Requires versioned images and hardened, resource-bounded TaskApp pods. · `kyverno/policies/taskapp-deployment-security.yaml`
- [Prometheus & Grafana](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/monitoring/kube-prometheus-stack-values.yaml): platform observability · `monitoring/kube-prometheus-stack-values.yaml`
- [TaskApp ServiceMonitor](https://github.com/oparag-dev/secure-gitops-k8s-delivery/blob/main/helm/taskapp/templates/servicemonitor.yaml): metrics integration · `helm/taskapp/templates/servicemonitor.yaml`

### Other components

- **Users**: actor

## Connections

- Users → Public TLS Load Balancer: HTTPS
- Public TLS Load Balancer → Frontend Deployment: public service
- Frontend Deployment → React SPA: serves
- React SPA → API Client: task requests
- API Client → Frontend Deployment: /api/
- Frontend Deployment → Backend Deployment: Nginx proxy
- Backend Deployment → REST API & JWT Auth: routes requests
- REST API & JWT Auth → SQLAlchemy Models: persists tasks
- SQLAlchemy Models → RDS PostgreSQL: SQL
- Alembic Migrations → RDS PostgreSQL: evolves schema
- GitHub Actions CI → Docker Hub: publishes SHA images
- GitHub Actions CI → TaskApp Helm Chart: updates image tags
- TaskApp Helm Chart → Argo CD: desired state
- Argo CD → kOps Kubernetes Cluster: reconciles taskapp namespace
- Docker Hub → kOps Kubernetes Cluster: image pulls
- TaskApp Helm Chart → Frontend Deployment: renders workload
- TaskApp Helm Chart → Backend Deployment: renders workload
- Terraform Environment → Private VPC Networking: provisions
- Terraform Environment → RDS PostgreSQL: provisions
- Terraform Remote State → Terraform Environment: stores state
- Private VPC Networking → kOps Kubernetes Cluster: network foundation
- Kyverno Policies → kOps Kubernetes Cluster: admission enforcement
- TaskApp ServiceMonitor → Prometheus & Grafana: scrape target
- TaskApp Helm Chart → TaskApp ServiceMonitor: renders
