# 100-hours-a-week/ktb4-10th-infra architecture

> Architecture diagram of the GitHub repository 100-hours-a-week/ktb4-10th-infra, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/100-hours-a-week/ktb4-10th-infra
- Repository: https://github.com/100-hours-a-week/ktb4-10th-infra

## Overview

KGB V2 Infrastructure is a Terraform-managed AWS platform for moving the KGuideBook service from a single-EC2 V1 toward a separate V2 VPC. The documented target workflow is user traffic through CloudFront to frontend storage or the ALB, then ECS backend tasks and private RDS; app-subnet egress uses per-AZ NAT instances. The README also describes IAM/SSM access, monitoring, Redis, AI, and other infrastructure modules. The target architecture includes planned or reused resources: the README says ALB and monitoring are pending, and S3/CloudFront are to be reused. No source excerpts were provided, so relationships below rely on README documentation rather than inspected Terraform calls.

Main entry points: [`prod/main.tf`](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/prod/main.tf) (Production root), [`modules/nat/main.tf`](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/nat/main.tf) (NAT instances), [`modules/backend/main.tf`](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/backend/main.tf) (Backend service), [`prod/cloudfront.tf`](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/prod/cloudfront.tf) (CloudFront)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_environment["Environment roots"]
  node_prod["Production root<br/>[main.tf]"]
end

subgraph group_network["Network and access"]
  node_network_module["VPC networking<br/>[main.tf]"]
  node_security["Security groups<br/>[main.tf]"]
  node_iam["IAM roles<br/>[main.tf]"]
  node_nat["NAT instances<br/>[main.tf]"]
end

subgraph group_compute["Application compute"]
  node_alb["Application load balancer<br/>[main.tf]"]
  node_ecs["ECS cluster hosts<br/>[main.tf]"]
  node_backend["Backend service<br/>[main.tf]"]
end

subgraph group_data["Data and services"]
  node_rds[("RDS MySQL<br/>[main.tf]")]
  node_redis[("Redis<br/>[main.tf]")]
  node_ai["AI infrastructure<br/>[main.tf]"]
end

subgraph group_operations["Operations and delivery"]
  node_cloudfront["CloudFront<br/>[cloudfront.tf]"]
  node_frontend[("Frontend storage<br/>[storage.tf]")]
  node_registry["Container registry<br/>[main.tf]"]
  node_monitoring["Monitoring host<br/>[main.tf]"]
  node_exporters["Metrics exporters<br/>[main.tf]"]
end

node_users(("Users"))
node_internet(("Internet"))
node_runpod["RunPod API"]
node_operator(("Developer"))

node_users -->|"request content"| node_cloudfront
node_cloudfront -->|"serve frontend"| node_frontend
node_cloudfront -->|"forward API"| node_alb
node_alb -->|"route requests"| node_backend
node_backend -->|"access database"| node_rds
node_network_module -->|"route app egress"| node_nat
node_nat -->|"NAT traffic"| node_internet
node_backend -->|"call API"| node_runpod
node_operator -->|"SSM tunnel"| node_nat
node_nat -->|"forward DB port"| node_rds
node_prod -->|"configures"| node_network_module
node_prod -->|"configures"| node_security
node_prod -->|"configures"| node_iam
node_prod -->|"configures"| node_nat
node_prod -->|"configures"| node_ecs
node_prod -->|"configures"| node_backend
node_prod -->|"configures"| node_rds
node_prod -->|"plans"| node_alb
node_prod -->|"plans"| node_monitoring

click node_prod "https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/prod/main.tf"
click node_network_module "https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/network/main.tf"
click node_security "https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/security/main.tf"
click node_iam "https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/iam/main.tf"
click node_nat "https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/nat/main.tf"
click node_cloudfront "https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/prod/cloudfront.tf"
click node_frontend "https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/prod/storage.tf"
click node_alb "https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/alb/main.tf"
click node_ecs "https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/ecs/main.tf"
click node_backend "https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/backend/main.tf"
click node_rds "https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/rds/main.tf"
click node_redis "https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/redis/main.tf"
click node_ai "https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/ai/main.tf"
click node_registry "https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/registry/main.tf"
click node_monitoring "https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/monitoring/main.tf"
click node_exporters "https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/exporters/main.tf"

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_prod,node_users toneBlue
class node_network_module,node_security,node_iam,node_nat toneAmber
class node_alb,node_ecs,node_backend,node_runpod toneMint
class node_rds,node_redis,node_ai toneRose
class node_cloudfront,node_frontend,node_registry,node_monitoring,node_exporters,node_internet,node_operator toneIndigo
```

## Components

### Environment roots

- [Production root](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/prod/main.tf): `prod/main.tf`

### Network and access

- [VPC networking](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/network/main.tf): `modules/network/main.tf`
- [Security groups](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/security/main.tf): `modules/security/main.tf`
- [IAM roles](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/iam/main.tf): `modules/iam/main.tf`
- [NAT instances](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/nat/main.tf): `modules/nat/main.tf`

### Application compute

- [Application load balancer](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/alb/main.tf): `modules/alb/main.tf`
- [ECS cluster hosts](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/ecs/main.tf): `modules/ecs/main.tf`
- [Backend service](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/backend/main.tf): `modules/backend/main.tf`

### Data and services

- [RDS MySQL](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/rds/main.tf): `modules/rds/main.tf`
- [Redis](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/redis/main.tf): `modules/redis/main.tf`
- [AI infrastructure](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/ai/main.tf): `modules/ai/main.tf`

### Operations and delivery

- [CloudFront](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/prod/cloudfront.tf): `prod/cloudfront.tf`
- [Frontend storage](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/prod/storage.tf): `prod/storage.tf`
- [Container registry](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/registry/main.tf): `modules/registry/main.tf`
- [Monitoring host](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/monitoring/main.tf): `modules/monitoring/main.tf`
- [Metrics exporters](https://github.com/100-hours-a-week/ktb4-10th-infra/blob/main/modules/exporters/main.tf): `modules/exporters/main.tf`

### Other components

- **Users**
- **Internet**
- **RunPod API**
- **Developer**

## Connections

- Users → CloudFront: request content (evidence: `README.md`)
- CloudFront → Frontend storage: serve frontend (evidence: `README.md`)
- CloudFront → Application load balancer: forward API (evidence: `README.md`)
- Application load balancer → Backend service: route requests (evidence: `README.md`)
- Backend service → RDS MySQL: access database (evidence: `README.md`)
- VPC networking → NAT instances: route app egress (evidence: `README.md`)
- NAT instances → Internet: NAT traffic (evidence: `README.md`)
- Backend service → RunPod API: call API (evidence: `README.md`)
- Developer → NAT instances: SSM tunnel (evidence: `README.md`)
- NAT instances → RDS MySQL: forward DB port (evidence: `README.md`)
- Production root → VPC networking: configures (evidence: `README.md`)
- Production root → Security groups: configures (evidence: `README.md`)
- Production root → IAM roles: configures (evidence: `README.md`)
- Production root → NAT instances: configures (evidence: `README.md`)
- Production root → ECS cluster hosts: configures (evidence: `README.md`)
- Production root → Backend service: configures (evidence: `README.md`)
- Production root → RDS MySQL: configures (evidence: `README.md`)
- Production root → Application load balancer: plans (evidence: `README.md`)
- Production root → Monitoring host: plans (evidence: `README.md`)
