# remtir/aksonocr-lite architecture

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

- Interactive diagram: https://gitdiagram.com/remtir/aksonocr-lite
- Repository: https://github.com/remtir/aksonocr-lite

## Overview

AksonOCR-Lite converts image or PDF pages into Markdown, text, or structured JSON, combining layout, OCR, reading order, and table reconstruction. The public Python API and CLI lead into a page converter that orchestrates input loading, optional dewarping, orientation correction, layout and line OCR, table handling, and result formatting. Model sessions are shared infrastructure, with weights fetched from Hugging Face or loaded locally. The README documents the stages; some internal pipeline calls were not shown, so those links cite the README rather than implying unsampled code was inspected.

Main entry points: [`aksonocr_lite/pipeline.py`](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/pipeline.py) (Page converter), [`aksonocr_lite/models.py`](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/models.py) (Model sessions), [`aksonocr_lite/layout.py`](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/layout.py) (Layout analysis), [`aksonocr_lite/__init__.py`](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/__init__.py) (Python API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_cli["CLI<br/>[cli.py]"]
  node_api["Python API<br/>[__init__.py]"]
end

subgraph group_pipeline["Page processing"]
  node_converter["Page converter<br/>[pipeline.py]"]
  node_input["Page loading<br/>[inputs.py]"]
  node_dewarp["Page dewarping<br/>[dewarp.py]"]
  node_pageori["Page orientation<br/>[orient.py]"]
  node_layout["Layout analysis<br/>[layout.py]"]
  node_postprocess["Layout postprocess<br/>[paddlex_layout.py]"]
  node_detection["Line detection<br/>[det.py]"]
  node_lineori["Line orientation<br/>[orient.py]"]
  node_recognizer["Thai recognizer<br/>[rec.py]"]
  node_tables["Table structure<br/>[table.py]"]
end

subgraph group_inference["Model inference"]
  node_models["Model sessions<br/>[models.py]"]
  node_weights[("Hugging Face weights")]
  node_localweights[("Local weights")]
end

subgraph group_output["Structured results"]
  node_schema["Page schema<br/>[schema.py]"]
  node_formatted["Markdown output<br/>[pipeline.py]"]
end

node_user(("Document user"))

node_user -->|"runs"| node_cli
node_user -->|"calls"| node_api
node_cli -->|"loads"| node_api
node_api -->|"creates"| node_converter
node_converter -->|"loads pages"| node_input
node_converter -.->|"optionally dewarps"| node_dewarp
node_converter -->|"corrects rotation"| node_pageori
node_converter -->|"detects layout"| node_layout
node_layout -->|"postprocesses"| node_postprocess
node_converter -->|"detects lines"| node_detection
node_converter -->|"checks line orientation"| node_lineori
node_converter -->|"recognizes lines"| node_recognizer
node_converter -->|"builds tables"| node_tables
node_converter -->|"returns page data"| node_schema
node_converter -->|"formats Markdown"| node_formatted
node_detection -->|"opens session"| node_models
node_dewarp -->|"opens sessions"| node_models
node_layout -->|"opens session"| node_models
node_pageori -->|"opens session"| node_models
node_recognizer -->|"opens session"| node_models
node_tables -->|"opens session"| node_models
node_models -->|"downloads"| node_weights
node_models -->|"loads when configured"| node_localweights

click node_cli "https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/cli.py"
click node_api "https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/__init__.py"
click node_converter "https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/pipeline.py"
click node_input "https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/inputs.py"
click node_dewarp "https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/dewarp.py"
click node_pageori "https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/orient.py"
click node_layout "https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/layout.py"
click node_postprocess "https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/_vendor/paddlex_layout.py"
click node_detection "https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/det.py"
click node_lineori "https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/orient.py"
click node_recognizer "https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/rec.py"
click node_tables "https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/table.py"
click node_models "https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/models.py"
click node_schema "https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/schema.py"
click node_formatted "https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/pipeline.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_cli,node_api,node_user toneBlue
class node_converter,node_input,node_dewarp,node_pageori,node_layout,node_postprocess,node_detection,node_lineori,node_recognizer,node_tables toneAmber
class node_models,node_weights,node_localweights toneMint
class node_schema,node_formatted toneRose
```

## Components

### User interfaces

- [CLI](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/cli.py): `aksonocr_lite/cli.py`
- [Python API](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/__init__.py): `aksonocr_lite/__init__.py`

### Page processing

- [Page converter](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/pipeline.py): `aksonocr_lite/pipeline.py`
- [Page loading](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/inputs.py): `aksonocr_lite/inputs.py`
- [Page dewarping](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/dewarp.py): `aksonocr_lite/dewarp.py`
- [Page orientation](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/orient.py): `aksonocr_lite/orient.py`
- [Layout analysis](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/layout.py): `aksonocr_lite/layout.py`
- [Layout postprocess](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/_vendor/paddlex_layout.py): `aksonocr_lite/_vendor/paddlex_layout.py`
- [Line detection](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/det.py): `aksonocr_lite/det.py`
- [Line orientation](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/orient.py): `aksonocr_lite/orient.py`
- [Thai recognizer](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/rec.py): `aksonocr_lite/rec.py`
- [Table structure](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/table.py): `aksonocr_lite/table.py`

### Model inference

- [Model sessions](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/models.py): `aksonocr_lite/models.py`
- **Hugging Face weights**
- **Local weights**

### Structured results

- [Page schema](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/schema.py): `aksonocr_lite/schema.py`
- [Markdown output](https://github.com/remtir/aksonocr-lite/blob/main/aksonocr_lite/pipeline.py): `aksonocr_lite/pipeline.py`

### Other components

- **Document user**

## Connections

- Document user → CLI: runs (evidence: `README.md`)
- Document user → Python API: calls (evidence: `README.md`)
- CLI → Python API: loads (evidence: `aksonocr_lite/cli.py`)
- Python API → Page converter: creates (evidence: `aksonocr_lite/__init__.py`)
- Page converter → Page loading: loads pages (evidence: `README.md`)
- Page converter → Page dewarping: optionally dewarps (evidence: `aksonocr_lite/pipeline.py`)
- Page converter → Page orientation: corrects rotation (evidence: `README.md`)
- Page converter → Layout analysis: detects layout (evidence: `README.md`)
- Layout analysis → Layout postprocess: postprocesses (evidence: `aksonocr_lite/layout.py`)
- Page converter → Line detection: detects lines (evidence: `README.md`)
- Page converter → Line orientation: checks line orientation (evidence: `README.md`)
- Page converter → Thai recognizer: recognizes lines (evidence: `README.md`)
- Page converter → Table structure: builds tables (evidence: `README.md`)
- Page converter → Page schema: returns page data (evidence: `aksonocr_lite/pipeline.py`)
- Page converter → Markdown output: formats Markdown (evidence: `README.md`)
- Line detection → Model sessions: opens session (evidence: `aksonocr_lite/det.py`)
- Page dewarping → Model sessions: opens sessions (evidence: `aksonocr_lite/dewarp.py`)
- Layout analysis → Model sessions: opens session (evidence: `aksonocr_lite/layout.py`)
- Page orientation → Model sessions: opens session (evidence: `aksonocr_lite/orient.py`)
- Thai recognizer → Model sessions: opens session (evidence: `aksonocr_lite/rec.py`)
- Table structure → Model sessions: opens session (evidence: `aksonocr_lite/table.py`)
- Model sessions → Hugging Face weights: downloads (evidence: `aksonocr_lite/models.py`)
- Model sessions → Local weights: loads when configured (evidence: `aksonocr_lite/models.py`)
