# siddheshengineer/gitops architecture

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

- Interactive diagram: https://gitdiagram.com/siddheshengineer/gitops
- Repository: https://github.com/siddheshengineer/gitops

## Overview

##### Project Type and Purpose
- Type: Full-stack GitOps deployment pipeline for a containerized Flask app.
- Purpose: Automate infrastructure & application deployment using GitOps principles; manage both local (k3d) and cloud (AKS via Terraform + Azure Arc) clusters; deliver continuous delivery with FluxCD and CI with GitHub Actions/CircleCI.

##### File Structure
- `.github/workflows/ci.yaml` → CI/CD definitions for building, testing, pushing Docker images, and updating GitOps manifests.
- `app/` → Flask application source, Dockerfile, HTML template (hello.html) + Python requirements.
- `env/arc_and_fluxCD/` → Kubernetes manifests (Namespace, Service, Deployment) for FluxCD to apply.
- `env/terrform/` → Terraform scripts (`aks-k8s-cluster.tf`, `variables.tf`, etc.) to provision an Azure Kubernetes Service cluster.
- `env/cluster-config.yaml` → k3d cluster creation config.
- `images/` → Static screenshots (architecture.png).

##### README for Additional Context
- Confirms use of k3d for local cluster, Azure Arc for cluster registration, FluxCD for pull-based CD, Docker for containerization, GitHub Actions/CircleCI for CI.
- Shows an existing architecture.png illustrating the flow.

##### Main Components
a. Developer Workstation
– Local Git repo → push to remote.
– Executes `k3d cluster create` & `kubectl` for local testing.
b. Git Repository (GitHub)
– Holds `app/`, `env/`, `.github/workflows/ci.yaml`.
– Triggers CI pipelines on push.
c. CI System
– GitHub Actions (or CircleCI)
– Steps: build Docker image → push to container registry (Docker Hub/Azure Container Registry) → update K8s manifests in Git (flux path).
d. Container Registry
– Stores versioned Docker images.
e. Kubernetes Cluster(s)
– Local k3d cluster (dev/test)
– Azure AKS cluster (prod) provisioned via Terraform
– Both clusters registered to Azure Arc
f. GitOps Operator
– FluxCD watches manifest directory in Git → pulls changes → applies to target cluster.
g. Application Components in K8s
– Namespace (e.g., default or custom)
– Deployment (Flask pods)
– Service (ClusterIP/LoadBalancer)
– Ingress / Port-forward for external access
h. IaC Tooling
– Terraform for AKS provisioning
– Azure Arc CLI for connecting clusters

##### Relationships and Data Flow
- Developer → Git push → triggers CI
- CI → builds Docker image → pushes to Registry → commits updated YAML → Git
- FluxCD → detects Git changes → pulls manifests → applies to K8s API
- Kubernetes API → schedules Pods & Services
- Azure Arc → syncs cluster state into Azure Control Plane
- Users → access Flask app via Service/Ingress

##### Key Architectural Patterns and Principles
- GitOps (Pull-based CD with FluxCD)
- Infrastructure-as-Code (Terraform + k3d YAML)
- Containerization (Docker)
- Immutable infrastructure & declarative configs

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Development Side
    subgraph "Development"
        Dev["Developer Workstation<br/>(git CLI, k3d CLI)"]:::code
        Git["GitHub Repo"]:::code
        CI["CI System<br/>(GitHub Actions / CircleCI)"]:::code
    end

    %% Container Registry
    Registry["Container Registry<br/>(Docker Hub / ACR)"]:::container

    %% Infrastructure Provisioning
    subgraph "Infrastructure Provisioning"
        Terraform["Terraform<br/>(AKS Provisioning)"]:::infra
        AzureArc["Azure Arc CLI"]:::infra
    end

    %% FluxCD and Manifests
    subgraph "GitOps Manifests"
        NS["namespace.yaml"]:::gitops
        SVC["service.yaml"]:::gitops
        DEP["deployment.yaml"]:::gitops
    end
    Flux["FluxCD Operator"]:::gitops

    %% Kubernetes Clusters
    subgraph "Kubernetes Clusters"
        k3d["k3d Cluster"]:::cluster
        AKS["AKS Cluster"]:::cluster
    end

    %% End User
    User["End User"]:::external

    %% Connections - Dev Flow
    Dev -->|"push code & manifests"| Git
    Git -->|"triggers CI"| CI
    CI -->|"build & push image"| Registry
    CI -->|"update manifests"| Git

    %% FluxCD Pull and Apply
    NS --> Flux
    SVC --> Flux
    DEP --> Flux
    Flux -.->|"pull changes"| Git
    Flux -->|"apply to"| k3d
    Flux -->|"apply to"| AKS

    %% Provisioning Flow
    Terraform -->|"provision AKS"| AKS
    AzureArc -->|"register cluster"| AKS
    AzureArc -->|"register cluster"| k3d

    %% User Access
    User -->|"access Flask service"| k3d
    User -->|"access Flask service"| AKS

    %% Click Events
    click CI "https://github.com/siddheshengineer/gitops/blob/main/.github/workflows/ci.yaml"
    click Git "https://github.com/siddheshengineer/gitops/blob/main/README.md"
    click NS "https://github.com/siddheshengineer/gitops/blob/main/env/arc_and_fluxCD/namespace.yaml"
    click SVC "https://github.com/siddheshengineer/gitops/blob/main/env/arc_and_fluxCD/service.yaml"
    click DEP "https://github.com/siddheshengineer/gitops/blob/main/env/arc_and_fluxCD/deployment.yaml"
    click Terraform "https://github.com/siddheshengineer/gitops/blob/main/env/terrform/aks-k8s-cluster.tf"
    click k3d "https://github.com/siddheshengineer/gitops/blob/main/env/cluster-config.yaml"

    %% Styles
    classDef code fill:#cce5ff,stroke:#0366d6,color:#0366d6;
    classDef container fill:#ffe5b4,stroke:#cc6600,color:#cc6600;
    classDef infra fill:#f3e6ff,stroke:#6f42c1,color:#6f42c1;
    classDef gitops fill:#e6ffed,stroke:#28a745,color:#28a745;
    classDef cluster fill:#e6ffed,stroke:#28a745,color:#28a745;
    classDef external fill:#eeeeee,stroke:#333333,color:#333333;
```
