# anfal-04/mnist-digit-classifier architecture

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

- Interactive diagram: https://gitdiagram.com/anfal-04/mnist-digit-classifier
- Repository: https://github.com/anfal-04/mnist-digit-classifier

## Overview

This is a Streamlit MNIST digit-classifier app. A user draws on a canvas, the app preprocesses the image and classifies it as “2” or “not a 2,” then displays the prediction and confidence. The app also loads or trains a binary logistic-regression model and presents sample MNIST images. Relationships are limited to those shown in the App.py excerpts; the notebook’s role is not established by the available evidence.

Main entry points: [`App.py`](https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.py) (Streamlit app), [`model.pkl`](https://github.com/anfal-04/mnist-digit-classifier/blob/main/model.pkl) (Saved model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_app["Streamlit app<br/>[App.py]"]
  node_drawing_canvas["Drawing canvas<br/>[App.py]"]
  node_sample_gallery["MNIST sample gallery<br/>[App.py]"]
end

subgraph group_model_data["Model and data"]
  node_mnist_source[("MNIST OpenML")]
  node_model_lifecycle["Model loading and training<br/>[App.py]"]
  node_logistic_model["Logistic regression<br/>[App.py]"]
  node_model_file["Saved model<br/>[model.pkl]"]
end

subgraph group_inference["Prediction and display"]
  node_preprocessing["Canvas preprocessing<br/>[App.py]"]
  node_classification["Binary classification<br/>[App.py]"]
  node_prediction_display["Prediction and confidence<br/>[App.py]"]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"renders"| node_drawing_canvas
node_app -->|"loads or trains"| node_model_lifecycle
node_model_lifecycle -->|"loads or saves"| node_model_file
node_model_lifecycle -->|"fetches data"| node_mnist_source
node_model_lifecycle -->|"fits"| node_logistic_model
node_app -->|"preprocesses drawing"| node_preprocessing
node_preprocessing -->|"provides vector"| node_classification
node_app -->|"predicts"| node_classification
node_classification -->|"supplies prediction"| node_prediction_display
node_app -->|"loads samples"| node_sample_gallery
node_sample_gallery -->|"fetches images"| node_mnist_source

click node_app "https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.py"
click node_drawing_canvas "https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.py"
click node_model_lifecycle "https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.py"
click node_logistic_model "https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.py"
click node_model_file "https://github.com/anfal-04/mnist-digit-classifier/blob/main/model.pkl"
click node_preprocessing "https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.py"
click node_classification "https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.py"
click node_prediction_display "https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.py"
click node_sample_gallery "https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.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_app,node_drawing_canvas,node_sample_gallery,node_user toneBlue
class node_mnist_source,node_model_lifecycle,node_logistic_model,node_model_file toneAmber
class node_preprocessing,node_classification,node_prediction_display toneMint
```

## Components

### User interface

- [Streamlit app](https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.py): `App.py`
- [Drawing canvas](https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.py): `App.py`
- [MNIST sample gallery](https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.py): `App.py`

### Model and data

- **MNIST OpenML**
- [Model loading and training](https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.py): `App.py`
- [Logistic regression](https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.py): `App.py`
- [Saved model](https://github.com/anfal-04/mnist-digit-classifier/blob/main/model.pkl): `model.pkl`

### Prediction and display

- [Canvas preprocessing](https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.py): `App.py`
- [Binary classification](https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.py): `App.py`
- [Prediction and confidence](https://github.com/anfal-04/mnist-digit-classifier/blob/main/App.py): `App.py`

### Other components

- **User**

## Connections

- User → Streamlit app: uses (evidence: `App.py`)
- Streamlit app → Drawing canvas: renders (evidence: `App.py`)
- Streamlit app → Model loading and training: loads or trains (evidence: `App.py`)
- Model loading and training → Saved model: loads or saves (evidence: `App.py`)
- Model loading and training → MNIST OpenML: fetches data (evidence: `App.py`)
- Model loading and training → Logistic regression: fits (evidence: `App.py`)
- Streamlit app → Canvas preprocessing: preprocesses drawing (evidence: `App.py`)
- Canvas preprocessing → Binary classification: provides vector (evidence: `App.py`)
- Streamlit app → Binary classification: predicts (evidence: `App.py`)
- Binary classification → Prediction and confidence: supplies prediction (evidence: `App.py`)
- Streamlit app → MNIST sample gallery: loads samples (evidence: `App.py`)
- MNIST sample gallery → MNIST OpenML: fetches images (evidence: `App.py`)
