# pmahindru/ci-cd-final-project architecture

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

- Interactive diagram: https://gitdiagram.com/pmahindru/ci-cd-final-project
- Repository: https://github.com/pmahindru/ci-cd-final-project

## Overview

##### Project type and purpose
- This is a Python-based microservice template used as a final-project scaffold for a CI/CD course. It provides:
- A simple HTTP API (“service” package, likely using Flask or similar).
- Local setup (bin/setup.sh, virtualenv).
- Automated CI/CD definition (GitHub Actions workflows under .github/workflows, Tekton tasks under .tekton).
- Containerization (Dockerfile).
- Deployment manifest (Procfile for Heroku or similar).

##### File structure
- Top level:
- GitHub metadata: .github/workflows/workflow.yml
- Tekton pipeline definitions: .tekton/tasks.yml
- Dockerfile, Procfile for container build & deployment
- bin/setup.sh for local dev environment
- requirements.txt & setup.cfg for Python dependencies
- service/: application code (routes.py + common helpers)
- tests/: test suite for route handlers
- No database or external data stores are defined—this is purely an API service.

##### README for additional insights
- The README is generic template guidance for students. No internal architecture details, but highlights that CI/CD tasks will be exercised via the supplied workflows/pipelines.

a. Main components
1. Developer & Local Machine
- Local codebase + bin/setup.sh (virtualenv)
- Unit tests (pytest)
2. Source Control / Code Repository
- GitHub repo with branch protection, Pull Requests
3. CI/CD Orchestration
- GitHub Actions (trigger on push/PR, defined in .github/workflows/workflow.yml)
- Tekton Tasks (Kubernetes-based pipeline, defined in .tekton/tasks.yml)
4. Container Build & Registry
- Docker build (Dockerfile) → Container image
- Push to Container Registry (Docker Hub, GitHub Container Registry, etc.)
5. Deployment Platform
- Heroku or other PaaS (Procfile)
- Kubernetes or similar (if using Tekton)
6. Running Service
- Python API service (service/routes.py + common modules)
- Exposed REST endpoints

b. Relationships & interactions
- Developer pushes code to GitHub → GitHub Actions triggers → runs tests → if successful, triggers Tekton pipeline
- Tekton orchestrates build & push of Docker image
- Post-build, the image is deployed to the target environment via Procfile or Kubernetes manifest
- Clients send HTTP requests to the deployed service.

c. Architectural patterns & design principles
- Separation of concerns:
- Source code & tests in separate folders
- CI (GitHub Actions) vs CD (Tekton) responsibilities delineated
- Infrastructure as Code:
- Pipelines defined in YAML under .github and .tekton
- Environment provisioning via Dockerfile / Procfile
- Microservice style: single service component exposing HTTP endpoints.

d. Key technologies
- Python, Flask (or similar) for API
- pytest for testing
- GitHub Actions for CI
- Tekton for CD pipeline
- Docker for containerization
- Heroku/Kubernetes for deployment

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Development Layer
    Dev["Developer / Local Machine"]:::developer
    Setup["Local Setup Script<br/>(bin/setup.sh)"]:::artifact
    Deps["Python Dependencies<br/>(requirements.txt & setup.cfg)"]:::artifact
    Dev --> Setup
    Dev --> Deps
    Dev -->|"push code"| Repo
    Dev -->|"run pytest"| TestSuite

    %% Source Control
    Repo["GitHub Repository"]:::repo

    %% CI/CD Layers
    CI["GitHub Actions (CI)"]:::ci
    Repo -->|trigger on push/PR| CI
    CI -->|"run pytest"| TestSuite
    CI -->|"trigger Tekton"| CD

    CD["Tekton Pipeline (CD)"]:::cd
    CI --> CD

    %% Build & Registry
    DockerBuild["Build Docker Image<br/>(Dockerfile)"]:::artifact
    CD -->|"build image"| DockerBuild
    Registry["Container Registry"]:::registry
    DockerBuild -->|"push to registry"| Registry

    %% Deployment
    Deploy["Deployment Manifest<br/>(Procfile)"]:::deploy
    Registry -->|"deploy image"| Deploy
    Platform["Heroku / Kubernetes"]:::platform
    Deploy --> Platform

    %% Runtime Service
    subgraph "Running Service"
        Service["Python API Service<br/>(service/routes.py)"]:::service
        CommonEH["Error Handlers<br/>(service/common/error_handlers.py)"]:::service
        CommonLH["Log Handlers<br/>(service/common/log_handlers.py)"]:::service
        CommonSt["Status Module<br/>(service/common/status.py)"]:::service
        Service --> CommonEH
        Service --> CommonLH
        Service --> CommonSt
        Platform --> Service
    end

    %% Test Suite
    TestSuite["Test Suite<br/>(tests/test_routes.py)"]:::test
    CI --> TestSuite

    %% Client Traffic
    Client["Client HTTP Requests"]:::client
    Client -->|"REST calls"| Service

    %% Click Events
    click Setup "https://github.com/pmahindru/ci-cd-final-project/blob/main/bin/setup.sh"
    click Deps "https://github.com/pmahindru/ci-cd-final-project/blob/main/requirements.txt"
    click Deps "https://github.com/pmahindru/ci-cd-final-project/blob/main/setup.cfg"
    click Repo "https://github.com/pmahindru/ci-cd-final-project/blob/main/.github/workflows/workflow.yml"
    click CI "https://github.com/pmahindru/ci-cd-final-project/blob/main/.github/workflows/workflow.yml"
    click CD "https://github.com/pmahindru/ci-cd-final-project/blob/main/.tekton/tasks.yml"
    click DockerBuild "https://github.com/pmahindru/ci-cd-final-project/tree/main/Dockerfile"
    click Deploy "https://github.com/pmahindru/ci-cd-final-project/tree/main/Procfile"
    click Service "https://github.com/pmahindru/ci-cd-final-project/blob/main/service/routes.py"
    click CommonEH "https://github.com/pmahindru/ci-cd-final-project/blob/main/service/common/error_handlers.py"
    click CommonLH "https://github.com/pmahindru/ci-cd-final-project/blob/main/service/common/log_handlers.py"
    click CommonSt "https://github.com/pmahindru/ci-cd-final-project/blob/main/service/common/status.py"
    click TestSuite "https://github.com/pmahindru/ci-cd-final-project/blob/main/tests/test_routes.py"

    %% Styles
    classDef developer fill:#CCE5FF,stroke:#000
    classDef repo fill:#CCE5FF,stroke:#000
    classDef artifact fill:#E6F2FF,stroke:#000
    classDef ci fill:#CCFFCC,stroke:#000
    classDef cd fill:#CCFFCC,stroke:#000
    classDef registry fill:#FFE5B4,stroke:#000
    classDef deploy fill:#E5CCFF,stroke:#000
    classDef platform fill:#E5CCFF,stroke:#000
    classDef service fill:#B3E6FF,stroke:#000
    classDef test fill:#FFCCCC,stroke:#000
    classDef client fill:#FFD1DC,stroke:#000
```
