# rabby50/image-to-text-ocr architecture

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

- Interactive diagram: https://gitdiagram.com/rabby50/image-to-text-ocr
- Repository: https://github.com/rabby50/image-to-text-ocr

## Overview

This local Flask OCR app lets a user select or drop an image, submit it for recognition, and review, copy, or download extracted text. The server validates and temporarily saves uploads, dispatches among automatic, PaddleOCR, and Tesseract modes, and returns normalized text and line metadata. The browser renders those results and enables export actions. The excerpts do not show every helper or cleanup detail, so the graph omits unverified internal links; README statements support the documented user workflow.

Main entry points: [`app.py`](https://github.com/rabby50/image-to-text-ocr/blob/main/app.py) (Mode dispatch), [`static/js/app.js`](https://github.com/rabby50/image-to-text-ocr/blob/main/static/js/app.js) (Browser logic), [`templates/index.html`](https://github.com/rabby50/image-to-text-ocr/blob/main/templates/index.html) (Upload interface), [`uploads`](https://github.com/rabby50/image-to-text-ocr/tree/main/uploads) (Temporary uploads)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser experience"]
  node_upload_ui["Upload interface<br/>[index.html]"]
  node_browser_logic["Browser logic<br/>[app.js]"]
  node_result_view["Result display<br/>[app.js]"]
  node_text_export["Copy / download<br/>[app.js]"]
end

subgraph group_service["Flask service"]
  node_flask["Flask app<br/>[app.py]"]
  node_ocr_endpoint["OCR endpoint<br/>[app.py]"]
  node_health_endpoint["Health endpoint<br/>[app.py]"]
  node_ocr_response["OCR response<br/>[app.py]"]
end

subgraph group_recognition["OCR recognition"]
  node_mode_dispatch["Mode dispatch<br/>[app.py]"]
  node_auto_ocr["Automatic OCR<br/>[app.py]"]
  node_paddle["PaddleOCR<br/>[app.py]"]
  node_tesseract["Tesseract OCR"]
  node_result_parser["Result parsing<br/>[app.py]"]
end

subgraph group_state["Temporary data"]
  node_upload_storage[("Temporary uploads")]
  node_bengali_data["Bengali language data<br/>[ben.traineddata]"]
end

node_user(("User"))

node_user -->|"selects image"| node_upload_ui
node_upload_ui -->|"supplies image"| node_browser_logic
node_browser_logic -->|"POSTs image"| node_ocr_endpoint
node_flask -->|"renders page"| node_upload_ui
node_ocr_endpoint -->|"saves upload"| node_upload_storage
node_ocr_endpoint -->|"dispatches mode"| node_mode_dispatch
node_mode_dispatch -->|"runs Paddle mode"| node_paddle
node_mode_dispatch -->|"runs Tesseract mode"| node_tesseract
node_mode_dispatch -->|"runs automatic mode"| node_auto_ocr
node_auto_ocr -->|"checks and runs"| node_tesseract
node_auto_ocr -->|"merges Latin results"| node_paddle
node_mode_dispatch -->|"parses Paddle output"| node_result_parser
node_tesseract -.->|"uses language data"| node_bengali_data
node_ocr_endpoint -->|"returns OCR result"| node_ocr_response
node_ocr_response -->|"provides JSON"| node_browser_logic
node_browser_logic -->|"renders lines"| node_result_view
node_result_view -->|"enables actions"| node_text_export
node_user -->|"copies or downloads"| node_text_export
node_user -.->|"checks readiness"| node_health_endpoint

click node_upload_ui "https://github.com/rabby50/image-to-text-ocr/blob/main/templates/index.html"
click node_browser_logic "https://github.com/rabby50/image-to-text-ocr/blob/main/static/js/app.js"
click node_result_view "https://github.com/rabby50/image-to-text-ocr/blob/main/static/js/app.js"
click node_text_export "https://github.com/rabby50/image-to-text-ocr/blob/main/static/js/app.js"
click node_flask "https://github.com/rabby50/image-to-text-ocr/blob/main/app.py"
click node_ocr_endpoint "https://github.com/rabby50/image-to-text-ocr/blob/main/app.py"
click node_health_endpoint "https://github.com/rabby50/image-to-text-ocr/blob/main/app.py"
click node_upload_storage "https://github.com/rabby50/image-to-text-ocr/tree/main/uploads"
click node_mode_dispatch "https://github.com/rabby50/image-to-text-ocr/blob/main/app.py"
click node_auto_ocr "https://github.com/rabby50/image-to-text-ocr/blob/main/app.py"
click node_paddle "https://github.com/rabby50/image-to-text-ocr/blob/main/app.py"
click node_result_parser "https://github.com/rabby50/image-to-text-ocr/blob/main/app.py"
click node_bengali_data "https://github.com/rabby50/image-to-text-ocr/blob/main/tessdata/ben.traineddata"
click node_ocr_response "https://github.com/rabby50/image-to-text-ocr/blob/main/app.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_upload_ui,node_browser_logic,node_result_view,node_text_export,node_user toneBlue
class node_flask,node_ocr_endpoint,node_health_endpoint,node_ocr_response toneAmber
class node_mode_dispatch,node_auto_ocr,node_paddle,node_tesseract,node_result_parser toneMint
class node_upload_storage,node_bengali_data toneRose
```

## Components

### Browser experience

- [Upload interface](https://github.com/rabby50/image-to-text-ocr/blob/main/templates/index.html): `templates/index.html`
- [Browser logic](https://github.com/rabby50/image-to-text-ocr/blob/main/static/js/app.js): `static/js/app.js`
- [Result display](https://github.com/rabby50/image-to-text-ocr/blob/main/static/js/app.js): `static/js/app.js`
- [Copy / download](https://github.com/rabby50/image-to-text-ocr/blob/main/static/js/app.js): `static/js/app.js`

### Flask service

- [Flask app](https://github.com/rabby50/image-to-text-ocr/blob/main/app.py): `app.py`
- [OCR endpoint](https://github.com/rabby50/image-to-text-ocr/blob/main/app.py): `app.py`
- [Health endpoint](https://github.com/rabby50/image-to-text-ocr/blob/main/app.py): `app.py`
- [OCR response](https://github.com/rabby50/image-to-text-ocr/blob/main/app.py): `app.py`

### OCR recognition

- [Mode dispatch](https://github.com/rabby50/image-to-text-ocr/blob/main/app.py): `app.py`
- [Automatic OCR](https://github.com/rabby50/image-to-text-ocr/blob/main/app.py): `app.py`
- [PaddleOCR](https://github.com/rabby50/image-to-text-ocr/blob/main/app.py): `app.py`
- **Tesseract OCR**
- [Result parsing](https://github.com/rabby50/image-to-text-ocr/blob/main/app.py): `app.py`

### Temporary data

- [Temporary uploads](https://github.com/rabby50/image-to-text-ocr/tree/main/uploads): `uploads`
- [Bengali language data](https://github.com/rabby50/image-to-text-ocr/blob/main/tessdata/ben.traineddata): `tessdata/ben.traineddata`

### Other components

- **User**

## Connections

- User → Upload interface: selects image (evidence: `README.md`)
- Upload interface → Browser logic: supplies image (evidence: `static/js/app.js`)
- Browser logic → OCR endpoint: POSTs image (evidence: `static/js/app.js`)
- Flask app → Upload interface: renders page (evidence: `app.py`)
- OCR endpoint → Temporary uploads: saves upload (evidence: `app.py`)
- OCR endpoint → Mode dispatch: dispatches mode (evidence: `app.py`)
- Mode dispatch → PaddleOCR: runs Paddle mode (evidence: `app.py`)
- Mode dispatch → Tesseract OCR: runs Tesseract mode (evidence: `app.py`)
- Mode dispatch → Automatic OCR: runs automatic mode (evidence: `app.py`)
- Automatic OCR → Tesseract OCR: checks and runs (evidence: `app.py`)
- Automatic OCR → PaddleOCR: merges Latin results (evidence: `app.py`)
- Mode dispatch → Result parsing: parses Paddle output (evidence: `app.py`)
- Tesseract OCR → Bengali language data: uses language data
- OCR endpoint → OCR response: returns OCR result (evidence: `app.py`)
- OCR response → Browser logic: provides JSON (evidence: `static/js/app.js`)
- Browser logic → Result display: renders lines (evidence: `static/js/app.js`)
- Result display → Copy / download: enables actions (evidence: `static/js/app.js`)
- User → Copy / download: copies or downloads (evidence: `README.md`)
- User → Health endpoint: checks readiness
