# maahmd/digit_project architecture

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

- Interactive diagram: https://gitdiagram.com/maahmd/digit_project
- Repository: https://github.com/maahmd/digit_project

## Overview

Digit_Project is a Streamlit handwritten-digit recognizer backed by a TensorFlow CNN. The main user workflow is drawing a digit, converting the canvas image to a normalized 28×28 input, running inference, and displaying the predicted digit, confidence, timing, and images. A separate training script loads and preprocesses MNIST, trains and evaluates the CNN, then saves a model file. The tree contains a weights file loaded by the app; the training script’s documented save filename differs, and the excerpts do not show how those artifacts are reconciled.

Main entry points: [`app.py`](https://github.com/maahmd/digit_project/blob/main/app.py) (CNN inference model), [`train_model.py`](https://github.com/maahmd/digit_project/blob/main/train_model.py) (CNN training), [`model_weights.weights.h5`](https://github.com/maahmd/digit_project/blob/main/model_weights.weights.h5) (Model weights)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inference["Digit recognition"]
  node_canvas["Drawing canvas<br/>[app.py]"]
  node_preprocess["Image preprocessing<br/>[app.py]"]
  node_appmodel["CNN inference model<br/>[app.py]"]
  node_weights["Model weights"]
  node_results["Prediction display<br/>[app.py]"]
end

subgraph group_training["Model training"]
  node_mnist[("MNIST dataset")]
  node_trainprep["Training preprocessing<br/>[train_model.py]"]
  node_trainmodel["CNN training<br/>[train_model.py]"]
  node_evaluation["Model evaluation<br/>[train_model.py]"]
  node_savedmodel["Saved model file<br/>[train_model.py]"]
end

node_user(("User"))

node_user -->|"draws digit"| node_canvas
node_canvas -->|"image data"| node_preprocess
node_preprocess -->|"normalized input"| node_appmodel
node_appmodel -->|"loads weights"| node_weights
node_appmodel -->|"prediction scores"| node_results
node_user -->|"views result"| node_results
node_mnist -->|"loads images"| node_trainprep
node_trainprep -->|"prepared data"| node_trainmodel
node_trainmodel -->|"evaluates model"| node_evaluation
node_trainmodel -->|"saves model"| node_savedmodel

click node_canvas "https://github.com/maahmd/digit_project/blob/main/app.py"
click node_preprocess "https://github.com/maahmd/digit_project/blob/main/app.py"
click node_appmodel "https://github.com/maahmd/digit_project/blob/main/app.py"
click node_weights "https://github.com/maahmd/digit_project/blob/main/model_weights.weights.h5"
click node_results "https://github.com/maahmd/digit_project/blob/main/app.py"
click node_trainprep "https://github.com/maahmd/digit_project/blob/main/train_model.py"
click node_trainmodel "https://github.com/maahmd/digit_project/blob/main/train_model.py"
click node_evaluation "https://github.com/maahmd/digit_project/blob/main/train_model.py"
click node_savedmodel "https://github.com/maahmd/digit_project/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_preprocess,node_appmodel,node_weights,node_results,node_user toneBlue
class node_mnist,node_trainprep,node_trainmodel,node_evaluation,node_savedmodel toneAmber
```

## Components

### Digit recognition

- [Drawing canvas](https://github.com/maahmd/digit_project/blob/main/app.py): `app.py`
- [Image preprocessing](https://github.com/maahmd/digit_project/blob/main/app.py): `app.py`
- [CNN inference model](https://github.com/maahmd/digit_project/blob/main/app.py): `app.py`
- [Model weights](https://github.com/maahmd/digit_project/blob/main/model_weights.weights.h5): `model_weights.weights.h5`
- [Prediction display](https://github.com/maahmd/digit_project/blob/main/app.py): `app.py`

### Model training

- **MNIST dataset**
- [Training preprocessing](https://github.com/maahmd/digit_project/blob/main/train_model.py): `train_model.py`
- [CNN training](https://github.com/maahmd/digit_project/blob/main/train_model.py): `train_model.py`
- [Model evaluation](https://github.com/maahmd/digit_project/blob/main/train_model.py): `train_model.py`
- [Saved model file](https://github.com/maahmd/digit_project/blob/main/train_model.py): `train_model.py`

### Other components

- **User**

## Connections

- User → Drawing canvas: draws digit
- Drawing canvas → Image preprocessing: image data
- Image preprocessing → CNN inference model: normalized input
- CNN inference model → Model weights: loads weights
- CNN inference model → Prediction display: prediction scores
- User → Prediction display: views result
- MNIST dataset → Training preprocessing: loads images
- Training preprocessing → CNN training: prepared data
- CNN training → Model evaluation: evaluates model
- CNN training → Saved model file: saves model
