# haddarmelek/deepscanocr architecture

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

- Interactive diagram: https://gitdiagram.com/haddarmelek/deepscanocr
- Repository: https://github.com/haddarmelek/deepscanocr

## Overview

This is a small Flask OCR microservice. A client posts JSON containing a Base64 image to `/ocr`; the handler decodes it, sends the resulting image to Tesseract, and returns extracted text as JSON. The service also exposes a readiness response at `/`. The graph reflects the sampled runtime code; Tesseract is shown as an external dependency.

Main entry points: [`app/ocr_service.py`](https://github.com/haddarmelek/deepscanocr/blob/main/app/ocr_service.py) (OCR endpoint), [`app/utils.py`](https://github.com/haddarmelek/deepscanocr/blob/main/app/utils.py) (Image decoder), [`app/__init__.py`](https://github.com/haddarmelek/deepscanocr/blob/main/app/__init__.py) (App factory)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_client(("API client"))
node_service["Flask service<br/>[ocr_service.py]"]
node_app_factory["App factory<br/>[__init__.py]"]
node_ocr_endpoint["OCR endpoint<br/>[ocr_service.py]"]
node_readiness["Readiness endpoint<br/>[ocr_service.py]"]
node_decoder["Image decoder<br/>[utils.py]"]
node_tesseract["Tesseract OCR"]

node_service -->|"creates app"| node_app_factory
node_client -->|"POSTs image"| node_ocr_endpoint
node_ocr_endpoint -->|"decodes image"| node_decoder
node_decoder -->|"returns image"| node_ocr_endpoint
node_ocr_endpoint -->|"extracts text"| node_tesseract
node_ocr_endpoint -->|"returns JSON"| node_client
node_client -->|"requests status"| node_readiness
node_readiness -->|"returns ready"| node_client

click node_service "https://github.com/haddarmelek/deepscanocr/blob/main/app/ocr_service.py"
click node_app_factory "https://github.com/haddarmelek/deepscanocr/blob/main/app/__init__.py"
click node_ocr_endpoint "https://github.com/haddarmelek/deepscanocr/blob/main/app/ocr_service.py"
click node_readiness "https://github.com/haddarmelek/deepscanocr/blob/main/app/ocr_service.py"
click node_decoder "https://github.com/haddarmelek/deepscanocr/blob/main/app/utils.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_client toneBlue
class node_service,node_app_factory,node_ocr_endpoint,node_readiness,node_decoder toneTeal
class node_tesseract toneIndigo
```

## Components

### Other components

- **API client**
- [Flask service](https://github.com/haddarmelek/deepscanocr/blob/main/app/ocr_service.py): `app/ocr_service.py`
- [App factory](https://github.com/haddarmelek/deepscanocr/blob/main/app/__init__.py): `app/__init__.py`
- [OCR endpoint](https://github.com/haddarmelek/deepscanocr/blob/main/app/ocr_service.py): `app/ocr_service.py`
- [Readiness endpoint](https://github.com/haddarmelek/deepscanocr/blob/main/app/ocr_service.py): `app/ocr_service.py`
- [Image decoder](https://github.com/haddarmelek/deepscanocr/blob/main/app/utils.py): `app/utils.py`
- **Tesseract OCR**

## Connections

- Flask service → App factory: creates app
- API client → OCR endpoint: POSTs image
- OCR endpoint → Image decoder: decodes image
- Image decoder → OCR endpoint: returns image
- OCR endpoint → Tesseract OCR: extracts text
- OCR endpoint → API client: returns JSON
- API client → Readiness endpoint: requests status
- Readiness endpoint → API client: returns ready
