# hugbrl09/digits-28 architecture

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

- Interactive diagram: https://gitdiagram.com/hugbrl09/digits-28
- Repository: https://github.com/hugbrl09/digits-28

## Overview

digits-28 is a browser-based handwritten-digit recognizer, supported by a model-training, evaluation, and TensorFlow.js export workflow. The main user path is drawing or choosing a sample, normalizing the canvas input, running inference in the browser, and viewing the predicted digit and class confidences. Training and evaluation are separate development-time capabilities. The graph uses the sampled app, training, and converter code plus README statements; detailed evaluation and export-verification implementations were not sampled.

Main entry points: [`app.js`](https://github.com/hugbrl09/digits-28/blob/main/app.js) (Browser inference), [`modelo.keras`](https://github.com/hugbrl09/digits-28/blob/main/modelo.keras) (Keras model), [`modelo_web/model.json`](https://github.com/hugbrl09/digits-28/blob/main/modelo_web/model.json) (TF.js model manifest), [`converter_standalone.py`](https://github.com/hugbrl09/digits-28/blob/main/converter_standalone.py) (Standalone converter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Browser recognition"]
  node_page["Recognition page<br/>[index.html]"]
  node_drawing["Drawing and samples<br/>[app.js]"]
  node_preprocess["Canvas normalization<br/>[app.js]"]
  node_inference["Browser inference<br/>[app.js]"]
  node_prediction["Prediction display<br/>[app.js]"]
  node_tfjs["TensorFlow.js runtime"]
end

subgraph group_ml["Model development"]
  node_training["MNIST training<br/>[treinar_mnist.py]"]
  node_mnist[("MNIST dataset")]
  node_keras[("Keras model<br/>[modelo.keras]")]
end

subgraph group_export["Model export"]
  node_official_export["Official TF.js export<br/>[treinar_mnist.py]"]
  node_standalone_export["Standalone converter"]
  node_manifest["TF.js model manifest<br/>[model.json]"]
  node_weights[("Model weights")]
end

subgraph group_results["Evaluation results"]
  node_evaluation["Test evaluation<br/>[treinar_mnist.py]"]
  node_report["Evaluation report<br/>[relatorio.json]"]
  node_confusion["Error examples"]
end

node_user(("Page user"))

node_user -->|"opens"| node_page
node_page -->|"hosts"| node_drawing
node_drawing -->|"normalizes"| node_preprocess
node_preprocess -->|"feeds"| node_inference
node_inference -->|"predicts with"| node_tfjs
node_inference -->|"loads"| node_manifest
node_manifest -->|"references"| node_weights
node_inference -->|"updates"| node_prediction
node_mnist -->|"supplies data"| node_training
node_training -->|"trains"| node_keras
node_keras -->|"is evaluated"| node_evaluation
node_evaluation -.->|"records results"| node_report
node_evaluation -.->|"reports errors"| node_confusion
node_keras -->|"exports from"| node_official_export
node_official_export -->|"writes"| node_manifest
node_keras -->|"converts from"| node_standalone_export
node_standalone_export -->|"writes"| node_manifest
node_standalone_export -->|"writes"| node_weights

click node_page "https://github.com/hugbrl09/digits-28/blob/main/index.html"
click node_drawing "https://github.com/hugbrl09/digits-28/blob/main/app.js"
click node_preprocess "https://github.com/hugbrl09/digits-28/blob/main/app.js"
click node_inference "https://github.com/hugbrl09/digits-28/blob/main/app.js"
click node_prediction "https://github.com/hugbrl09/digits-28/blob/main/app.js"
click node_training "https://github.com/hugbrl09/digits-28/blob/main/treinar_mnist.py"
click node_keras "https://github.com/hugbrl09/digits-28/blob/main/modelo.keras"
click node_evaluation "https://github.com/hugbrl09/digits-28/blob/main/treinar_mnist.py"
click node_report "https://github.com/hugbrl09/digits-28/blob/main/relatorio.json"
click node_confusion "https://github.com/hugbrl09/digits-28/tree/main/relatorio"
click node_official_export "https://github.com/hugbrl09/digits-28/blob/main/treinar_mnist.py"
click node_standalone_export "https://github.com/hugbrl09/digits-28/blob/main/converter_standalone.py"
click node_manifest "https://github.com/hugbrl09/digits-28/blob/main/modelo_web/model.json"
click node_weights "https://github.com/hugbrl09/digits-28/blob/main/modelo_web/group1-shard1of1.bin"

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_page,node_drawing,node_preprocess,node_inference,node_prediction,node_tfjs,node_user toneBlue
class node_training,node_mnist,node_keras toneAmber
class node_official_export,node_standalone_export,node_manifest,node_weights toneMint
class node_evaluation,node_report,node_confusion toneRose
```

## Components

### Browser recognition

- [Recognition page](https://github.com/hugbrl09/digits-28/blob/main/index.html): `index.html`
- [Drawing and samples](https://github.com/hugbrl09/digits-28/blob/main/app.js): `app.js`
- [Canvas normalization](https://github.com/hugbrl09/digits-28/blob/main/app.js): `app.js`
- [Browser inference](https://github.com/hugbrl09/digits-28/blob/main/app.js): `app.js`
- [Prediction display](https://github.com/hugbrl09/digits-28/blob/main/app.js): `app.js`
- **TensorFlow.js runtime**

### Model development

- [MNIST training](https://github.com/hugbrl09/digits-28/blob/main/treinar_mnist.py): `treinar_mnist.py`
- **MNIST dataset**
- [Keras model](https://github.com/hugbrl09/digits-28/blob/main/modelo.keras): `modelo.keras`

### Model export

- [Official TF.js export](https://github.com/hugbrl09/digits-28/blob/main/treinar_mnist.py): `treinar_mnist.py`
- [Standalone converter](https://github.com/hugbrl09/digits-28/blob/main/converter_standalone.py): `converter_standalone.py`
- [TF.js model manifest](https://github.com/hugbrl09/digits-28/blob/main/modelo_web/model.json): `modelo_web/model.json`
- [Model weights](https://github.com/hugbrl09/digits-28/blob/main/modelo_web/group1-shard1of1.bin): `modelo_web/group1-shard1of1.bin`

### Evaluation results

- [Test evaluation](https://github.com/hugbrl09/digits-28/blob/main/treinar_mnist.py): `treinar_mnist.py`
- [Evaluation report](https://github.com/hugbrl09/digits-28/blob/main/relatorio.json): `relatorio.json`
- [Error examples](https://github.com/hugbrl09/digits-28/tree/main/relatorio): `relatorio`

### Other components

- **Page user**

## Connections

- Page user → Recognition page: opens (evidence: `README.md`)
- Recognition page → Drawing and samples: hosts (evidence: `README.md`)
- Drawing and samples → Canvas normalization: normalizes (evidence: `app.js`)
- Canvas normalization → Browser inference: feeds (evidence: `app.js`)
- Browser inference → TensorFlow.js runtime: predicts with (evidence: `app.js`)
- Browser inference → TF.js model manifest: loads (evidence: `app.js`)
- TF.js model manifest → Model weights: references (evidence: `README.md`)
- Browser inference → Prediction display: updates (evidence: `app.js`)
- MNIST dataset → MNIST training: supplies data (evidence: `treinar_mnist.py`)
- MNIST training → Keras model: trains (evidence: `treinar_mnist.py`)
- Keras model → Test evaluation: is evaluated (evidence: `treinar_mnist.py`)
- Test evaluation → Evaluation report: records results
- Test evaluation → Error examples: reports errors
- Keras model → Official TF.js export: exports from (evidence: `treinar_mnist.py`)
- Official TF.js export → TF.js model manifest: writes (evidence: `README.md`)
- Keras model → Standalone converter: converts from (evidence: `converter_standalone.py`)
- Standalone converter → TF.js model manifest: writes (evidence: `converter_standalone.py`)
- Standalone converter → Model weights: writes (evidence: `converter_standalone.py`)
