# gaiusparasa10-hash/mnist architecture

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

- Interactive diagram: https://gitdiagram.com/gaiusparasa10-hash/mnist
- Repository: https://github.com/gaiusparasa10-hash/mnist

## Overview

This repository is a Streamlit application for handwritten-digit recognition, backed by a trained MNIST CNN. The user draws a digit, requests prediction, and receives a digit and confidence score; Clear resets the canvas and displayed result. The app preprocesses the captured image before inference. A separate training script loads MNIST, trains and evaluates the CNN, and saves the model artifact used by the app. Edges are supported by the sampled app and training script, or by the README for documented behavior.

Main entry points: [`streamlit_app.py`](https://github.com/gaiusparasa10-hash/mnist/blob/main/streamlit_app.py) (Predict and Clear), [`train_model.py`](https://github.com/gaiusparasa10-hash/mnist/blob/main/train_model.py) (Training Workflow), [`model.keras`](https://github.com/gaiusparasa10-hash/mnist/blob/main/model.keras) (Trained Model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Drawing and Results"]
  node_canvas["Drawing Canvas<br/>[streamlit_app.py]"]
  node_controls["Predict and Clear<br/>[streamlit_app.py]"]
  node_results["Prediction Display<br/>[streamlit_app.py]"]
end

subgraph group_inference["Prediction Runtime"]
  node_preprocess["Image Preprocessing<br/>[streamlit_app.py]"]
  node_model_loader["Model Loader<br/>[streamlit_app.py]"]
  node_cnn["CNN Inference<br/>[streamlit_app.py]"]
  node_model_artifact["Trained Model<br/>[model.keras]"]
end

subgraph group_training["Model Training"]
  node_training_script["Training Workflow<br/>[train_model.py]"]
  node_mnist["MNIST Dataset"]
  node_training_preprocess["Training Data Prep<br/>[train_model.py]"]
  node_cnn_training["CNN Training<br/>[train_model.py]"]
  node_evaluation["Model Evaluation<br/>[train_model.py]"]
end

node_user(("User"))

node_user -->|"draws on"| node_canvas
node_canvas -->|"provides image"| node_controls
node_user -->|"requests prediction"| node_controls
node_controls -->|"invokes"| node_preprocess
node_preprocess -->|"provides tensor"| node_cnn
node_model_loader -->|"loads"| node_model_artifact
node_cnn -->|"uses loaded model"| node_model_loader
node_cnn -->|"stores prediction"| node_results
node_user -->|"clears canvas"| node_controls
node_training_script -->|"loads dataset"| node_mnist
node_training_script -->|"prepares data"| node_training_preprocess
node_training_preprocess -->|"provides training data"| node_cnn_training
node_cnn_training -->|"evaluates model"| node_evaluation
node_training_script -->|"saves model"| node_model_artifact

click node_canvas "https://github.com/gaiusparasa10-hash/mnist/blob/main/streamlit_app.py"
click node_controls "https://github.com/gaiusparasa10-hash/mnist/blob/main/streamlit_app.py"
click node_results "https://github.com/gaiusparasa10-hash/mnist/blob/main/streamlit_app.py"
click node_preprocess "https://github.com/gaiusparasa10-hash/mnist/blob/main/streamlit_app.py"
click node_model_loader "https://github.com/gaiusparasa10-hash/mnist/blob/main/streamlit_app.py"
click node_cnn "https://github.com/gaiusparasa10-hash/mnist/blob/main/streamlit_app.py"
click node_model_artifact "https://github.com/gaiusparasa10-hash/mnist/blob/main/model.keras"
click node_training_script "https://github.com/gaiusparasa10-hash/mnist/blob/main/train_model.py"
click node_training_preprocess "https://github.com/gaiusparasa10-hash/mnist/blob/main/train_model.py"
click node_cnn_training "https://github.com/gaiusparasa10-hash/mnist/blob/main/train_model.py"
click node_evaluation "https://github.com/gaiusparasa10-hash/mnist/blob/main/train_model.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_canvas,node_controls,node_results,node_user toneBlue
class node_preprocess,node_model_loader,node_cnn,node_model_artifact toneAmber
class node_training_script,node_mnist,node_training_preprocess,node_cnn_training,node_evaluation toneMint
```

## Components

### Drawing and Results

- [Drawing Canvas](https://github.com/gaiusparasa10-hash/mnist/blob/main/streamlit_app.py): `streamlit_app.py`
- [Predict and Clear](https://github.com/gaiusparasa10-hash/mnist/blob/main/streamlit_app.py): `streamlit_app.py`
- [Prediction Display](https://github.com/gaiusparasa10-hash/mnist/blob/main/streamlit_app.py): `streamlit_app.py`

### Prediction Runtime

- [Image Preprocessing](https://github.com/gaiusparasa10-hash/mnist/blob/main/streamlit_app.py): `streamlit_app.py`
- [Model Loader](https://github.com/gaiusparasa10-hash/mnist/blob/main/streamlit_app.py): `streamlit_app.py`
- [CNN Inference](https://github.com/gaiusparasa10-hash/mnist/blob/main/streamlit_app.py): `streamlit_app.py`
- [Trained Model](https://github.com/gaiusparasa10-hash/mnist/blob/main/model.keras): `model.keras`

### Model Training

- [Training Workflow](https://github.com/gaiusparasa10-hash/mnist/blob/main/train_model.py): `train_model.py`
- **MNIST Dataset**
- [Training Data Prep](https://github.com/gaiusparasa10-hash/mnist/blob/main/train_model.py): `train_model.py`
- [CNN Training](https://github.com/gaiusparasa10-hash/mnist/blob/main/train_model.py): `train_model.py`
- [Model Evaluation](https://github.com/gaiusparasa10-hash/mnist/blob/main/train_model.py): `train_model.py`

### Other components

- **User**

## Connections

- User → Drawing Canvas: draws on (evidence: `README.md`)
- Drawing Canvas → Predict and Clear: provides image (evidence: `streamlit_app.py`)
- User → Predict and Clear: requests prediction (evidence: `README.md`)
- Predict and Clear → Image Preprocessing: invokes (evidence: `streamlit_app.py`)
- Image Preprocessing → CNN Inference: provides tensor (evidence: `streamlit_app.py`)
- Model Loader → Trained Model: loads (evidence: `streamlit_app.py`)
- CNN Inference → Model Loader: uses loaded model (evidence: `streamlit_app.py`)
- CNN Inference → Prediction Display: stores prediction (evidence: `streamlit_app.py`)
- User → Predict and Clear: clears canvas (evidence: `streamlit_app.py`)
- Training Workflow → MNIST Dataset: loads dataset (evidence: `train_model.py`)
- Training Workflow → Training Data Prep: prepares data (evidence: `train_model.py`)
- Training Data Prep → CNN Training: provides training data (evidence: `train_model.py`)
- CNN Training → Model Evaluation: evaluates model (evidence: `train_model.py`)
- Training Workflow → Trained Model: saves model (evidence: `train_model.py`)
