# gustavoeso/projeto_cloud architecture

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

- Interactive diagram: https://gitdiagram.com/gustavoeso/projeto_cloud
- Repository: https://github.com/gustavoeso/projeto_cloud

## Overview

##### Main components
- CloudFormation Template – Represented by the projeto.yaml that orchestrates all AWS resources.
- Application Load Balancer (ALB) – The entry point for client requests.
- VPC and Subnets – The VPC (gustavoVPC) along with its two public subnets (PublicSubnet1 and PublicSubnet2).
- EC2 Instances in an Auto Scaling Group – Shown with a Launch Configuration (AppLaunchConfiguration) and an Auto Scaling Group (AppAutoScalingGroup) that supports scaling (from 1 to 5 instances) and utilizes an IAM Instance Profile.
- S3 Bucket – Used for storing the application code that is downloaded by instances during launch via user data.
- DynamoDB Table – The central database (“Users” table) along with the dedicated VPC Endpoint (DynamoDBVpcEndpoint) for secure, private connectivity.
- IAM Roles/Instance Profile – Represent the S3AccessRole and its attachment via the EC2InstanceProfile.
- Security Groups – For both the EC2 instances and the ALB that regulate incoming and outgoing traffic.
- Load Testing Component – Represent the Locust tool (locustfile.py) used to stress test the deployed environment.

##### Relationships and interactions
- From the EC2 instances, show two interactions:
- One with the S3 Bucket (for downloading and running the application code via user data).
- Another with the DynamoDB Table for data operations. Emphasize that these interactions occur over the VPC network, making use of the DynamoDB VPC Endpoint.
- Optionally, represent load testing (via Locust) as an external client that sends simulated requests to the ALB.

##### Architectural patterns and design principles
- Infrastructure as Code – The complete environment is managed via CloudFormation templates (projeto.yaml).
- Auto Scaling – Indicate the scaling policies (ScaleOutPolicy, ScaleInPolicy) that adjust instance counts based on CPU utilization.
- Security and Permissions – Clearly denote the IAM roles, security groups, and policies that give the necessary permissions to access AWS resources.
- Modular Components – Separate components (ALB, VPC, Auto Scaling Group, DynamoDB, S3, etc.) make the architecture easier to manage and scale.

##### Relevant technologies and frameworks
- AWS Services: EC2, ALB, VPC, DynamoDB, S3, CloudFormation, CloudWatch, IAM.
- Scripts and Automation: The provided bash and PowerShell scripts automate stack creation and deletion.
- Locust for Load Testing: Illustrate that load testing is performed by running locustfile.py to simulate traffic.
- Python Application: The application logic is contained in aplicacao.py, running on EC2 instances.

##### Clarity and detail
- That every major component (including load testing infrastructure and IAM roles) is represented.

## Diagram (Mermaid)

```mermaid
flowchart TD
    CF["CloudFormation: projeto.yaml"]:::cloud
    Clients["Clients (Web Browser)"]:::client
    Locust["Load Tester (Locust)"]:::load
    ALB["AppLoadBalancer"]:::alb
    VPC["gustavoVPC"]:::vpc
    Subnet1["PublicSubnet1"]:::subnet
    Subnet2["PublicSubnet2"]:::subnet
    ASG["AppAutoScalingGroup (EC2 Instances)"]:::ec2
    App["Python Application"]:::app
    SG["Security Groups"]:::sg
    IAM["IAM Roles/Instance Profile"]:::iam
    S3["DeploymentArtifacts (S3 Bucket)"]:::s3
    EP["DynamoDB VPC Endpoint"]:::vpcEndpoint
    DB["Users DynamoDB Table"]:::db
    ASP["AutoScaling Policies"]:::policy

    %% CloudFormation drives the entire architecture
    CF -->|"defines"| ALB
    CF -->|"defines"| VPC
    CF -->|"defines"| S3
    CF -->|"defines"| DB
    CF -->|"defines"| IAM
    CF -->|"defines"| SG

    %% Clients and load tester send requests to the ALB
    Clients -->|"HTTP"| ALB
    Locust -->|"SimulatedTraffic"| ALB

    %% ALB routes traffic into the VPC
    ALB -->|"RoutesTraffic"| VPC

    %% VPC contains public subnets which host the Auto Scaling Group
    VPC --> Subnet1
    VPC --> Subnet2
    Subnet1 -->|"Hosts"| ASG
    Subnet2 -->|"Hosts"| ASG

    %% Auto Scaling Group details
    ASG -->|"Runs"| App
    ASG -->|"Uses"| IAM
    ASG -->|"DownloadsCode"| S3
    ASG -->|"DataOpsVia"| EP
    EP -->|"Access"| DB
    ASG ---|"Scaling"| ASP

    %% Security Groups are associated with ALB and EC2 instances
    ALB --- SG
    ASG --- SG

    %% Styles
    classDef cloud fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef client fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px;
    classDef load fill:#ffccbc,stroke:#d84315,stroke-width:2px;
    classDef alb fill:#ffe082,stroke:#ff6f00,stroke-width:2px;
    classDef vpc fill:#b3e5fc,stroke:#0288d1,stroke-width:2px;
    classDef subnet fill:#e1f5fe,stroke:#01579b,stroke-width:2px;
    classDef ec2 fill:#c5e1a5,stroke:#33691e,stroke-width:2px;
    classDef app fill:#d1c4e9,stroke:#5e35b1,stroke-width:2px;
    classDef s3 fill:#f8bbd0,stroke:#ad1457,stroke-width:2px;
    classDef db fill:#fff9c4,stroke:#f9a825,stroke-width:2px;
    classDef iam fill:#d7ccc8,stroke:#4e342e,stroke-width:2px;
    classDef sg fill:#cfd8dc,stroke:#455a64,stroke-width:2px;
    classDef policy fill:#ffecb3,stroke:#ff6f00,stroke-width:2px;
    classDef vpcEndpoint fill:#f0f4c3,stroke:#afb42b,stroke-width:2px;

    %% Click Events
    click CF "https://github.com/gustavoeso/projeto_cloud/blob/main/projeto.yaml"
    click ALB "https://github.com/gustavoeso/projeto_cloud/blob/main/projeto.yaml"
    click VPC "https://github.com/gustavoeso/projeto_cloud/blob/main/projeto.yaml"
    click ASG "https://github.com/gustavoeso/projeto_cloud/blob/main/projeto.yaml"
    click S3 "https://github.com/gustavoeso/projeto_cloud/blob/main/projeto.yaml"
    click DB "https://github.com/gustavoeso/projeto_cloud/blob/main/projeto.yaml"
    click IAM "https://github.com/gustavoeso/projeto_cloud/blob/main/projeto.yaml"
    click SG "https://github.com/gustavoeso/projeto_cloud/blob/main/projeto.yaml"
    click Locust "https://github.com/gustavoeso/projeto_cloud/blob/main/locustfile.py"
    click App "https://github.com/gustavoeso/projeto_cloud/blob/main/aplicacao.py"
```
