# paddlepaddle/paddleocr architecture

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

- Interactive diagram: https://gitdiagram.com/paddlepaddle/paddleocr
- Repository: https://github.com/paddlepaddle/paddleocr
- Video tour (about a minute): https://gitdiagram.com/paddlepaddle/paddleocr/video

## Overview

PaddleOCR is a broad OCR and document-AI toolkit: users submit images or PDFs through its Python interfaces, run text recognition or document-parsing pipelines, and receive structured results such as JSON or Markdown. The repository also includes model/data-training infrastructure, API clients, and deployment runtimes. The graph emphasizes these product capabilities; some pipeline links are documented at the product level because their implementation was not sampled, so uncertain connections are left dashed.

Main entry points: [`paddleocr/__init__.py`](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/__init__.py) (Python API), [`paddleocr/_models/base.py`](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_models/base.py) (Inference models), [`paddleocr/_api_client/client.py`](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_api_client/client.py) (API SDK clients), [`paddleocr/_pipelines/pp_structurev3.py`](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_pipelines/pp_structurev3.py) (Structure parsing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_python["Python inference"]
  node_cli["Python CLI<br/>[_cli.py]"]
  node_api["Python API<br/>[__init__.py]"]
  node_ocr["OCR pipeline<br/>[ocr.py]"]
  node_preprocess["Document preprocessing"]
  node_structure["Structure parsing<br/>[pp_structurev3.py]"]
  node_vl["Document VLM<br/>[paddleocr_vl.py]"]
  node_docconvert["Document conversion<br/>[core.py]"]
end

subgraph group_models["Models and training"]
  node_model_api["Inference models<br/>[base.py]"]
  node_modeling["Model architectures<br/>[base_model.py]"]
  node_training["Training runner<br/>[program.py]"]
  node_data["Training data<br/>[simple_dataset.py]"]
end

subgraph group_clients["API clients"]
  node_api_client["API SDK clients<br/>[client.py]"]
  node_async_client["Async SDK<br/>[async_client.py]"]
  node_http["HTTP transport<br/>[_http.py]"]
  node_poller["Job polling<br/>[_poller.py]"]
  node_resources["Result resources<br/>[_resources.py]"]
end

subgraph group_deployment["Deployment and integrations"]
  node_cpp["C++ inference<br/>[pipeline.cc]"]
  node_mobile["Mobile OCR engines<br/>[OCREngine.kt]"]
  node_mcp["MCP integration<br/>[ocr.py]"]
  node_langchain["LangChain loader<br/>[paddleocr_vl.py]"]
end

node_user(("User or application"))
node_api_service{{"PaddleOCR API service"}}

node_user -.->|"invokes"| node_cli
node_user -.->|"submits images"| node_api
node_cli -.->|"dispatches"| node_api
node_api -.->|"runs OCR"| node_ocr
node_api -.->|"runs preprocessing"| node_preprocess
node_api -.->|"parses structure"| node_structure
node_api -.->|"parses with VLM"| node_vl
node_ocr -.->|"uses inference"| node_model_api
node_preprocess -.->|"uses inference"| node_model_api
node_structure -.->|"uses inference"| node_model_api
node_vl -.->|"uses inference"| node_model_api
node_structure -.->|"produces documents"| node_docconvert
node_vl -.->|"produces documents"| node_docconvert
node_data -.->|"supplies batches"| node_training
node_training -.->|"trains models"| node_modeling
node_api_client -->|"uses transport"| node_http
node_api_client -->|"polls jobs"| node_poller
node_api_client -->|"saves results"| node_resources
node_async_client -->|"uses transport"| node_http
node_async_client -->|"polls jobs"| node_poller
node_http -.->|"submits jobs"| node_api_service
node_api_service -.->|"returns job state"| node_poller
node_user -.->|"runs locally"| node_cpp
node_user -.->|"runs on device"| node_mobile
node_user -.->|"connects agent"| node_mcp
node_user -.->|"loads documents"| node_langchain

click node_cli "https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_cli.py"
click node_api "https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/__init__.py"
click node_ocr "https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_pipelines/ocr.py"
click node_preprocess "https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_pipelines/doc_preprocessor.py"
click node_structure "https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_pipelines/pp_structurev3.py"
click node_vl "https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_pipelines/paddleocr_vl.py"
click node_docconvert "https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_doc2md/core.py"
click node_model_api "https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_models/base.py"
click node_modeling "https://github.com/paddlepaddle/paddleocr/blob/main/ppocr/modeling/architectures/base_model.py"
click node_training "https://github.com/paddlepaddle/paddleocr/blob/main/tools/program.py"
click node_data "https://github.com/paddlepaddle/paddleocr/blob/main/ppocr/data/simple_dataset.py"
click node_api_client "https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_api_client/client.py"
click node_async_client "https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_api_client/async_client.py"
click node_http "https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_api_client/_http.py"
click node_poller "https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_api_client/_poller.py"
click node_resources "https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_api_client/_resources.py"
click node_cpp "https://github.com/paddlepaddle/paddleocr/blob/main/deploy/cpp_infer/src/pipelines/ocr/pipeline.cc"
click node_mobile "https://github.com/paddlepaddle/paddleocr/blob/main/deploy/ppocr-android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/OCREngine.kt"
click node_mcp "https://github.com/paddlepaddle/paddleocr/blob/main/mcp_server/paddleocr_mcp/tasks/ocr.py"
click node_langchain "https://github.com/paddlepaddle/paddleocr/blob/main/langchain-paddleocr/langchain_paddleocr/document_loaders/paddleocr_vl.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_ocr,node_preprocess,node_structure,node_vl,node_docconvert,node_user toneBlue
class node_model_api,node_modeling,node_training,node_data toneAmber
class node_api_client,node_async_client,node_http,node_poller,node_resources,node_api_service toneMint
class node_cpp,node_mobile,node_mcp,node_langchain toneRose
```

## Components

### Python inference

- [Python CLI](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_cli.py): `paddleocr/_cli.py`
- [Python API](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/__init__.py): `paddleocr/__init__.py`
- [OCR pipeline](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_pipelines/ocr.py): `paddleocr/_pipelines/ocr.py`
- [Document preprocessing](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_pipelines/doc_preprocessor.py): `paddleocr/_pipelines/doc_preprocessor.py`
- [Structure parsing](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_pipelines/pp_structurev3.py): `paddleocr/_pipelines/pp_structurev3.py`
- [Document VLM](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_pipelines/paddleocr_vl.py): `paddleocr/_pipelines/paddleocr_vl.py`
- [Document conversion](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_doc2md/core.py): `paddleocr/_doc2md/core.py`

### Models and training

- [Inference models](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_models/base.py): `paddleocr/_models/base.py`
- [Model architectures](https://github.com/paddlepaddle/paddleocr/blob/main/ppocr/modeling/architectures/base_model.py): `ppocr/modeling/architectures/base_model.py`
- [Training runner](https://github.com/paddlepaddle/paddleocr/blob/main/tools/program.py): `tools/program.py`
- [Training data](https://github.com/paddlepaddle/paddleocr/blob/main/ppocr/data/simple_dataset.py): `ppocr/data/simple_dataset.py`

### API clients

- [API SDK clients](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_api_client/client.py): `paddleocr/_api_client/client.py`
- [Async SDK](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_api_client/async_client.py): `paddleocr/_api_client/async_client.py`
- [HTTP transport](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_api_client/_http.py): `paddleocr/_api_client/_http.py`
- [Job polling](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_api_client/_poller.py): `paddleocr/_api_client/_poller.py`
- [Result resources](https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr/_api_client/_resources.py): `paddleocr/_api_client/_resources.py`

### Deployment and integrations

- [C++ inference](https://github.com/paddlepaddle/paddleocr/blob/main/deploy/cpp_infer/src/pipelines/ocr/pipeline.cc): `deploy/cpp_infer/src/pipelines/ocr/pipeline.cc`
- [Mobile OCR engines](https://github.com/paddlepaddle/paddleocr/blob/main/deploy/ppocr-android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/OCREngine.kt): `deploy/ppocr-android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/OCREngine.kt`
- [MCP integration](https://github.com/paddlepaddle/paddleocr/blob/main/mcp_server/paddleocr_mcp/tasks/ocr.py): `mcp_server/paddleocr_mcp/tasks/ocr.py`
- [LangChain loader](https://github.com/paddlepaddle/paddleocr/blob/main/langchain-paddleocr/langchain_paddleocr/document_loaders/paddleocr_vl.py): `langchain-paddleocr/langchain_paddleocr/document_loaders/paddleocr_vl.py`

### Other components

- **User or application**
- **PaddleOCR API service**

## Connections

- User or application → Python CLI: invokes
- User or application → Python API: submits images
- Python CLI → Python API: dispatches
- Python API → OCR pipeline: runs OCR
- Python API → Document preprocessing: runs preprocessing
- Python API → Structure parsing: parses structure
- Python API → Document VLM: parses with VLM
- OCR pipeline → Inference models: uses inference
- Document preprocessing → Inference models: uses inference
- Structure parsing → Inference models: uses inference
- Document VLM → Inference models: uses inference
- Structure parsing → Document conversion: produces documents
- Document VLM → Document conversion: produces documents
- Training data → Training runner: supplies batches
- Training runner → Model architectures: trains models
- API SDK clients → HTTP transport: uses transport (evidence: `paddleocr/_api_client/client.py`)
- API SDK clients → Job polling: polls jobs (evidence: `paddleocr/_api_client/client.py`)
- API SDK clients → Result resources: saves results (evidence: `paddleocr/_api_client/client.py`)
- Async SDK → HTTP transport: uses transport (evidence: `paddleocr/_api_client/async_client.py`)
- Async SDK → Job polling: polls jobs (evidence: `paddleocr/_api_client/async_client.py`)
- HTTP transport → PaddleOCR API service: submits jobs
- PaddleOCR API service → Job polling: returns job state
- User or application → C++ inference: runs locally
- User or application → Mobile OCR engines: runs on device
- User or application → MCP integration: connects agent
- User or application → LangChain loader: loads documents
