# aps31012005-prog/task_13_kubernetes_deployment architecture

> Architecture diagram of the GitHub repository aps31012005-prog/task_13_kubernetes_deployment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aps31012005-prog/task_13_kubernetes_deployment
- Repository: https://github.com/aps31012005-prog/task_13_kubernetes_deployment

## Overview

This repository combines a Streamlit CIFAR-10 image-classification interface with a Flask prediction API and Kubernetes deployment configuration. The main user workflow is upload an image in Streamlit, send it to Flask, preprocess it for the trained CNN, and display the predicted class and confidence. The README documents separate Kubernetes workloads and services, replica scaling, resource limits, and rolling updates. Source excerpts show the application calls; deployment relationships are based on README documentation, since manifest contents were not sampled.

Main entry points: [`flask_api.py`](https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/flask_api.py) (Flask API), [`streamlit-deployment.yaml`](https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/streamlit-deployment.yaml) (Streamlit Deployment), [`app.py`](https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/app.py) (Dashboard and Upload), [`pages/1_Image_Prediction.py`](https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/pages/1_Image_Prediction.py) (Prediction Page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Streamlit Frontend"]
  node_main_ui["Dashboard and Upload<br/>[app.py]"]
  node_prediction_page["Prediction Page"]
end

subgraph group_inference["Prediction API"]
  node_flask_api["Flask API<br/>[flask_api.py]"]
  node_preprocess["Image Preprocessing<br/>[flask_api.py]"]
  node_cnn["CIFAR-10 CNN<br/>[cifar10_cnn.keras]"]
end

subgraph group_cluster["Kubernetes Workloads"]
  node_flask_workload["Flask Deployment"]
  node_flask_service["Flask Service<br/>[flask-service.yaml]"]
  node_streamlit_workload["Streamlit Deployment"]
  node_streamlit_service["Streamlit Service"]
end

node_user(("Browser User"))
node_kubernetes{{"Kubernetes Cluster"}}

node_user -->|"uses dashboard"| node_main_ui
node_user -->|"uploads image"| node_prediction_page
node_main_ui -->|"checks and predicts"| node_flask_api
node_prediction_page -->|"checks and predicts"| node_flask_api
node_flask_api -->|"preprocesses image"| node_preprocess
node_flask_api -->|"runs inference"| node_cnn
node_flask_api -->|"returns prediction"| node_main_ui
node_flask_api -->|"returns prediction"| node_prediction_page
node_kubernetes -->|"runs workload"| node_flask_workload
node_kubernetes -->|"runs workload"| node_streamlit_workload
node_flask_workload -->|"exposed internally"| node_flask_service
node_streamlit_workload -->|"exposed externally"| node_streamlit_service
node_streamlit_service -->|"serves browser access"| node_user
node_flask_service -.->|"routes API traffic"| node_flask_api
node_streamlit_workload -.->|"calls API internally"| node_flask_service

click node_main_ui "https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/app.py"
click node_prediction_page "https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/pages/1_Image_Prediction.py"
click node_flask_api "https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/flask_api.py"
click node_preprocess "https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/flask_api.py"
click node_cnn "https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/model/cifar10_cnn.keras"
click node_flask_workload "https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/flask-deployment.yaml"
click node_flask_service "https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/flask-service.yaml"
click node_streamlit_workload "https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/streamlit-deployment.yaml"
click node_streamlit_service "https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/streamlit-service.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main_ui,node_prediction_page,node_user toneBlue
class node_flask_api,node_preprocess,node_cnn toneAmber
class node_flask_workload,node_flask_service,node_streamlit_workload,node_streamlit_service toneMint
class node_kubernetes toneIndigo
```

## Components

### Streamlit Frontend

- [Dashboard and Upload](https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/app.py): `app.py`
- [Prediction Page](https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/pages/1_Image_Prediction.py): `pages/1_Image_Prediction.py`

### Prediction API

- [Flask API](https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/flask_api.py): `flask_api.py`
- [Image Preprocessing](https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/flask_api.py): `flask_api.py`
- [CIFAR-10 CNN](https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/model/cifar10_cnn.keras): `model/cifar10_cnn.keras`

### Kubernetes Workloads

- [Flask Deployment](https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/flask-deployment.yaml): `flask-deployment.yaml`
- [Flask Service](https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/flask-service.yaml): `flask-service.yaml`
- [Streamlit Deployment](https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/streamlit-deployment.yaml): `streamlit-deployment.yaml`
- [Streamlit Service](https://github.com/aps31012005-prog/task_13_kubernetes_deployment/blob/main/streamlit-service.yaml): `streamlit-service.yaml`

### Other components

- **Browser User**
- **Kubernetes Cluster**

## Connections

- Browser User → Dashboard and Upload: uses dashboard (evidence: `README.md`)
- Browser User → Prediction Page: uploads image (evidence: `pages/1_Image_Prediction.py`)
- Dashboard and Upload → Flask API: checks and predicts (evidence: `app.py`)
- Prediction Page → Flask API: checks and predicts (evidence: `pages/1_Image_Prediction.py`)
- Flask API → Image Preprocessing: preprocesses image (evidence: `flask_api.py`)
- Flask API → CIFAR-10 CNN: runs inference (evidence: `flask_api.py`)
- Flask API → Dashboard and Upload: returns prediction (evidence: `app.py`)
- Flask API → Prediction Page: returns prediction (evidence: `pages/1_Image_Prediction.py`)
- Kubernetes Cluster → Flask Deployment: runs workload (evidence: `README.md`)
- Kubernetes Cluster → Streamlit Deployment: runs workload (evidence: `README.md`)
- Flask Deployment → Flask Service: exposed internally (evidence: `README.md`)
- Streamlit Deployment → Streamlit Service: exposed externally (evidence: `README.md`)
- Streamlit Service → Browser User: serves browser access (evidence: `README.md`)
- Flask Service → Flask API: routes API traffic (evidence: `README.md`)
- Streamlit Deployment → Flask Service: calls API internally (evidence: `README.md`)
