# aiops-02/expense-infra-vm-v1 architecture

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

- Interactive diagram: https://gitdiagram.com/aiops-02/expense-infra-vm-v1
- Repository: https://github.com/aiops-02/expense-infra-vm-v1

## Overview

This repository provisions AWS infrastructure for a three-tier Expense application; it does not contain the application implementation. The main workflow is Terraform apply: establish network and access controls, create MySQL then backend and frontend VMs with tier-specific setup, publish DNS and HTTPS ingress, and wait for VM and end-to-end readiness. The diagram reflects README-documented behavior; no source excerpts were provided, so edges cite the README rather than inferred Terraform internals.

Main entry points: [`ec2.tf`](https://github.com/aiops-02/expense-infra-vm-v1/blob/main/ec2.tf) (Frontend VM), [`dns.tf`](https://github.com/aiops-02/expense-infra-vm-v1/blob/main/dns.tf) (Route53 Records), [`readiness.tf`](https://github.com/aiops-02/expense-infra-vm-v1/blob/main/readiness.tf) (Readiness Checks), [`network.tf`](https://github.com/aiops-02/expense-infra-vm-v1/blob/main/network.tf) (VPC Network)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_foundation["Network and Access"]
  node_network["VPC Network<br/>[network.tf]"]
  node_security["Tier Security Groups<br/>[security.tf]"]
end

subgraph group_tiers["Application Tiers"]
  node_mysql["MySQL VM<br/>[ec2.tf]"]
  node_mysql_setup["MySQL Setup<br/>[mysql.sh.tftpl]"]
  node_backend["Backend VM<br/>[ec2.tf]"]
  node_backend_setup["Backend Setup<br/>[backend.sh.tftpl]"]
  node_frontend["Frontend VM<br/>[ec2.tf]"]
  node_frontend_setup["Frontend Setup<br/>[frontend.sh.tftpl]"]
end

subgraph group_entry["Ingress and DNS"]
  node_dns["Route53 Records<br/>[dns.tf]"]
  node_alb["HTTPS Load Balancer<br/>[alb.tf]"]
end

subgraph group_validation["Readiness and Outputs"]
  node_readiness["Readiness Checks<br/>[readiness.tf]"]
  node_outputs["Stack Outputs<br/>[outputs.tf]"]
end

node_operator(("Terraform Operator"))

node_operator -->|"applies stack"| node_network
node_operator -->|"applies stack"| node_mysql
node_operator -->|"applies stack"| node_backend
node_operator -->|"applies stack"| node_frontend
node_network -->|"hosts VM"| node_mysql
node_network -->|"hosts VM"| node_backend
node_network -->|"hosts VM"| node_frontend
node_security -->|"allows traffic"| node_mysql
node_security -->|"allows traffic"| node_backend
node_security -->|"allows traffic"| node_frontend
node_mysql -->|"runs setup"| node_mysql_setup
node_backend -->|"runs setup"| node_backend_setup
node_frontend -->|"runs setup"| node_frontend_setup
node_backend -->|"uses DB hostname"| node_dns
node_frontend -->|"resolves backend"| node_dns
node_alb -->|"targets instance"| node_frontend
node_operator -->|"publishes HTTPS"| node_alb
node_dns -->|"aliases app name"| node_alb
node_dns -->|"records private IP"| node_mysql
node_dns -->|"records private IP"| node_backend
node_dns -->|"records private IP"| node_frontend
node_readiness -->|"checks setup"| node_mysql
node_readiness -->|"checks setup"| node_backend
node_readiness -->|"checks setup"| node_frontend
node_readiness -->|"probes app URL"| node_alb
node_operator -->|"reads results"| node_outputs

click node_network "https://github.com/aiops-02/expense-infra-vm-v1/blob/main/network.tf"
click node_security "https://github.com/aiops-02/expense-infra-vm-v1/blob/main/security.tf"
click node_mysql "https://github.com/aiops-02/expense-infra-vm-v1/blob/main/ec2.tf"
click node_mysql_setup "https://github.com/aiops-02/expense-infra-vm-v1/blob/main/templates/mysql.sh.tftpl"
click node_backend "https://github.com/aiops-02/expense-infra-vm-v1/blob/main/ec2.tf"
click node_backend_setup "https://github.com/aiops-02/expense-infra-vm-v1/blob/main/templates/backend.sh.tftpl"
click node_frontend "https://github.com/aiops-02/expense-infra-vm-v1/blob/main/ec2.tf"
click node_frontend_setup "https://github.com/aiops-02/expense-infra-vm-v1/blob/main/templates/frontend.sh.tftpl"
click node_dns "https://github.com/aiops-02/expense-infra-vm-v1/blob/main/dns.tf"
click node_alb "https://github.com/aiops-02/expense-infra-vm-v1/blob/main/alb.tf"
click node_readiness "https://github.com/aiops-02/expense-infra-vm-v1/blob/main/readiness.tf"
click node_outputs "https://github.com/aiops-02/expense-infra-vm-v1/blob/main/outputs.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_network,node_security toneBlue
class node_mysql,node_mysql_setup,node_backend,node_backend_setup,node_frontend,node_frontend_setup toneAmber
class node_dns,node_alb toneMint
class node_readiness,node_outputs toneRose
class node_operator toneIndigo
```

## Components

### Network and Access

- [VPC Network](https://github.com/aiops-02/expense-infra-vm-v1/blob/main/network.tf): `network.tf`
- [Tier Security Groups](https://github.com/aiops-02/expense-infra-vm-v1/blob/main/security.tf): `security.tf`

### Application Tiers

- [MySQL VM](https://github.com/aiops-02/expense-infra-vm-v1/blob/main/ec2.tf): `ec2.tf`
- [MySQL Setup](https://github.com/aiops-02/expense-infra-vm-v1/blob/main/templates/mysql.sh.tftpl): `templates/mysql.sh.tftpl`
- [Backend VM](https://github.com/aiops-02/expense-infra-vm-v1/blob/main/ec2.tf): `ec2.tf`
- [Backend Setup](https://github.com/aiops-02/expense-infra-vm-v1/blob/main/templates/backend.sh.tftpl): `templates/backend.sh.tftpl`
- [Frontend VM](https://github.com/aiops-02/expense-infra-vm-v1/blob/main/ec2.tf): `ec2.tf`
- [Frontend Setup](https://github.com/aiops-02/expense-infra-vm-v1/blob/main/templates/frontend.sh.tftpl): `templates/frontend.sh.tftpl`

### Ingress and DNS

- [Route53 Records](https://github.com/aiops-02/expense-infra-vm-v1/blob/main/dns.tf): `dns.tf`
- [HTTPS Load Balancer](https://github.com/aiops-02/expense-infra-vm-v1/blob/main/alb.tf): `alb.tf`

### Readiness and Outputs

- [Readiness Checks](https://github.com/aiops-02/expense-infra-vm-v1/blob/main/readiness.tf): `readiness.tf`
- [Stack Outputs](https://github.com/aiops-02/expense-infra-vm-v1/blob/main/outputs.tf): `outputs.tf`

### Other components

- **Terraform Operator**

## Connections

- Terraform Operator → VPC Network: applies stack (evidence: `README.md`)
- Terraform Operator → MySQL VM: applies stack (evidence: `README.md`)
- Terraform Operator → Backend VM: applies stack (evidence: `README.md`)
- Terraform Operator → Frontend VM: applies stack (evidence: `README.md`)
- VPC Network → MySQL VM: hosts VM (evidence: `README.md`)
- VPC Network → Backend VM: hosts VM (evidence: `README.md`)
- VPC Network → Frontend VM: hosts VM (evidence: `README.md`)
- Tier Security Groups → MySQL VM: allows traffic (evidence: `README.md`)
- Tier Security Groups → Backend VM: allows traffic (evidence: `README.md`)
- Tier Security Groups → Frontend VM: allows traffic (evidence: `README.md`)
- MySQL VM → MySQL Setup: runs setup (evidence: `README.md`)
- Backend VM → Backend Setup: runs setup (evidence: `README.md`)
- Frontend VM → Frontend Setup: runs setup (evidence: `README.md`)
- Backend VM → Route53 Records: uses DB hostname (evidence: `README.md`)
- Frontend VM → Route53 Records: resolves backend (evidence: `README.md`)
- HTTPS Load Balancer → Frontend VM: targets instance (evidence: `README.md`)
- Terraform Operator → HTTPS Load Balancer: publishes HTTPS (evidence: `README.md`)
- Route53 Records → HTTPS Load Balancer: aliases app name (evidence: `README.md`)
- Route53 Records → MySQL VM: records private IP (evidence: `README.md`)
- Route53 Records → Backend VM: records private IP (evidence: `README.md`)
- Route53 Records → Frontend VM: records private IP (evidence: `README.md`)
- Readiness Checks → MySQL VM: checks setup (evidence: `README.md`)
- Readiness Checks → Backend VM: checks setup (evidence: `README.md`)
- Readiness Checks → Frontend VM: checks setup (evidence: `README.md`)
- Readiness Checks → HTTPS Load Balancer: probes app URL (evidence: `README.md`)
- Terraform Operator → Stack Outputs: reads results (evidence: `README.md`)
