# palliplease/flask-digit-recognizer architecture

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

- Interactive diagram: https://gitdiagram.com/palliplease/flask-digit-recognizer
- Repository: https://github.com/palliplease/flask-digit-recognizer

## Overview

This repository is a Flask web app for recognizing handwritten digits. A user uploads an image; the app preprocesses it for a trained LeNet-5 model, predicts a digit, and renders the result. The separate model script downloads MNIST, trains and evaluates the classifier, and saves model files. The README is empty; the map relies on the supplied source and file tree, and does not assume template behavior beyond its use by the routes.

Main entry points: [`app.py`](https://github.com/palliplease/flask-digit-recognizer/blob/master/app.py) (Flask routes), [`model.py`](https://github.com/palliplease/flask-digit-recognizer/blob/master/model.py) (Model training), [`main_pickle_save.pkl`](https://github.com/palliplease/flask-digit-recognizer/blob/master/main_pickle_save.pkl) (Pickled model), [`templates/index.html`](https://github.com/palliplease/flask-digit-recognizer/blob/master/templates/index.html) (Page template)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_routes["Flask routes<br/>[app.py]"]
  node_template["Page template<br/>[index.html]"]
end

subgraph group_inference["Digit inference"]
  node_preprocess["Image preprocessing<br/>[app.py]"]
  node_predict["Digit prediction<br/>[app.py]"]
  node_pickle_model["Pickled model"]
end

subgraph group_training["Model training"]
  node_prepare_data["Data preparation<br/>[model.py]"]
  node_lenet["LeNet-5 definition<br/>[model.py]"]
  node_train["Model training<br/>[model.py]"]
  node_evaluate["Model evaluation<br/>[model.py]"]
  node_h5_model["HDF5 model<br/>[main_save.h5]"]
end

node_user(("User"))
node_mnist[("MNIST dataset")]

node_user -->|"requests page"| node_routes
node_routes -->|"renders page"| node_template
node_user -->|"uploads image"| node_routes
node_routes -->|"calls"| node_preprocess
node_routes -->|"loads"| node_pickle_model
node_routes -->|"calls"| node_predict
node_preprocess -->|"provides image"| node_predict
node_predict -->|"runs inference"| node_pickle_model
node_routes -->|"renders prediction"| node_template
node_mnist -->|"loads dataset"| node_prepare_data
node_prepare_data -->|"provides data"| node_train
node_lenet -->|"builds model"| node_train
node_train -->|"evaluates"| node_evaluate
node_train -->|"saves"| node_h5_model
node_train -->|"serializes"| node_pickle_model

click node_routes "https://github.com/palliplease/flask-digit-recognizer/blob/master/app.py"
click node_template "https://github.com/palliplease/flask-digit-recognizer/blob/master/templates/index.html"
click node_preprocess "https://github.com/palliplease/flask-digit-recognizer/blob/master/app.py"
click node_predict "https://github.com/palliplease/flask-digit-recognizer/blob/master/app.py"
click node_pickle_model "https://github.com/palliplease/flask-digit-recognizer/blob/master/main_pickle_save.pkl"
click node_prepare_data "https://github.com/palliplease/flask-digit-recognizer/blob/master/model.py"
click node_lenet "https://github.com/palliplease/flask-digit-recognizer/blob/master/model.py"
click node_train "https://github.com/palliplease/flask-digit-recognizer/blob/master/model.py"
click node_evaluate "https://github.com/palliplease/flask-digit-recognizer/blob/master/model.py"
click node_h5_model "https://github.com/palliplease/flask-digit-recognizer/blob/master/main_save.h5"

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_routes,node_template,node_user toneBlue
class node_preprocess,node_predict,node_pickle_model,node_mnist toneAmber
class node_prepare_data,node_lenet,node_train,node_evaluate,node_h5_model toneMint
```

## Components

### Web interface

- [Flask routes](https://github.com/palliplease/flask-digit-recognizer/blob/master/app.py): `app.py`
- [Page template](https://github.com/palliplease/flask-digit-recognizer/blob/master/templates/index.html): `templates/index.html`

### Digit inference

- [Image preprocessing](https://github.com/palliplease/flask-digit-recognizer/blob/master/app.py): `app.py`
- [Digit prediction](https://github.com/palliplease/flask-digit-recognizer/blob/master/app.py): `app.py`
- [Pickled model](https://github.com/palliplease/flask-digit-recognizer/blob/master/main_pickle_save.pkl): `main_pickle_save.pkl`

### Model training

- [Data preparation](https://github.com/palliplease/flask-digit-recognizer/blob/master/model.py): `model.py`
- [LeNet-5 definition](https://github.com/palliplease/flask-digit-recognizer/blob/master/model.py): `model.py`
- [Model training](https://github.com/palliplease/flask-digit-recognizer/blob/master/model.py): `model.py`
- [Model evaluation](https://github.com/palliplease/flask-digit-recognizer/blob/master/model.py): `model.py`
- [HDF5 model](https://github.com/palliplease/flask-digit-recognizer/blob/master/main_save.h5): `main_save.h5`

### Other components

- **User**
- **MNIST dataset**

## Connections

- User → Flask routes: requests page
- Flask routes → Page template: renders page
- User → Flask routes: uploads image
- Flask routes → Image preprocessing: calls
- Flask routes → Pickled model: loads
- Flask routes → Digit prediction: calls
- Image preprocessing → Digit prediction: provides image
- Digit prediction → Pickled model: runs inference
- Flask routes → Page template: renders prediction
- MNIST dataset → Data preparation: loads dataset
- Data preparation → Model training: provides data
- LeNet-5 definition → Model training: builds model
- Model training → Model evaluation: evaluates
- Model training → HDF5 model: saves
- Model training → Pickled model: serializes
