# camelot-dev/camelot architecture

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

- Interactive diagram: https://gitdiagram.com/camelot-dev/camelot
- Repository: https://github.com/camelot-dev/camelot

## Overview

Camelot is a Python library and CLI for turning PDF tables into pandas-backed tables and export files. The main workflow accepts a PDF or in-memory input, resolves pages, dispatches a parser, and returns extracted tables for inspection or export. Parser choices cover ruled, whitespace-based, alignment-based, hybrid, and neural structure detection; image conversion and line processing support visual analysis. The README documents these capabilities, while unsampled implementation details are represented cautiously rather than treated as inspected.

Main entry points: [`camelot/handlers.py`](https://github.com/camelot-dev/camelot/blob/master/camelot/handlers.py) (Parser dispatch), [`camelot/parsers/lattice.py`](https://github.com/camelot-dev/camelot/blob/master/camelot/parsers/lattice.py) (Lattice parser), [`camelot/core.py`](https://github.com/camelot-dev/camelot/blob/master/camelot/core.py) (Tables and list), [`camelot/io.py`](https://github.com/camelot-dev/camelot/blob/master/camelot/io.py) (Read API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_read_api["Read API<br/>[io.py]"]
  node_cli["CLI<br/>[cli.py]"]
end

subgraph group_orchestration["Extraction orchestration"]
  node_handler["PDF handler<br/>[handlers.py]"]
  node_dispatch["Parser dispatch<br/>[handlers.py]"]
  node_conversion["Image conversion"]
  node_backends["Render backends<br/>[pdfium_backend.py]"]
end

subgraph group_parsing["Table parsing"]
  node_base["Parser base<br/>[base.py]"]
  node_lattice["Lattice parser<br/>[lattice.py]"]
  node_stream["Stream parser<br/>[stream.py]"]
  node_network["Network parser<br/>[network.py]"]
  node_hybrid["Hybrid parser<br/>[hybrid.py]"]
  node_ml["ML parser<br/>[ml.py]"]
  node_image_processing["Line processing"]
end

subgraph group_results["Results and output"]
  node_tables["Tables and list<br/>[core.py]"]
  node_export["Export formats<br/>[core.py]"]
  node_plotting["Visual plotting<br/>[plotting.py]"]
end

node_user(("User"))
node_pdf["PDF input"]
node_pandas["pandas"]
node_ocr["OCR engine"]

node_user -->|"calls"| node_read_api
node_user -->|"runs"| node_cli
node_pdf -->|"supplies"| node_read_api
node_read_api -->|"creates handler"| node_handler
node_handler -->|"parses pages"| node_dispatch
node_dispatch -->|"selects parser"| node_lattice
node_dispatch -.->|"selects parser"| node_stream
node_dispatch -.->|"selects parser"| node_network
node_dispatch -.->|"selects parser"| node_hybrid
node_dispatch -.->|"selects parser"| node_ml
node_lattice -->|"extends"| node_base
node_stream -.->|"extends"| node_base
node_network -->|"extends"| node_base
node_hybrid -.->|"combines parser"| node_lattice
node_hybrid -.->|"combines parser"| node_network
node_lattice -->|"detects lines"| node_image_processing
node_lattice -->|"renders page"| node_conversion
node_conversion -->|"selects backend"| node_backends
node_ml -.->|"renders page"| node_conversion
node_ml -.->|"reads scan text"| node_ocr
node_dispatch -.->|"returns tables"| node_tables
node_read_api -->|"returns list"| node_tables
node_tables -->|"provides DataFrame"| node_pandas
node_tables -->|"exports"| node_export
node_tables -.->|"plots tables"| node_plotting
node_cli -.->|"exposes extraction"| node_read_api

click node_read_api "https://github.com/camelot-dev/camelot/blob/master/camelot/io.py"
click node_cli "https://github.com/camelot-dev/camelot/blob/master/camelot/cli.py"
click node_handler "https://github.com/camelot-dev/camelot/blob/master/camelot/handlers.py"
click node_dispatch "https://github.com/camelot-dev/camelot/blob/master/camelot/handlers.py"
click node_base "https://github.com/camelot-dev/camelot/blob/master/camelot/parsers/base.py"
click node_lattice "https://github.com/camelot-dev/camelot/blob/master/camelot/parsers/lattice.py"
click node_stream "https://github.com/camelot-dev/camelot/blob/master/camelot/parsers/stream.py"
click node_network "https://github.com/camelot-dev/camelot/blob/master/camelot/parsers/network.py"
click node_hybrid "https://github.com/camelot-dev/camelot/blob/master/camelot/parsers/hybrid.py"
click node_ml "https://github.com/camelot-dev/camelot/blob/master/camelot/parsers/ml.py"
click node_image_processing "https://github.com/camelot-dev/camelot/blob/master/camelot/image_processing.py"
click node_conversion "https://github.com/camelot-dev/camelot/blob/master/camelot/backends/image_conversion.py"
click node_backends "https://github.com/camelot-dev/camelot/blob/master/camelot/backends/pdfium_backend.py"
click node_tables "https://github.com/camelot-dev/camelot/blob/master/camelot/core.py"
click node_export "https://github.com/camelot-dev/camelot/blob/master/camelot/core.py"
click node_plotting "https://github.com/camelot-dev/camelot/blob/master/camelot/plotting.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_read_api,node_cli,node_user toneBlue
class node_handler,node_dispatch,node_conversion,node_backends toneAmber
class node_base,node_lattice,node_stream,node_network,node_hybrid,node_ml,node_image_processing toneMint
class node_tables,node_export,node_plotting toneRose
class node_pdf,node_pandas,node_ocr toneIndigo
```

## Components

### Entry points

- [Read API](https://github.com/camelot-dev/camelot/blob/master/camelot/io.py): `camelot/io.py`
- [CLI](https://github.com/camelot-dev/camelot/blob/master/camelot/cli.py): `camelot/cli.py`

### Extraction orchestration

- [PDF handler](https://github.com/camelot-dev/camelot/blob/master/camelot/handlers.py): `camelot/handlers.py`
- [Parser dispatch](https://github.com/camelot-dev/camelot/blob/master/camelot/handlers.py): `camelot/handlers.py`
- [Image conversion](https://github.com/camelot-dev/camelot/blob/master/camelot/backends/image_conversion.py): `camelot/backends/image_conversion.py`
- [Render backends](https://github.com/camelot-dev/camelot/blob/master/camelot/backends/pdfium_backend.py): `camelot/backends/pdfium_backend.py`

### Table parsing

- [Parser base](https://github.com/camelot-dev/camelot/blob/master/camelot/parsers/base.py): `camelot/parsers/base.py`
- [Lattice parser](https://github.com/camelot-dev/camelot/blob/master/camelot/parsers/lattice.py): `camelot/parsers/lattice.py`
- [Stream parser](https://github.com/camelot-dev/camelot/blob/master/camelot/parsers/stream.py): `camelot/parsers/stream.py`
- [Network parser](https://github.com/camelot-dev/camelot/blob/master/camelot/parsers/network.py): `camelot/parsers/network.py`
- [Hybrid parser](https://github.com/camelot-dev/camelot/blob/master/camelot/parsers/hybrid.py): `camelot/parsers/hybrid.py`
- [ML parser](https://github.com/camelot-dev/camelot/blob/master/camelot/parsers/ml.py): `camelot/parsers/ml.py`
- [Line processing](https://github.com/camelot-dev/camelot/blob/master/camelot/image_processing.py): `camelot/image_processing.py`

### Results and output

- [Tables and list](https://github.com/camelot-dev/camelot/blob/master/camelot/core.py): `camelot/core.py`
- [Export formats](https://github.com/camelot-dev/camelot/blob/master/camelot/core.py): `camelot/core.py`
- [Visual plotting](https://github.com/camelot-dev/camelot/blob/master/camelot/plotting.py): `camelot/plotting.py`

### Other components

- **User**
- **PDF input**
- **pandas**
- **OCR engine**

## Connections

- User → Read API: calls (evidence: `README.md`)
- User → CLI: runs (evidence: `README.md`)
- PDF input → Read API: supplies (evidence: `README.md`)
- Read API → PDF handler: creates handler (evidence: `camelot/io.py`)
- PDF handler → Parser dispatch: parses pages (evidence: `camelot/handlers.py`)
- Parser dispatch → Lattice parser: selects parser (evidence: `camelot/handlers.py`)
- Parser dispatch → Stream parser: selects parser (evidence: `README.md`)
- Parser dispatch → Network parser: selects parser (evidence: `README.md`)
- Parser dispatch → Hybrid parser: selects parser (evidence: `README.md`)
- Parser dispatch → ML parser: selects parser (evidence: `README.md`)
- Lattice parser → Parser base: extends (evidence: `camelot/parsers/lattice.py`)
- Stream parser → Parser base: extends (evidence: `camelot/parsers/stream.py`)
- Network parser → Parser base: extends (evidence: `camelot/parsers/network.py`)
- Hybrid parser → Lattice parser: combines parser (evidence: `README.md`)
- Hybrid parser → Network parser: combines parser (evidence: `README.md`)
- Lattice parser → Line processing: detects lines (evidence: `camelot/parsers/lattice.py`)
- Lattice parser → Image conversion: renders page (evidence: `camelot/parsers/lattice.py`)
- Image conversion → Render backends: selects backend (evidence: `camelot/backends/image_conversion.py`)
- ML parser → Image conversion: renders page (evidence: `README.md`)
- ML parser → OCR engine: reads scan text (evidence: `README.md`)
- Parser dispatch → Tables and list: returns tables (evidence: `camelot/handlers.py`)
- Read API → Tables and list: returns list (evidence: `camelot/io.py`)
- Tables and list → pandas: provides DataFrame (evidence: `README.md`)
- Tables and list → Export formats: exports (evidence: `README.md`)
- Tables and list → Visual plotting: plots tables
- CLI → Read API: exposes extraction (evidence: `README.md`)
