# dineshkumarj45/hdr architecture

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

- Interactive diagram: https://gitdiagram.com/dineshkumarj45/hdr
- Repository: https://github.com/dineshkumarj45/hdr

## Overview

HDR is a handwritten-digit recognition app: users draw a digit in the web interface, submit it for preprocessing and CNN/SVM inference, and receive both model scores plus a confidence-based final choice. A separate training script builds the CNN and SVM from MNIST and saves model artifacts that the Flask app loads at startup. The README documents the interactive web workflow; index.html is listed in the tree but was not sampled, so its implementation details are not shown.

Main entry points: [`app.py`](https://github.com/dineshkumarj45/hdr/blob/main/app.py) (Flask app), [`index.html`](https://github.com/dineshkumarj45/hdr/blob/main/index.html) (Drawing interface), [`train_model.py`](https://github.com/dineshkumarj45/hdr/blob/main/train_model.py) (CNN training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_web_ui["Drawing interface<br/>[index.html]"]
end

subgraph group_inference["Prediction service"]
  node_flask_app["Flask app<br/>[app.py]"]
  node_preprocessing["Image preprocessing<br/>[app.py]"]
  node_cnn_inference["CNN inference<br/>[app.py]"]
  node_svm_inference["SVM inference<br/>[app.py]"]
  node_decision["Confidence comparison<br/>[app.py]"]
end

subgraph group_training["Model training"]
  node_cnn_training["CNN training<br/>[train_model.py]"]
  node_svm_training["SVM training<br/>[train_model.py]"]
end

node_user(("Digit drawer"))
node_mnist[("MNIST dataset")]
node_cnn_artifact["CNN model file"]
node_svm_artifact["SVM model file"]

node_user -->|"draws"| node_web_ui
node_web_ui -->|"submits digit"| node_flask_app
node_flask_app -->|"returns prediction"| node_web_ui
node_flask_app -->|"preprocesses"| node_preprocessing
node_flask_app -->|"predicts with"| node_cnn_inference
node_flask_app -->|"predicts with"| node_svm_inference
node_flask_app -->|"compares scores"| node_decision
node_mnist -->|"trains on"| node_cnn_training
node_mnist -->|"trains on"| node_svm_training
node_cnn_training -->|"saves"| node_cnn_artifact
node_svm_training -->|"saves"| node_svm_artifact
node_flask_app -->|"loads"| node_cnn_artifact
node_flask_app -->|"loads"| node_svm_artifact

click node_web_ui "https://github.com/dineshkumarj45/hdr/blob/main/index.html"
click node_flask_app "https://github.com/dineshkumarj45/hdr/blob/main/app.py"
click node_preprocessing "https://github.com/dineshkumarj45/hdr/blob/main/app.py"
click node_cnn_inference "https://github.com/dineshkumarj45/hdr/blob/main/app.py"
click node_svm_inference "https://github.com/dineshkumarj45/hdr/blob/main/app.py"
click node_decision "https://github.com/dineshkumarj45/hdr/blob/main/app.py"
click node_cnn_training "https://github.com/dineshkumarj45/hdr/blob/main/train_model.py"
click node_svm_training "https://github.com/dineshkumarj45/hdr/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_web_ui toneBlue
class node_flask_app,node_preprocessing,node_cnn_inference,node_svm_inference,node_decision,node_mnist toneAmber
class node_cnn_training,node_svm_training toneMint
class node_user,node_cnn_artifact,node_svm_artifact toneIndigo
```

## Components

### User interface

- [Drawing interface](https://github.com/dineshkumarj45/hdr/blob/main/index.html): `index.html`

### Prediction service

- [Flask app](https://github.com/dineshkumarj45/hdr/blob/main/app.py): `app.py`
- [Image preprocessing](https://github.com/dineshkumarj45/hdr/blob/main/app.py): `app.py`
- [CNN inference](https://github.com/dineshkumarj45/hdr/blob/main/app.py): `app.py`
- [SVM inference](https://github.com/dineshkumarj45/hdr/blob/main/app.py): `app.py`
- [Confidence comparison](https://github.com/dineshkumarj45/hdr/blob/main/app.py): `app.py`

### Model training

- [CNN training](https://github.com/dineshkumarj45/hdr/blob/main/train_model.py): `train_model.py`
- [SVM training](https://github.com/dineshkumarj45/hdr/blob/main/train_model.py): `train_model.py`

### Other components

- **Digit drawer**
- **MNIST dataset**
- **CNN model file**
- **SVM model file**

## Connections

- Digit drawer → Drawing interface: draws (evidence: `README.md`)
- Drawing interface → Flask app: submits digit (evidence: `README.md`)
- Flask app → Drawing interface: returns prediction (evidence: `README.md`)
- Flask app → Image preprocessing: preprocesses (evidence: `app.py`)
- Flask app → CNN inference: predicts with (evidence: `app.py`)
- Flask app → SVM inference: predicts with (evidence: `app.py`)
- Flask app → Confidence comparison: compares scores (evidence: `app.py`)
- MNIST dataset → CNN training: trains on (evidence: `train_model.py`)
- MNIST dataset → SVM training: trains on (evidence: `train_model.py`)
- CNN training → CNN model file: saves (evidence: `train_model.py`)
- SVM training → SVM model file: saves (evidence: `train_model.py`)
- Flask app → CNN model file: loads (evidence: `app.py`)
- Flask app → SVM model file: loads (evidence: `app.py`)
