# divsh54321/url-shortener-infra architecture

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

- Interactive diagram: https://gitdiagram.com/divsh54321/url-shortener-infra
- Repository: https://github.com/divsh54321/url-shortener-infra

## Overview

This repository provisions and deploys the URL shortener on AWS: Terraform creates the network, managed data services, app instances, and load balancer; Ansible installs and runs the app container on both instances. The principal request path is Internet → ALB → app servers → Postgres/Redis. The README documents these connections and deployment behavior; most Terraform and Ansible source was not sampled, so the graph reflects documented relationships rather than inspected implementation details. The sampled `encoding.py` is not part of this infrastructure workflow.

Main entry points: [`vpc.tf`](https://github.com/divsh54321/url-shortener-infra/blob/main/vpc.tf) (VPC and subnets), [`app_servers.tf`](https://github.com/divsh54321/url-shortener-infra/blob/main/app_servers.tf) (App servers), [`playbook.yml`](https://github.com/divsh54321/url-shortener-infra/blob/main/playbook.yml) (Ansible playbook), [`security_groups.tf`](https://github.com/divsh54321/url-shortener-infra/blob/main/security_groups.tf) (Security groups)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_network["Network and access"]
  node_vpc["VPC and subnets<br/>[vpc.tf]"]
  node_security["Security groups<br/>[security_groups.tf]"]
  node_provider["AWS provider<br/>[provider.tf]"]
end

subgraph group_data["Persistent services"]
  node_rds[("Postgres RDS<br/>[database.tf]")]
  node_redis[("Redis cache<br/>[database.tf]")]
end

subgraph group_serving["Application serving"]
  node_servers["App servers<br/>[app_servers.tf]"]
  node_alb["Application load balancer<br/>[alb.tf]"]
  node_app["URL shortener container"]
end

subgraph group_deployment["Deployment"]
  node_inventory["Server inventory<br/>[inventory.ini]"]
  node_playbook["Ansible playbook<br/>[playbook.yml]"]
  node_outputs["Terraform outputs<br/>[outputs.tf]"]
end

node_internet(("Internet clients"))
node_operator(("Deployment operator"))

node_internet -->|"sends requests"| node_alb
node_alb -->|"routes traffic"| node_servers
node_servers -->|"uses database"| node_rds
node_servers -->|"uses cache"| node_redis
node_operator -->|"runs deployment"| node_playbook
node_inventory -->|"lists targets"| node_playbook
node_playbook -->|"configures servers"| node_servers
node_playbook -->|"runs container"| node_app
node_app -->|"runs on"| node_servers
node_outputs -->|"provides endpoints"| node_playbook
node_provider -.->|"provisions with AWS"| node_vpc
node_vpc -->|"contains network"| node_security
node_vpc -->|"hosts privately"| node_rds
node_vpc -->|"hosts privately"| node_redis
node_vpc -->|"hosts publicly"| node_servers
node_vpc -->|"hosts publicly"| node_alb
node_security -->|"restricts access"| node_rds
node_security -->|"restricts access"| node_redis

click node_vpc "https://github.com/divsh54321/url-shortener-infra/blob/main/vpc.tf"
click node_security "https://github.com/divsh54321/url-shortener-infra/blob/main/security_groups.tf"
click node_rds "https://github.com/divsh54321/url-shortener-infra/blob/main/database.tf"
click node_redis "https://github.com/divsh54321/url-shortener-infra/blob/main/database.tf"
click node_servers "https://github.com/divsh54321/url-shortener-infra/blob/main/app_servers.tf"
click node_alb "https://github.com/divsh54321/url-shortener-infra/blob/main/alb.tf"
click node_inventory "https://github.com/divsh54321/url-shortener-infra/blob/main/inventory.ini"
click node_playbook "https://github.com/divsh54321/url-shortener-infra/blob/main/playbook.yml"
click node_provider "https://github.com/divsh54321/url-shortener-infra/blob/main/provider.tf"
click node_outputs "https://github.com/divsh54321/url-shortener-infra/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_vpc,node_security,node_provider,node_internet toneBlue
class node_rds,node_redis toneAmber
class node_servers,node_alb,node_app toneMint
class node_inventory,node_playbook,node_outputs toneRose
class node_operator toneIndigo
```

## Components

### Network and access

- [VPC and subnets](https://github.com/divsh54321/url-shortener-infra/blob/main/vpc.tf): `vpc.tf`
- [Security groups](https://github.com/divsh54321/url-shortener-infra/blob/main/security_groups.tf): `security_groups.tf`
- [AWS provider](https://github.com/divsh54321/url-shortener-infra/blob/main/provider.tf): `provider.tf`

### Persistent services

- [Postgres RDS](https://github.com/divsh54321/url-shortener-infra/blob/main/database.tf): `database.tf`
- [Redis cache](https://github.com/divsh54321/url-shortener-infra/blob/main/database.tf): `database.tf`

### Application serving

- [App servers](https://github.com/divsh54321/url-shortener-infra/blob/main/app_servers.tf): `app_servers.tf`
- [Application load balancer](https://github.com/divsh54321/url-shortener-infra/blob/main/alb.tf): `alb.tf`
- **URL shortener container**

### Deployment

- [Server inventory](https://github.com/divsh54321/url-shortener-infra/blob/main/inventory.ini): `inventory.ini`
- [Ansible playbook](https://github.com/divsh54321/url-shortener-infra/blob/main/playbook.yml): `playbook.yml`
- [Terraform outputs](https://github.com/divsh54321/url-shortener-infra/blob/main/outputs.tf): `outputs.tf`

### Other components

- **Internet clients**
- **Deployment operator**

## Connections

- Internet clients → Application load balancer: sends requests (evidence: `README.md`)
- Application load balancer → App servers: routes traffic (evidence: `README.md`)
- App servers → Postgres RDS: uses database (evidence: `README.md`)
- App servers → Redis cache: uses cache (evidence: `README.md`)
- Deployment operator → Ansible playbook: runs deployment (evidence: `README.md`)
- Server inventory → Ansible playbook: lists targets (evidence: `README.md`)
- Ansible playbook → App servers: configures servers (evidence: `README.md`)
- Ansible playbook → URL shortener container: runs container (evidence: `README.md`)
- URL shortener container → App servers: runs on (evidence: `README.md`)
- Terraform outputs → Ansible playbook: provides endpoints (evidence: `README.md`)
- AWS provider → VPC and subnets: provisions with AWS
- VPC and subnets → Security groups: contains network (evidence: `README.md`)
- VPC and subnets → Postgres RDS: hosts privately (evidence: `README.md`)
- VPC and subnets → Redis cache: hosts privately (evidence: `README.md`)
- VPC and subnets → App servers: hosts publicly (evidence: `README.md`)
- VPC and subnets → Application load balancer: hosts publicly (evidence: `README.md`)
- Security groups → Postgres RDS: restricts access (evidence: `README.md`)
- Security groups → Redis cache: restricts access (evidence: `README.md`)
