# arun037/three-tier-architecture architecture

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

- Interactive diagram: https://gitdiagram.com/arun037/three-tier-architecture
- Repository: https://github.com/arun037/three-tier-architecture

## Overview

##### Main Components
- VPC: Represents the networking boundary, including public and private subnets, NAT, routing, and connectivity across multiple Availability Zones.
- Load Balancer (ALB): Handles incoming public traffic and directs it to the web tier.
- Auto Scaling Group (ASG): Manages EC2 instances for the frontend (web tier) and backend (application tier).
- Launch Templates: Provide instance configuration for your EC2 instances in the ASG.
- RDS: Represents the database tier responsible for data storage.
- Security Groups (SG): Define firewall policies controlling the traffic between these layers.
- Terraform modules: Create a modular, reusable approach for defining each resource (VPC, Launch Template, LB, ASG, RDS, SG).

##### Relationships and Data Flow
- Backend EC2 instances to the RDS instance in the private subnet, indicating secure, controlled data access.
- Auxiliary lines for modules—showing how each Terraform module (e.g., asg, launchtemplate, lb, rds, sg, vpc) encapsulates parts of the overall architecture.

- FROM the client to the load balancer,
- FROM the load balancer to the ASG (EC2 instance layer),
- FROM the backend EC2 instances to the RDS database.
- Use of modular design provided by Terraform modules. For instance, each directory (asg, launchtemplate, lb, rds, sg, vpc) represents a functional building block, suggesting a clean separation of concerns.
- That the project follows a “three-tier” pattern comprising presentation, application, and data layers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client"]:::client

    subgraph "Terraform Modules"
        subgraph "Network Layer"
            VPC["VPC (Networking)"]:::network
            SG["Security Groups"]:::network
        end
        subgraph "Presentation Layer"
            ALB["Load Balancer (ALB)"]:::network
        end
        subgraph "Application Layer"
            ASG["Auto Scaling Group (ASG)"]:::compute
            LT["Launch Templates"]:::compute
        end
        subgraph "Data Layer"
            RDS["RDS (Database)"]:::database
        end
    end

    %% Data Flow Arrows
    Client -->|"HTTP_Request"| ALB
    ALB -->|"routes_to"| ASG
    LT -->|"configures"| ASG
    ASG -->|"accesses"| RDS

    %% Security Groups relationships (illustrative of access control)
    SG ---|"protects"| ALB
    SG ---|"protects"| ASG
    SG ---|"protects"| RDS

    %% VPC containment (dotted lines indicating network boundaries)
    VPC -.-> ALB
    VPC -.-> ASG
    VPC -.-> RDS

    %% Click Events for Terraform Modules
    click VPC "https://github.com/arun037/three-tier-architecture/tree/main/module/vpc/"
    click ALB "https://github.com/arun037/three-tier-architecture/tree/main/module/lb/"
    click ASG "https://github.com/arun037/three-tier-architecture/tree/main/module/asg/"
    click LT "https://github.com/arun037/three-tier-architecture/tree/main/module/launchtemplate/"
    click RDS "https://github.com/arun037/three-tier-architecture/tree/main/module/rds/"
    click SG "https://github.com/arun037/three-tier-architecture/tree/main/module/sg/"

    %% Styles
    classDef network fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef compute fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef database fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef client fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
```
