# harishappana1/aks_python architecture

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

- Interactive diagram: https://gitdiagram.com/harishappana1/aks_python
- Repository: https://github.com/harishappana1/aks_python

## Overview

##### Project type and purpose
- This is a lightweight, containerized Python micro-service intended for local testing on Kubernetes (Minikube).
- Key indicators:
- app.py (the service code)
- Dockerfile (defines a container image)
- deployment.yaml & service.yaml (Kubernetes manifests)
- .github/workflows/build-and-push.yml (CI/CD pipeline)

##### File structure
- Top-level files:
- app.py – the application entry point
- test.py – a test harness for the service
- requirements.txt – Python dependencies
- Dockerfile – container build instructions
- deployment.yaml – Kubernetes Deployment spec
- service.yaml (typoed “serive.yaml”) – Kubernetes Service spec
- .github/workflows/build-and-push.yml – GitHub Actions workflow
- Patterns & infrastructure:
- Container + Kubernetes (minikube)
- CI/CD builds & pushes image

##### README for additional insights
- Workflow:
- Build Docker image locally
- Start Minikube, point Docker CLI at Minikube’s registry
- kubectl apply Deployment + Service
- Expose the app via a NodePort/LoadBalancer
- Uses Azure AD service principal for RBAC in other contexts

a. Main components
- Developer workstation (code + tests)
- GitHub repository + GitHub Actions runner
- Docker Registry (Minikube’s local registry or remote)
- Kubernetes cluster (Minikube VM)
- Kubernetes Master
- Worker node(s) running Pods
- Pod(s) running containerized app.py
- Kubernetes Service object exposing the Pods
- External client (e.g., browser or curl)
- (Optional) Azure AD as an external identity provider for RBAC

b. Relationships & interactions
1. Developer pushes code → GitHub
2. GitHub Actions: build image → push to registry
3. kubectl (or CI) deploys Deployment + Service → Kubernetes API server
4. Scheduler places Pod(s) on worker node(s); Pod downloads image from registry
5. Service routes external traffic to Pod(s) on specified port
6. Client → Service → Pod(s) → app.py handles request → returns response

c. Architectural patterns & design principles
- Twelve-factor app: dependencies declared (requirements.txt), config via environment
- Containerization: isolation and reproducible builds
- Immutable infrastructure: redeploy via Deployment spec
- Declarative infrastructure as code (Kubernetes manifests)
- CI/CD: automated build & deploy

d. Key technologies
- Python + Flask (or similar) in app.py
- Docker
- Kubernetes (Minikube)
- GitHub Actions
- Azure AD (RBAC)

##### Detailed breakdown
1. CI/CD pipeline (GitHub Actions): code → build → push
2. Container Registry: image storage
3. Kubernetes Control Plane: API server, scheduler
4. Worker Node(s): Pod(s) running app container
5. Kubernetes Service: load-balancer or NodePort
6. Client: end-user or test script
7. External identity: Azure AD SP (if RBAC is in scope)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Developer Environment
    subgraph "Developer Environment"
        direction TB
        Developer["Developer Workstation"]:::external
        App["app.py"]:::compute
        Test["test.py"]:::compute
        Req["requirements.txt"]:::compute
        DockerfileNode["Dockerfile"]:::compute
        Readme["readme.md"]:::compute
        DeploymentManifest["deployment.yaml"]:::compute
        ServiceManifest["serive.yaml"]:::compute
    end

    %% CI/CD
    GitHub["GitHub Repository"]:::external
    Actions["GitHub Actions Runner"]:::ci

    %% Container Registry
    Registry[(Docker Registry)]:::registry

    %% Minikube Cluster
    subgraph "Minikube Cluster"
        direction TB
        subgraph "Control Plane"
            APIServer["API Server"]:::infra
            Scheduler["Scheduler"]:::infra
        end
        subgraph "Worker Node"
            Pod["Pod (app container)"]:::compute
        end
        Service["K8s Service"]:::infra
    end

    %% External Systems
    Client["External Client"]:::external
    Azure["Azure AD"]:::external

    %% Connections
    Developer -->|"git push"| GitHub
    GitHub -->|"trigger build"| Actions
    Actions -->|"docker build/push"| Registry
    Actions -->|"read manifest"| DeploymentManifest
    Actions -->|"read manifest"| ServiceManifest
    Actions -->|"kubectl apply"| APIServer
    APIServer -->|"auth request"| Azure
    APIServer -->|"schedule"| Scheduler
    Scheduler -->|"schedule Pod"| Pod
    Pod -->|"pull image"| Registry
    Client -->|"HTTP request"| Service
    Service -->|"routes traffic"| Pod
    Pod -->|"runs app.py"| App
    Developer -->|"run tests"| Test
    Test -->|"executes"| App

    %% Click Events
    click App "https://github.com/harishappana1/aks_python/blob/main/app.py"
    click Req "https://github.com/harishappana1/aks_python/blob/main/requirements.txt"
    click DockerfileNode "https://github.com/harishappana1/aks_python/tree/main/Dockerfile"
    click DeploymentManifest "https://github.com/harishappana1/aks_python/blob/main/deployment.yaml"
    click ServiceManifest "https://github.com/harishappana1/aks_python/blob/main/serive.yaml"
    click Actions "https://github.com/harishappana1/aks_python/blob/main/.github/workflows/build-and-push.yml"
    click Test "https://github.com/harishappana1/aks_python/blob/main/test.py"
    click Readme "https://github.com/harishappana1/aks_python/blob/main/readme.md"

    %% Styles
    classDef compute fill:#a2d5f2,stroke:#333,stroke-width:1px
    classDef registry fill:#f2a2a2,stroke:#333,stroke-width:1px
    classDef external fill:#d5f2a2,stroke:#333,stroke-width:1px
    classDef ci fill:#f2e2a2,stroke:#333,stroke-width:1px
    classDef infra fill:#e2d5f2,stroke:#333,stroke-width:1px
```
