# roxsross/workshop-ecs architecture

> Architecture diagram of the GitHub repository roxsross/workshop-ecs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/roxsross/workshop-ecs
- Repository: https://github.com/roxsross/workshop-ecs

## Overview

##### Project type and purpose
- This is a containerized, single-service web application (“Voting APP”) built with Python (Flask), intended to be deployed locally via Docker Compose and in AWS using ECS.
- The README makes it clear the goals are:
- Teach local Docker workflows (compose.yml)
- Teach ECS deployment (docs/ecs.md)

##### File structure
- Top-level files:
- app.py – Flask application entry point
- init_db.py – script to bootstrap or migrate the database
- Dockerfile – builds the Flask app image
- compose.yml – defines local containers (app + database)
- docs/local.md, docs/ecs.md – step-by-step guides for local and ECS deployment
- static/, templates/ – front-end assets and HTML
- No separate “backend” vs. “frontend” repos: the Flask app serves both.
- No explicit Terraform or Kubernetes manifests here (despite badges), but focus is Docker/ECS.

##### README insights
- The app uses AWS ECS (Elastic Container Service) for production
- Local development via docker-compose
- Implied infrastructure: container registry, ECS cluster, Task Definitions, load balancer, database (likely RDS or a managed DB)

##### Main components
a. Client (Web browser)
b. Local Dev Environment (optional view):
- Docker Compose network
- Voting-app container (Flask + static/templates)
- Database container (e.g., PostgreSQL or SQLite)
c. AWS Production Environment:
- AWS Route 53/DNS → Application Load Balancer
- ECS Cluster (Fargate or EC2)
- Task Definition running Voting-app container
- RDS (or other managed database)
- ECR (container registry)
d. External Services & Infrastructure-as-Code (optional):
- AWS CLI/CloudFormation/Terraform for automation

##### Relationships and interactions
- User → ALB → ECS Task (Flask) → RDS
- In local mode: User → docker-compose Flask container → docker-compose DB
- CI/CD (if added later) pushes to ECR, then triggers ECS service update

##### Architectural patterns & design principles
- Container-first, immutable infrastructure
- Monolithic web service (Flask) + backing datastore
- Two deployment targets (local vs. cloud) share the same Dockerfile
- Separation of concerns: application code (app.py & templates) vs. infra definitions (compose.yml, docs)

##### Technologies to call out
- Python/Flask for web service
- Docker & Docker Compose for local containers
- AWS ECS (with ALB) for production orchestration
- RDS or managed DB for persistence
- (Optional) Terraform/CloudFormation for infra provisioning

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Client
    Browser(["Web Browser"]):::client

    %% Local Development Environment
    subgraph "Local Development" 
        direction TB
        ComposeNetwork(["Docker Network"]):::infra
        LocalApp(["Voting-app Container<br/>(Flask)"]):::compute
        LocalDB(["Database Container<br/>(PostgreSQL)"]):::db
        ComposeNetwork --> LocalApp
        ComposeNetwork --> LocalDB
        Browser -->|HTTP| LocalApp
        LocalApp -->|SQL| LocalDB
    end

    %% AWS Production Environment
    subgraph "AWS Production" 
        direction TB
        DNS(["Route 53 / DNS"]):::aws
        ALB(["Application Load Balancer"]):::aws
        ECS(["ECS Cluster"]):::aws
        TaskDef(["ECS Task<br/>Voting-app Container"]):::compute
        RDS(["RDS (Managed DB)"]):::db

        DNS --> ALB
        ALB --> TaskDef
        TaskDef --> RDS
        Browser -->|HTTPS| ALB
    end

    %% Documentation and Files
    subgraph "Project Files & Docs"
        direction TB
        AppFile["app.py"]:::file
        InitDB["init_db.py"]:::file
        DockerfileNode["Dockerfile"]:::file
        ComposeFile["compose.yml"]:::file
        ECSGuide["docs/ecs.md"]:::docs
        LocalGuide["docs/local.md"]:::docs
        StaticDir["static/"]:::file
        TemplatesDir["templates/"]:::file
        Requirements["requirements.txt"]:::file
        Readme["README.md"]:::file

        Readme --> AppFile
        Readme --> ComposeFile
        Readme --> ECSGuide
        Readme --> LocalGuide
    end

    %% Click Events
    click AppFile "https://github.com/roxsross/workshop-ecs/blob/master/app.py"
    click InitDB "https://github.com/roxsross/workshop-ecs/blob/master/init_db.py"
    click DockerfileNode "https://github.com/roxsross/workshop-ecs/tree/master/Dockerfile"
    click ComposeFile "https://github.com/roxsross/workshop-ecs/blob/master/compose.yml"
    click ECSGuide "https://github.com/roxsross/workshop-ecs/blob/master/docs/ecs.md"
    click LocalGuide "https://github.com/roxsross/workshop-ecs/blob/master/docs/local.md"
    click StaticDir "https://github.com/roxsross/workshop-ecs/tree/master/static/"
    click TemplatesDir "https://github.com/roxsross/workshop-ecs/tree/master/templates/"
    click Requirements "https://github.com/roxsross/workshop-ecs/blob/master/requirements.txt"
    click Readme "https://github.com/roxsross/workshop-ecs/blob/master/README.md"

    %% Styles
    classDef compute fill:#D6EAF8,stroke:#1F618D,color:#1B4F72;
    classDef db fill:#FDEBD0,stroke:#D35400,color:#A04000;
    classDef aws fill:#D5F5E3,stroke:#27AE60,color:#1D8348;
    classDef infra fill:#EBDEF0,stroke:#8E44AD,color:#4A235A;
    classDef client fill:#FCF3CF,stroke:#B7950B,color:#7D6608;
    classDef file fill:#F2F3F4,stroke:#566573,color:#2C3E50;
    classDef docs fill:#FEF9E7,stroke:#B9770E,color:#7E5109;
```
