# amanm13/azure-stack architecture

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

- Interactive diagram: https://gitdiagram.com/amanm13/azure-stack
- Repository: https://github.com/amanm13/azure-stack

## Overview

- Resource Group Module – Acts as the container for all Azure resources and provides a logical grouping.
- Networking Module – Responsible for creating an Azure Virtual Network (VNet) with three subnets. This module lays down the foundation for your three tiers:
- Each subnet represents one tier of your application: the presentation/web tier, application tier, and data tier.
- Security Group Module – Configures network security groups (NSGs) that apply firewall rules and enforce the traffic policies:
- For example, one NSG rule allows public inbound traffic to the web tier while restricting direct inbound access to the database tier.
- Compute Module – Provisions virtual machines, network interfaces, and (if applicable) availability sets:
- One VM is designated for the web tier (exposed to the internet) and another for the application tier (which has controlled traffic from the web tier).
- Database Module – Creates the database server and the associated database:
- Notice the connection design where the application tier can communicate with the database, but not vice versa, matching the security criteria.

##### Flow and Dependencies
- Within the networking section, illustrate that the Virtual Network is divided into three subnets, and clearly indicate how each subnet connects to its respective module:
- The web VM (which accepts inbound traffic from the internet).
- The application VM (which interacts with both the web VM and the database).
- To represent the isolation implied by the security rules (e.g., the database not being accessible directly from the web tier).

##### Architectural Patterns and Principles
- Layered Three-Tier Architecture: Visually separate the presentation layer (web), business logic (application), and data management (database) to reflect the classic three-tier model.
- Infrastructure as Code (IaC): Include a note that these modules are connected via Terraform (using files like main.tf, vars.tf, and terraform.tfvars) that ensures repeatable and predictable deployments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    TOrch["Terraform Orchestrator"]:::orchestrator
    RG["Resource Group Module"]:::module
    Net["Networking Module"]:::module
    Sec["Security Group Module"]:::security
    Comp["Compute Module"]:::compute
    DB["Database Module"]:::database
    TL["Terraform Lifecycle (init,plan,validate,apply)"]:::orchestrator

    %% Top-level orchestration to modules
    TOrch -->|"provisions"| RG
    TOrch -->|"provisions"| Net
    TOrch -->|"provisions"| Sec
    TOrch -->|"provisions"| Comp
    TOrch -->|"provisions"| DB
    TOrch ---|"lifecycle"| TL

    %% Networking Module Details
    subgraph "Networking Details"
        VNet["Azure Virtual Network"]:::networking
        WS["Web Subnet (Presentation Tier)"]:::subnet
        AS["Application Subnet (Application Tier)"]:::subnet
        DS["Database Subnet (Data Tier)"]:::subnet
    end
    Net -->|"creates"| VNet
    VNet -->|"divides_into"| WS
    VNet -->|"divides_into"| AS
    VNet -->|"divides_into"| DS
    VNet -->|"applies_NSG"| Sec

    %% Compute Module Details
    subgraph "Compute Details"
        WVM["Web VM (Internet-Facing)"]:::compute
        APM["Application VM"]:::compute
    end
    Comp -->|"provisions"| WVM
    Comp -->|"provisions"| APM
    WS -->|"hosts"| WVM
    AS -->|"hosts"| APM
    APM -->|"communicates"| DB

    %% Styles
    classDef orchestrator fill:#ffefc6,stroke:#333,stroke-width:2px;
    classDef module fill:#c6e2ff,stroke:#333,stroke-width:2px;
    classDef security fill:#ffcccb,stroke:#333,stroke-width:2px;
    classDef compute fill:#c6ffc6,stroke:#333,stroke-width:2px;
    classDef database fill:#ffffcc,stroke:#333,stroke-width:2px;
    classDef networking fill:#d1f7ff,stroke:#333,stroke-width:2px;
    classDef subnet fill:#e6ffe6,stroke:#333,stroke-width:2px;

    %% Click Events
    click TOrch "https://github.com/amanm13/azure-stack/blob/main/main.tf"
    click RG "https://github.com/amanm13/azure-stack/tree/main/modules/resourcegroup"
    click Net "https://github.com/amanm13/azure-stack/tree/main/modules/networking"
    click Sec "https://github.com/amanm13/azure-stack/tree/main/modules/securitygroup"
    click Comp "https://github.com/amanm13/azure-stack/tree/main/modules/compute"
    click DB "https://github.com/amanm13/azure-stack/tree/main/modules/database"
```
