# theangrytech-git/chaosstudiolab architecture

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

- Interactive diagram: https://gitdiagram.com/theangrytech-git/chaosstudiolab
- Repository: https://github.com/theangrytech-git/chaosstudiolab

## Overview

##### Project type and purpose
- This is an Infrastructure-as-Code (IaC) deployment project for Azure Chaos Studio experiments.
- It uses Terraform to define and provision resources in “UK South” (with optional “UK West” failover), plus scripts and pipelines to run chaos experiments and health checks.

##### File structure
- Top-level IaC files: provider.tf, main.tf, variables.tf, output.tf, env.tfvars, terraform.lock.hcl
- CI/CD definitions:
- .github/workflows/main.yml
- .github/workflows/msdevsecops.yml
- azure-pipelines.yml
- Auxiliary scripts and assets:
- healthcheck.py + healthcheckpage.html
- assets/HLD.png
- Miscellaneous: secret password file (should be removed or secured)

##### Extract key insights from the README
- Purpose: Deploy a small lab, create three real-world Playbook-in-Run (PIR) experiments and smaller failure scenarios.
- Audience: Engineers learning Chaos Studio and Azure Well-Architected pillars.
- There is already a high-level design graphic in assets/HLD.png – use it as a starting point.

##### Main components
- Source Code Management (GitHub repo)
- CI/CD systems (GitHub Actions, Azure Pipelines)
- Terraform engine (local or remote backend)
- Azure Resource Manager (ARM) / Subscription boundary
- Deployed Azure services:
- Virtual Machines or VM Scale Sets
- Resource Groups
- Azure Chaos Studio (experiments, targets)
- Networking components (VNet, subnets)
- Monitoring/health-check stack:
- healthcheck.py + healthcheckpage.html hosted somewhere (VM or Web App)
- Optional failover region (UK West)

##### Relationships and interactions
- Developers push code → triggers GitHub Actions or Azure Pipelines
- CI/CD system executes Terraform plan/apply using provider.tf and env.tfvars
- Terraform communicates with ARM to provision resource groups, VMs, Chaos Studio experiments
- After deployment, healthcheck.py runs against deployed resources and serves healthcheckpage.html
- Users can invoke Chaos Studio experiments against the deployed targets

##### Architectural patterns and design principles
- Declarative IaC (Terraform)
- GitOps-style pipeline (code-driven deployments)
- Separation of concerns:
- Pipeline code vs. infrastructure code vs. runtime artifacts (scripts)
- Resiliency through multi-region (UK South primary, UK West failover)
- Well-Architected Framework pillars: Reliability (chaos experiments), Operational Excellence (automated pipelines), Performance Efficiency (region failover), etc.

##### Technology and framework highlights
- Terraform (HCL files, .terraform lock)
- GitHub Actions (.github/workflows)
- Azure DevOps Pipelines (azure-pipelines.yml)
- Python (healthcheck.py)
- Azure Chaos Studio
- Azure CLI / ARM under the hood

##### Final recommendations
- Reference the existing HLD.png in assets as a styling guide.
- Iterate with your team to ensure no resource type or script is omitted.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD Zone
    subgraph "CI/CD Zone"
        Repo["GitHub Repository"]:::code
        GHActions["GitHub Actions"]:::code
        AzurePipelines["Azure Pipelines"]:::code
    end

    Repo -->|"git push"| GHActions
    Repo -->|"git push"| AzurePipelines
    GHActions -->|"runs Terraform"| Terraform
    AzurePipelines -->|"runs Terraform"| Terraform

    %% IaC Zone
    subgraph "IaC Zone"
        Terraform["Terraform Engine"]:::iac
        ProviderTF["provider.tf"]:::iac
        MainTF["main.tf"]:::iac
        VarsTF["variables.tf"]:::iac
        OutputTF["output.tf"]:::iac
        EnvTF["env.tfvars"]:::iac
        LockTF[".terraform.lock.hcl"]:::iac
    end

    Terraform --> ProviderTF
    Terraform --> MainTF
    Terraform --> VarsTF
    Terraform --> OutputTF
    Terraform --> EnvTF
    Terraform --> LockTF
    Terraform -->|"provision resources"| ARM

    %% Azure Cloud Boundary
    subgraph "Azure Cloud"
        style AzureCloud fill:#FFE5B4,stroke:#F08000
        ARM["Azure ARM"]:::azure

        subgraph "Subscription"
            RG["Resource Groups"]:::azure

            subgraph "Primary Region (UK South)"
                Network["VNet & Subnets"]:::azure
                VMs["VMs/VMSS"]:::azure
                Chaos["Azure Chaos Studio"]:::chaos
                Health["Health-Check Service"]:::health
                Page["healthcheckpage.html"]:::health
            end

            subgraph "Failover Region (UK West)"
                NetworkFail["VNet & Subnets"]:::azure
                VMsFail["VMs/VMSS"]:::azure
                ChaosFail["Azure Chaos Studio"]:::chaos
            end
        end
    end

    ARM --> RG
    RG --> Network
    RG --> NetworkFail
    Network --> VMs
    NetworkFail --> VMsFail
    VMs --> Health
    VMs --> Page
    VMsFail --> Health
    VMsFail --> Page
    VMs --> Chaos
    VMsFail --> ChaosFail
    Chaos -->|"run experiments"| VMs
    ChaosFail -->|"run experiments"| VMsFail

    %% Click Events
    click Repo "https://github.com/theangrytech-git/chaosstudiolab/tree/main//"
    click GHActions "https://github.com/theangrytech-git/chaosstudiolab/tree/main/.github/workflows"
    click AzurePipelines "https://github.com/theangrytech-git/chaosstudiolab/blob/main/azure-pipelines.yml"
    click ProviderTF "https://github.com/theangrytech-git/chaosstudiolab/blob/main/provider.tf"
    click MainTF "https://github.com/theangrytech-git/chaosstudiolab/blob/main/main.tf"
    click VarsTF "https://github.com/theangrytech-git/chaosstudiolab/blob/main/variables.tf"
    click OutputTF "https://github.com/theangrytech-git/chaosstudiolab/blob/main/output.tf"
    click EnvTF "https://github.com/theangrytech-git/chaosstudiolab/blob/main/env.tfvars"
    click LockTF "https://github.com/theangrytech-git/chaosstudiolab/blob/main/.terraform.lock.hcl"
    click Health "https://github.com/theangrytech-git/chaosstudiolab/blob/main/healthcheck.py"
    click Page "https://github.com/theangrytech-git/chaosstudiolab/blob/main/healthcheckpage.html"

    %% Styles
    classDef code fill:#CFE2F3,stroke:#084C61
    classDef iac fill:#D6EFD6,stroke:#2E7D32
    classDef azure fill:#E3F2FD,stroke:#1565C0
    classDef chaos fill:#F3E5F5,stroke:#6A1B9A
    classDef health fill:#FFF9C4,stroke:#F9A825
```
