# rohan-r07/handwritten-digit-analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/rohan-r07/handwritten-digit-analyzer
- Repository: https://github.com/rohan-r07/handwritten-digit-analyzer

## Overview

This is a handwritten-digit recognition product with a Streamlit exploration interface and a React client for a FastAPI service. The principal workflow is image selection/upload, preprocessing and normalization, then hybrid template-and-feature classification; results include confidence/candidates and processing-stage visualizations. The graph also preserves the documented rule-based and template subsystems. Several implementation files, especially the API and React service, were not excerpted, so links based only on the README are identified as documented or left unverified.

Main entry points: [`frontend/src/App.tsx`](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/frontend/src/App.tsx) (React workspace), [`src/digit_recognizer.py`](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/src/digit_recognizer.py) (Hybrid recognition), [`app.py`](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/app.py) (Streamlit interface), [`src/api.py`](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/src/api.py) (FastAPI service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User interfaces"]
  node_react_app["React workspace<br/>[App.tsx]"]
  node_react_views["Upload and result views"]
  node_preview["Image preview<br/>[ImagePreview.tsx]"]
  node_processing_gallery["Processing gallery"]
  node_recognition_hook["Recognition state"]
  node_recognition_service["Recognition API client<br/>[recognitionApi.ts]"]
  node_streamlit["Streamlit interface<br/>[app.py]"]
end

subgraph group_processing["Image processing"]
  node_preprocessing["Preprocess and normalize<br/>[preprocessing.py]"]
  node_feature_extraction["Geometric features"]
end

subgraph group_recognition["Recognition engine"]
  node_recognizer["Hybrid recognition"]
  node_rule_classifier["Rule classifier<br/>[rule_classifier.py]"]
  node_template_matcher["Template matching"]
end

subgraph group_reference["Templates and API"]
  node_api["FastAPI service<br/>[api.py]"]
  node_template_manager["Template loading"]
  node_templates[("Reference digits")]
end

node_user(("Image submitter"))

node_user -->|"uploads image"| node_react_app
node_react_app -->|"renders"| node_react_views
node_react_app -->|"renders"| node_preview
node_react_app -->|"renders"| node_processing_gallery
node_react_app -->|"requests recognition"| node_recognition_hook
node_recognition_hook -->|"calls"| node_recognition_service
node_recognition_service -->|"sends upload"| node_api
node_user -->|"uploads image"| node_streamlit
node_streamlit -->|"preprocesses image"| node_preprocessing
node_streamlit -->|"extracts features"| node_feature_extraction
node_streamlit -->|"requests prediction"| node_recognizer
node_api -.->|"processes upload"| node_preprocessing
node_api -.->|"requests prediction"| node_recognizer
node_recognizer -->|"matches templates"| node_template_matcher
node_recognizer -->|"extracts features"| node_feature_extraction
node_recognizer -->|"scores features"| node_rule_classifier
node_template_matcher -->|"compares against"| node_templates
node_template_manager -.->|"loads templates"| node_templates

click node_react_app "https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/frontend/src/App.tsx"
click node_react_views "https://github.com/rohan-r07/handwritten-digit-analyzer/tree/main/frontend/src/components"
click node_preview "https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/frontend/src/components/ImagePreview.tsx"
click node_processing_gallery "https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/frontend/src/components/ProcessingGallery.tsx"
click node_recognition_hook "https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/frontend/src/hooks/useDigitRecognition.ts"
click node_recognition_service "https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/frontend/src/services/recognitionApi.ts"
click node_streamlit "https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/app.py"
click node_api "https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/src/api.py"
click node_preprocessing "https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/src/preprocessing.py"
click node_feature_extraction "https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/src/feature_extraction.py"
click node_recognizer "https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/src/digit_recognizer.py"
click node_rule_classifier "https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/src/rule_classifier.py"
click node_template_matcher "https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/src/template_matcher.py"
click node_template_manager "https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/src/template_manager.py"
click node_templates "https://github.com/rohan-r07/handwritten-digit-analyzer/tree/main/templates"

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_react_app,node_react_views,node_preview,node_processing_gallery,node_recognition_hook,node_recognition_service,node_streamlit toneBlue
class node_preprocessing,node_feature_extraction toneAmber
class node_recognizer,node_rule_classifier,node_template_matcher toneMint
class node_api,node_template_manager,node_templates toneRose
class node_user toneIndigo
```

## Components

### User interfaces

- [React workspace](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Upload and result views](https://github.com/rohan-r07/handwritten-digit-analyzer/tree/main/frontend/src/components): `frontend/src/components`
- [Image preview](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/frontend/src/components/ImagePreview.tsx): `frontend/src/components/ImagePreview.tsx`
- [Processing gallery](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/frontend/src/components/ProcessingGallery.tsx): `frontend/src/components/ProcessingGallery.tsx`
- [Recognition state](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/frontend/src/hooks/useDigitRecognition.ts): `frontend/src/hooks/useDigitRecognition.ts`
- [Recognition API client](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/frontend/src/services/recognitionApi.ts): `frontend/src/services/recognitionApi.ts`
- [Streamlit interface](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/app.py): `app.py`

### Image processing

- [Preprocess and normalize](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/src/preprocessing.py): `src/preprocessing.py`
- [Geometric features](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/src/feature_extraction.py): `src/feature_extraction.py`

### Recognition engine

- [Hybrid recognition](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/src/digit_recognizer.py): `src/digit_recognizer.py`
- [Rule classifier](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/src/rule_classifier.py): `src/rule_classifier.py`
- [Template matching](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/src/template_matcher.py): `src/template_matcher.py`

### Templates and API

- [FastAPI service](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/src/api.py): `src/api.py`
- [Template loading](https://github.com/rohan-r07/handwritten-digit-analyzer/blob/main/src/template_manager.py): `src/template_manager.py`
- [Reference digits](https://github.com/rohan-r07/handwritten-digit-analyzer/tree/main/templates): `templates`

### Other components

- **Image submitter**

## Connections

- Image submitter → React workspace: uploads image (evidence: `README.md`)
- React workspace → Upload and result views: renders (evidence: `frontend/src/App.tsx`)
- React workspace → Image preview: renders (evidence: `frontend/src/App.tsx`)
- React workspace → Processing gallery: renders (evidence: `frontend/src/App.tsx`)
- React workspace → Recognition state: requests recognition (evidence: `frontend/src/App.tsx`)
- Recognition state → Recognition API client: calls (evidence: `frontend/src/hooks/useDigitRecognition.ts`)
- Recognition API client → FastAPI service: sends upload (evidence: `README.md`)
- Image submitter → Streamlit interface: uploads image (evidence: `README.md`)
- Streamlit interface → Preprocess and normalize: preprocesses image (evidence: `app.py`)
- Streamlit interface → Geometric features: extracts features (evidence: `app.py`)
- Streamlit interface → Hybrid recognition: requests prediction (evidence: `app.py`)
- FastAPI service → Preprocess and normalize: processes upload
- FastAPI service → Hybrid recognition: requests prediction
- Hybrid recognition → Template matching: matches templates (evidence: `src/digit_recognizer.py`)
- Hybrid recognition → Geometric features: extracts features (evidence: `src/digit_recognizer.py`)
- Hybrid recognition → Rule classifier: scores features (evidence: `src/digit_recognizer.py`)
- Template matching → Reference digits: compares against (evidence: `README.md`)
- Template loading → Reference digits: loads templates
