# aps31012005-prog/task_10_docker_flask_api architecture

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

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

## Overview

This repository provides a Flask API for CIFAR-10 image classification, with documented Docker deployment. The main workflow accepts an uploaded image, preprocesses it for the trained model, and returns a class and confidence as JSON; a separate health endpoint reports API availability. The sampled Flask source supports the inference and routing relationships shown. Docker behavior is described in the README, but its build and optimization steps are deployment practices rather than runtime components.

Main entry points: [`flask_api.py`](https://github.com/aps31012005-prog/task_10_docker_flask_api/blob/main/flask_api.py) (Prediction endpoint), [`model/cifar10_cnn.keras`](https://github.com/aps31012005-prog/task_10_docker_flask_api/blob/main/model/cifar10_cnn.keras) (CIFAR-10 model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API"]
  node_flask["Flask application<br/>[flask_api.py]"]
  node_health["Health endpoint<br/>[flask_api.py]"]
  node_predict["Prediction endpoint<br/>[flask_api.py]"]
  node_json["JSON response<br/>[flask_api.py]"]
end

subgraph group_inference["Inference"]
  node_preprocess["Image preprocessing<br/>[flask_api.py]"]
  node_model["CIFAR-10 model<br/>[cifar10_cnn.keras]"]
  node_classes["Class mapping<br/>[flask_api.py]"]
end

subgraph group_deployment["Deployment"]
  node_container["Docker container"]
end

node_user(("API client"))

node_user -->|"sends request"| node_container
node_container -->|"runs"| node_flask
node_flask -->|"dispatches GET"| node_health
node_flask -->|"dispatches POST"| node_predict
node_predict -->|"prepares image"| node_preprocess
node_preprocess -->|"submits batch"| node_model
node_model -->|"returns scores"| node_predict
node_predict -->|"maps index"| node_classes
node_health -->|"returns status"| node_json
node_predict -->|"returns prediction"| node_json
node_json -->|"sends response"| node_user

click node_flask "https://github.com/aps31012005-prog/task_10_docker_flask_api/blob/main/flask_api.py"
click node_health "https://github.com/aps31012005-prog/task_10_docker_flask_api/blob/main/flask_api.py"
click node_predict "https://github.com/aps31012005-prog/task_10_docker_flask_api/blob/main/flask_api.py"
click node_preprocess "https://github.com/aps31012005-prog/task_10_docker_flask_api/blob/main/flask_api.py"
click node_model "https://github.com/aps31012005-prog/task_10_docker_flask_api/blob/main/model/cifar10_cnn.keras"
click node_classes "https://github.com/aps31012005-prog/task_10_docker_flask_api/blob/main/flask_api.py"
click node_json "https://github.com/aps31012005-prog/task_10_docker_flask_api/blob/main/flask_api.py"

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_flask,node_health,node_predict,node_json,node_user toneBlue
class node_preprocess,node_model,node_classes toneAmber
class node_container toneMint
```

## Components

### API

- [Flask application](https://github.com/aps31012005-prog/task_10_docker_flask_api/blob/main/flask_api.py): `flask_api.py`
- [Health endpoint](https://github.com/aps31012005-prog/task_10_docker_flask_api/blob/main/flask_api.py): `flask_api.py`
- [Prediction endpoint](https://github.com/aps31012005-prog/task_10_docker_flask_api/blob/main/flask_api.py): `flask_api.py`
- [JSON response](https://github.com/aps31012005-prog/task_10_docker_flask_api/blob/main/flask_api.py): `flask_api.py`

### Inference

- [Image preprocessing](https://github.com/aps31012005-prog/task_10_docker_flask_api/blob/main/flask_api.py): `flask_api.py`
- [CIFAR-10 model](https://github.com/aps31012005-prog/task_10_docker_flask_api/blob/main/model/cifar10_cnn.keras): `model/cifar10_cnn.keras`
- [Class mapping](https://github.com/aps31012005-prog/task_10_docker_flask_api/blob/main/flask_api.py): `flask_api.py`

### Deployment

- **Docker container**

### Other components

- **API client**

## Connections

- API client → Docker container: sends request
- Docker container → Flask application: runs
- Flask application → Health endpoint: dispatches GET
- Flask application → Prediction endpoint: dispatches POST
- Prediction endpoint → Image preprocessing: prepares image
- Image preprocessing → CIFAR-10 model: submits batch
- CIFAR-10 model → Prediction endpoint: returns scores
- Prediction endpoint → Class mapping: maps index
- Health endpoint → JSON response: returns status
- Prediction endpoint → JSON response: returns prediction
- JSON response → API client: sends response
