# urbanworkteam/infra architecture

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

- Interactive diagram: https://gitdiagram.com/urbanworkteam/infra
- Repository: https://github.com/urbanworkteam/infra

## Overview

Farmily Infrastructure provisions the application’s AWS runtime and also contains a multi-region disaster-recovery system. The primary operational workflow is health-check failure detection, failover orchestration and approval, database fencing and promotion, then verification and retrospective reporting. Terraform modules represent the application platform; the DR Lambda handlers implement distinct control and investigation stages. Several DR connections are documented in handler comments, but the orchestration definition and most Terraform wiring were not excerpted, so unsampled relationships are omitted.

Main entry points: [`Desktop/VPC/environments/dr-brain/stepfunctions.tf`](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/environments/dr-brain/stepfunctions.tf) (Failover Workflow), [`Desktop/VPC/environments/dev/main.tf`](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/environments/dev/main.tf) (Dev Environment), [`Desktop/VPC/environments/prod/main.tf`](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/environments/prod/main.tf) (Prod Environment), [`Desktop/VPC/lambdas/slack_callback/handler.py`](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/slack_callback/handler.py) (Slack Callback)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["AWS Platform"]
  node_dev_env["Dev Environment<br/>[main.tf]"]
  node_prod_env["Prod Environment<br/>[main.tf]"]
  node_vpc["VPC Network<br/>[main.tf]"]
  node_security["Security Groups<br/>[main.tf]"]
  node_monitoring["CloudWatch Alerts<br/>[main.tf]"]
end

subgraph group_runtime["Application Runtime"]
  node_ecs["ECS Fargate<br/>[main.tf]"]
  node_rds[("PostgreSQL RDS<br/>[main.tf]")]
  node_redis[("Redis Cache<br/>[main.tf]")]
  node_s3[("Static File Store<br/>[main.tf]")]
  node_cdn["CloudFront CDN<br/>[main.tf]"]
end

subgraph group_dr_control["DR Control"]
  node_canary["Health Canary<br/>[handler.py]"]
  node_workflow["Failover Workflow<br/>[stepfunctions.tf]"]
end

subgraph group_dr_workers["DR Workers"]
  node_diagnose["Replica Diagnosis<br/>[handler.py]"]
  node_advisor["Failover Advice<br/>[handler.py]"]
  node_fence["Primary Fencing<br/>[handler.py]"]
  node_promote["Replica Promotion<br/>[handler.py]"]
  node_flip["Coordinator Update<br/>[handler.py]"]
  node_verify["DB Verification<br/>[handler.py]"]
  node_audit["Failover Audit<br/>[handler.py]"]
  node_retro["Retrospective Report<br/>[handler.py]"]
end

subgraph group_operations["Operator Tools"]
  node_approval["Slack Approval<br/>[handler.py]"]
  node_callback["Slack Callback<br/>[handler.py]"]
  node_traffic["Traffic Pin Control<br/>[handler.py]"]
  node_unfence["Manual Unfence<br/>[handler.py]"]
end

node_engineer(("Operator"))
node_rds_service[("AWS RDS")]
node_step_service["Step Functions"]
node_slack(("Slack"))
node_ddb[("DynamoDB Coordinator")]
node_sns["SNS Alerts"]
node_bedrock["Bedrock"]
node_s3_service[("AWS S3")]

node_engineer -->|"provisions"| node_dev_env
node_engineer -->|"provisions"| node_prod_env
node_dev_env -->|"configures"| node_vpc
node_dev_env -->|"configures"| node_security
node_dev_env -->|"configures"| node_ecs
node_dev_env -->|"configures"| node_rds
node_dev_env -->|"configures"| node_redis
node_dev_env -->|"configures"| node_s3
node_dev_env -->|"configures"| node_cdn
node_dev_env -->|"configures"| node_monitoring
node_prod_env -->|"configures"| node_vpc
node_prod_env -->|"configures"| node_security
node_prod_env -->|"configures"| node_ecs
node_prod_env -->|"configures"| node_rds
node_prod_env -->|"configures"| node_redis
node_prod_env -->|"configures"| node_s3
node_prod_env -->|"configures"| node_cdn
node_prod_env -->|"configures"| node_monitoring
node_ecs -.->|"uses"| node_rds
node_ecs -.->|"uses"| node_redis
node_cdn -->|"serves"| node_s3
node_monitoring -->|"alerts"| node_sns
node_canary -->|"starts execution"| node_step_service
node_canary -->|"updates health"| node_ddb
node_canary -->|"publishes alert"| node_sns
node_workflow -->|"requests approval"| node_approval
node_approval -->|"posts card"| node_slack
node_slack -->|"sends action"| node_callback
node_callback -->|"resumes task"| node_step_service
node_callback -->|"invokes control"| node_traffic
node_callback -->|"invokes recovery"| node_unfence
node_workflow -.->|"runs diagnosis"| node_diagnose
node_workflow -.->|"requests advice"| node_advisor
node_workflow -.->|"runs fence"| node_fence
node_workflow -.->|"runs promotion"| node_promote
node_workflow -.->|"updates primary"| node_flip
node_workflow -->|"runs baseline"| node_verify
node_workflow -.->|"runs audit"| node_audit
node_workflow -->|"creates report"| node_retro
node_diagnose -->|"reads replica"| node_rds_service
node_advisor -->|"requests analysis"| node_bedrock
node_fence -->|"replaces groups"| node_rds_service
node_fence -->|"records fence"| node_ddb
node_promote -.->|"promotes replica"| node_rds_service
node_flip -->|"updates coordinator"| node_ddb
node_verify -->|"checks database"| node_rds_service
node_audit -->|"invokes checks"| node_verify
node_audit -->|"uses tool loop"| node_bedrock

click node_dev_env "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/environments/dev/main.tf"
click node_prod_env "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/environments/prod/main.tf"
click node_vpc "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/modules/vpc/main.tf"
click node_security "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/modules/sg/main.tf"
click node_ecs "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/modules/ecs/main.tf"
click node_rds "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/modules/rds/main.tf"
click node_redis "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/modules/elasticache/main.tf"
click node_s3 "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/modules/s3/main.tf"
click node_cdn "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/modules/cloudfront/main.tf"
click node_monitoring "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/modules/cloudwatch/main.tf"
click node_canary "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/detect_canary/handler.py"
click node_workflow "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/environments/dr-brain/stepfunctions.tf"
click node_approval "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/slack_notify/handler.py"
click node_callback "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/slack_callback/handler.py"
click node_diagnose "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/diagnose/handler.py"
click node_advisor "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/advisor/handler.py"
click node_fence "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/fence/handler.py"
click node_promote "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/promote/handler.py"
click node_flip "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/flip_coordinator/handler.py"
click node_verify "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/verify/handler.py"
click node_audit "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/audit_agent/handler.py"
click node_retro "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/retrospective/handler.py"
click node_traffic "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/traffic_pin/handler.py"
click node_unfence "https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/unfence/handler.py"

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_dev_env,node_prod_env,node_vpc,node_security,node_monitoring toneBlue
class node_ecs,node_rds,node_redis,node_s3,node_cdn,node_rds_service,node_ddb,node_s3_service toneAmber
class node_canary,node_workflow toneMint
class node_diagnose,node_advisor,node_fence,node_promote,node_flip,node_verify,node_audit,node_retro toneRose
class node_approval,node_callback,node_traffic,node_unfence,node_engineer,node_step_service,node_slack,node_sns,node_bedrock toneIndigo
```

## Components

### AWS Platform

- [Dev Environment](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/environments/dev/main.tf): `Desktop/VPC/environments/dev/main.tf`
- [Prod Environment](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/environments/prod/main.tf): `Desktop/VPC/environments/prod/main.tf`
- [VPC Network](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/modules/vpc/main.tf): `Desktop/VPC/modules/vpc/main.tf`
- [Security Groups](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/modules/sg/main.tf): `Desktop/VPC/modules/sg/main.tf`
- [CloudWatch Alerts](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/modules/cloudwatch/main.tf): `Desktop/VPC/modules/cloudwatch/main.tf`

### Application Runtime

- [ECS Fargate](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/modules/ecs/main.tf): `Desktop/VPC/modules/ecs/main.tf`
- [PostgreSQL RDS](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/modules/rds/main.tf): `Desktop/VPC/modules/rds/main.tf`
- [Redis Cache](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/modules/elasticache/main.tf): `Desktop/VPC/modules/elasticache/main.tf`
- [Static File Store](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/modules/s3/main.tf): `Desktop/VPC/modules/s3/main.tf`
- [CloudFront CDN](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/modules/cloudfront/main.tf): `Desktop/VPC/modules/cloudfront/main.tf`

### DR Control

- [Health Canary](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/detect_canary/handler.py): `Desktop/VPC/lambdas/detect_canary/handler.py`
- [Failover Workflow](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/environments/dr-brain/stepfunctions.tf): `Desktop/VPC/environments/dr-brain/stepfunctions.tf`

### DR Workers

- [Replica Diagnosis](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/diagnose/handler.py): `Desktop/VPC/lambdas/diagnose/handler.py`
- [Failover Advice](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/advisor/handler.py): `Desktop/VPC/lambdas/advisor/handler.py`
- [Primary Fencing](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/fence/handler.py): `Desktop/VPC/lambdas/fence/handler.py`
- [Replica Promotion](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/promote/handler.py): `Desktop/VPC/lambdas/promote/handler.py`
- [Coordinator Update](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/flip_coordinator/handler.py): `Desktop/VPC/lambdas/flip_coordinator/handler.py`
- [DB Verification](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/verify/handler.py): `Desktop/VPC/lambdas/verify/handler.py`
- [Failover Audit](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/audit_agent/handler.py): `Desktop/VPC/lambdas/audit_agent/handler.py`
- [Retrospective Report](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/retrospective/handler.py): `Desktop/VPC/lambdas/retrospective/handler.py`

### Operator Tools

- [Slack Approval](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/slack_notify/handler.py): `Desktop/VPC/lambdas/slack_notify/handler.py`
- [Slack Callback](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/slack_callback/handler.py): `Desktop/VPC/lambdas/slack_callback/handler.py`
- [Traffic Pin Control](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/traffic_pin/handler.py): `Desktop/VPC/lambdas/traffic_pin/handler.py`
- [Manual Unfence](https://github.com/urbanworkteam/infra/blob/main/Desktop/VPC/lambdas/unfence/handler.py): `Desktop/VPC/lambdas/unfence/handler.py`

### Other components

- **Operator**
- **AWS RDS**
- **Step Functions**
- **Slack**
- **DynamoDB Coordinator**
- **SNS Alerts**
- **Bedrock**
- **AWS S3**

## Connections

- Operator → Dev Environment: provisions (evidence: `README.md`)
- Operator → Prod Environment: provisions (evidence: `README.md`)
- Dev Environment → VPC Network: configures (evidence: `README.md`)
- Dev Environment → Security Groups: configures (evidence: `README.md`)
- Dev Environment → ECS Fargate: configures (evidence: `README.md`)
- Dev Environment → PostgreSQL RDS: configures (evidence: `README.md`)
- Dev Environment → Redis Cache: configures (evidence: `README.md`)
- Dev Environment → Static File Store: configures (evidence: `README.md`)
- Dev Environment → CloudFront CDN: configures (evidence: `README.md`)
- Dev Environment → CloudWatch Alerts: configures (evidence: `README.md`)
- Prod Environment → VPC Network: configures (evidence: `README.md`)
- Prod Environment → Security Groups: configures (evidence: `README.md`)
- Prod Environment → ECS Fargate: configures (evidence: `README.md`)
- Prod Environment → PostgreSQL RDS: configures (evidence: `README.md`)
- Prod Environment → Redis Cache: configures (evidence: `README.md`)
- Prod Environment → Static File Store: configures (evidence: `README.md`)
- Prod Environment → CloudFront CDN: configures (evidence: `README.md`)
- Prod Environment → CloudWatch Alerts: configures (evidence: `README.md`)
- ECS Fargate → PostgreSQL RDS: uses
- ECS Fargate → Redis Cache: uses
- CloudFront CDN → Static File Store: serves (evidence: `README.md`)
- CloudWatch Alerts → SNS Alerts: alerts (evidence: `README.md`)
- Health Canary → Step Functions: starts execution (evidence: `Desktop/VPC/lambdas/detect_canary/handler.py`)
- Health Canary → DynamoDB Coordinator: updates health (evidence: `Desktop/VPC/lambdas/detect_canary/handler.py`)
- Health Canary → SNS Alerts: publishes alert (evidence: `Desktop/VPC/lambdas/detect_canary/handler.py`)
- Failover Workflow → Slack Approval: requests approval (evidence: `Desktop/VPC/lambdas/slack_notify/handler.py`)
- Slack Approval → Slack: posts card (evidence: `Desktop/VPC/lambdas/slack_notify/handler.py`)
- Slack → Slack Callback: sends action (evidence: `Desktop/VPC/lambdas/slack_callback/handler.py`)
- Slack Callback → Step Functions: resumes task (evidence: `Desktop/VPC/lambdas/slack_callback/handler.py`)
- Slack Callback → Traffic Pin Control: invokes control (evidence: `Desktop/VPC/lambdas/slack_callback/handler.py`)
- Slack Callback → Manual Unfence: invokes recovery (evidence: `Desktop/VPC/lambdas/slack_callback/handler.py`)
- Failover Workflow → Replica Diagnosis: runs diagnosis
- Failover Workflow → Failover Advice: requests advice
- Failover Workflow → Primary Fencing: runs fence
- Failover Workflow → Replica Promotion: runs promotion
- Failover Workflow → Coordinator Update: updates primary
- Failover Workflow → DB Verification: runs baseline (evidence: `Desktop/VPC/lambdas/verify/handler.py`)
- Failover Workflow → Failover Audit: runs audit
- Failover Workflow → Retrospective Report: creates report (evidence: `Desktop/VPC/lambdas/retrospective/handler.py`)
- Replica Diagnosis → AWS RDS: reads replica (evidence: `Desktop/VPC/lambdas/diagnose/handler.py`)
- Failover Advice → Bedrock: requests analysis (evidence: `Desktop/VPC/lambdas/advisor/handler.py`)
- Primary Fencing → AWS RDS: replaces groups (evidence: `Desktop/VPC/lambdas/fence/handler.py`)
- Primary Fencing → DynamoDB Coordinator: records fence (evidence: `Desktop/VPC/lambdas/fence/handler.py`)
- Replica Promotion → AWS RDS: promotes replica
- Coordinator Update → DynamoDB Coordinator: updates coordinator (evidence: `Desktop/VPC/lambdas/flip_coordinator/handler.py`)
- DB Verification → AWS RDS: checks database (evidence: `Desktop/VPC/lambdas/verify/handler.py`)
- Failover Audit → DB Verification: invokes checks (evidence: `Desktop/VPC/lambdas/audit_agent/handler.py`)
- Failover Audit → Bedrock: uses tool loop (evidence: `Desktop/VPC/lambdas/audit_agent/handler.py`)
