# r-suresh-kumar/udacity-devops-ml-api architecture

> Architecture diagram of the GitHub repository r-suresh-kumar/udacity-devops-ml-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/r-suresh-kumar/udacity-devops-ml-api
- Repository: https://github.com/r-suresh-kumar/udacity-devops-ml-api

## Overview

##### Project type and purpose
- This is a machine-learning microservice API written in Python (Flask) that serves pre-trained `sklearn` housing-price predictions.
- It is fully containerized with Docker, deployed to a local Kubernetes cluster, and continuously tested & built via CircleCI.

##### File structure
- Top-level files & dirs:
- app.py        ← Flask application exposing a /predict endpoint
- model_data/   ← serialized model (`.joblib`) and source CSV
- Dockerfile, run_docker.sh, make_prediction.sh  ← container build & run scripts
- run_kubernetes.sh, upload_docker.sh           ← Kubernetes deploy & CI upload scripts
- .circleci/config.yml                          ← CI pipeline definition
- Makefile & requirements.txt                   ← build, lint, and dependency management
- No external DB—model loaded from local file, logs printed to stdout.

##### README for additional insights
- Confirms Docker + Kubernetes deployment steps
- CI goal: linting, build Docker image, push, deploy to k8s, test inference
- Emphasis on “operationalize production microservices.”

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Development & CI"
        GitHub["GitHub Repo"]:::external
        CI["CircleCI Pipeline"]:::build
        DockerfileNode["Dockerfile"]:::build
        MakefileNode["Makefile"]:::build
        Req["requirements.txt"]:::build
        Readme["README.md"]:::external
        RD["run_docker.sh"]:::build
        MP["make_prediction.sh"]:::build
        UK["upload_docker.sh"]:::build
        RK["run_kubernetes.sh"]:::build
        GitHub --> CI
        CI -->|"uses Dockerfile"| DockerfileNode
        CI -->|"uses Makefile"| MakefileNode
        CI -->|"uses requirements"| Req
        CI -->|"executes"| RD
        CI -->|"executes"| MP
        CI -->|"executes"| UK
        CI -->|"executes"| RK
    end

    CI -->|"push image"| Registry["Docker Hub Registry"]:::external

    subgraph "Kubernetes Cluster"
        direction TB
        K8sMaster["K8s Master"]:::runtime
        K8sWorker["K8s Worker Node"]:::runtime
        Service["K8s Service"]:::runtime
        Pod["Inference Pod"]:::runtime
        App["Flask API (app.py)"]:::runtime
        ModelData["model_data/"]:::runtime
        K8sMaster --> K8sWorker
        K8sWorker --> Pod
        Pod --> App
        Pod --> ModelData
        Service --> Pod
    end

    Registry --> K8sMaster

    Client["Client (curl/script)"]:::external
    Client -->|"HTTP /predict"| Service

    Logs["CI & Runtime Logs"]:::external
    CI --> Logs
    Pod --> Logs

    classDef build fill:#1f77b4,stroke:#333,color:#fff;
    classDef runtime fill:#2ca02c,stroke:#333,color:#fff;
    classDef external fill:#ff7f0e,stroke:#333,color:#fff;

    click App "https://github.com/r-suresh-kumar/udacity-devops-ml-api/blob/master/app.py"
    click ModelData "https://github.com/r-suresh-kumar/udacity-devops-ml-api/tree/master/model_data/"
    click DockerfileNode "https://github.com/r-suresh-kumar/udacity-devops-ml-api/tree/master/Dockerfile"
    click RD "https://github.com/r-suresh-kumar/udacity-devops-ml-api/blob/master/run_docker.sh"
    click MP "https://github.com/r-suresh-kumar/udacity-devops-ml-api/blob/master/make_prediction.sh"
    click RK "https://github.com/r-suresh-kumar/udacity-devops-ml-api/blob/master/run_kubernetes.sh"
    click UK "https://github.com/r-suresh-kumar/udacity-devops-ml-api/blob/master/upload_docker.sh"
    click CI "https://github.com/r-suresh-kumar/udacity-devops-ml-api/blob/master/.circleci/config.yml"
    click MakefileNode "https://github.com/r-suresh-kumar/udacity-devops-ml-api/tree/master/Makefile"
    click Req "https://github.com/r-suresh-kumar/udacity-devops-ml-api/blob/master/requirements.txt"
    click Readme "https://github.com/r-suresh-kumar/udacity-devops-ml-api/blob/master/README.md"
    click Logs "https://github.com/r-suresh-kumar/udacity-devops-ml-api/tree/master/output_txt_files/"
```
