# aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment architecture

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

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

## Overview

This repository deploys a CIFAR-10 image-classification application: a user uploads an image through Streamlit, which calls a Flask prediction API that preprocesses the image, invokes the trained CNN, and returns a class and confidence. Kubernetes manifests deploy and expose the frontend and backend. The API and frontend behavior are supported by sampled source; Kubernetes relationships and configuration are described in the README, while manifest internals were not sampled.

Main entry points: [`flask_api.py`](https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/flask_api.py) (Flask prediction API), [`app.py`](https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/app.py) (Classification dashboard), [`pages/1_Image_Prediction.py`](https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/pages/1_Image_Prediction.py) (Prediction page), [`flask-service.yaml`](https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/flask-service.yaml) (Flask service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Streamlit Frontend"]
  node_dashboard["Classification dashboard<br/>[app.py]"]
  node_prediction_page["Prediction page"]
end

subgraph group_inference["Prediction Backend"]
  node_flask_api["Flask prediction API<br/>[flask_api.py]"]
  node_preprocessing["Image preprocessing<br/>[flask_api.py]"]
  node_cnn["CNN inference<br/>[flask_api.py]"]
  node_model["Trained CNN model<br/>[cifar10_cnn.keras]"]
end

subgraph group_kubernetes["Kubernetes Deployment"]
  node_flask_deployment["Flask deployment"]
  node_flask_service["Flask service<br/>[flask-service.yaml]"]
  node_streamlit_deployment["Streamlit deployment"]
  node_streamlit_service["Streamlit service"]
end

node_user(("Image uploader"))

node_user -->|"uploads image"| node_dashboard
node_user -->|"uploads image"| node_prediction_page
node_dashboard -->|"posts image"| node_flask_api
node_prediction_page -->|"posts image"| node_flask_api
node_flask_api -->|"converts image"| node_preprocessing
node_flask_api -->|"predicts with"| node_cnn
node_cnn -->|"loads model"| node_model
node_flask_api -->|"returns JSON"| node_dashboard
node_flask_api -->|"returns JSON"| node_prediction_page
node_flask_deployment -->|"exposes backend"| node_flask_service
node_streamlit_deployment -->|"exposes frontend"| node_streamlit_service
node_streamlit_service -->|"serves interface"| node_user
node_dashboard -->|"calls service"| node_flask_service
node_prediction_page -.->|"calls service"| node_flask_service

click node_dashboard "https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/app.py"
click node_prediction_page "https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/pages/1_Image_Prediction.py"
click node_flask_api "https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/flask_api.py"
click node_preprocessing "https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/flask_api.py"
click node_cnn "https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/flask_api.py"
click node_model "https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/model/cifar10_cnn.keras"
click node_flask_deployment "https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/flask-deployment.yaml"
click node_flask_service "https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/flask-service.yaml"
click node_streamlit_deployment "https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/streamlit-deployment.yaml"
click node_streamlit_service "https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_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_dashboard,node_prediction_page toneBlue
class node_flask_api,node_preprocessing,node_cnn,node_model toneAmber
class node_flask_deployment,node_flask_service,node_streamlit_deployment,node_streamlit_service toneMint
class node_user toneIndigo
```

## Components

### Streamlit Frontend

- [Classification dashboard](https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/app.py): `app.py`
- [Prediction page](https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/pages/1_Image_Prediction.py): `pages/1_Image_Prediction.py`

### Prediction Backend

- [Flask prediction API](https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/flask_api.py): `flask_api.py`
- [Image preprocessing](https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/flask_api.py): `flask_api.py`
- [CNN inference](https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/flask_api.py): `flask_api.py`
- [Trained CNN model](https://github.com/aps31012005-prog/task_12_kubernetes_cluster_setup_and_deployment/blob/main/model/cifar10_cnn.keras): `model/cifar10_cnn.keras`

### Kubernetes Deployment

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

### Other components

- **Image uploader**

## Connections

- Image uploader → Classification dashboard: uploads image (evidence: `app.py`)
- Image uploader → Prediction page: uploads image (evidence: `pages/1_Image_Prediction.py`)
- Classification dashboard → Flask prediction API: posts image (evidence: `app.py`)
- Prediction page → Flask prediction API: posts image (evidence: `pages/1_Image_Prediction.py`)
- Flask prediction API → Image preprocessing: converts image (evidence: `flask_api.py`)
- Flask prediction API → CNN inference: predicts with (evidence: `flask_api.py`)
- CNN inference → Trained CNN model: loads model (evidence: `flask_api.py`)
- Flask prediction API → Classification dashboard: returns JSON (evidence: `app.py`)
- Flask prediction API → Prediction page: returns JSON (evidence: `pages/1_Image_Prediction.py`)
- Flask deployment → Flask service: exposes backend (evidence: `README.md`)
- Streamlit deployment → Streamlit service: exposes frontend (evidence: `README.md`)
- Streamlit service → Image uploader: serves interface (evidence: `README.md`)
- Classification dashboard → Flask service: calls service (evidence: `README.md`)
- Prediction page → Flask service: calls service
