# firecrawl/anydoc architecture

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

- Interactive diagram: https://gitdiagram.com/firecrawl/anydoc
- Repository: https://github.com/firecrawl/anydoc

## Overview

anydoc is a Rust document-conversion library: callers provide a file or bytes, the library identifies or accepts a format, parses it into a shared document model, then serializes that model as GitHub-Flavored Markdown. The README also documents Node.js, Python, and browser bindings, embedded assets, and optional hosted OCR for scanned PDFs. Format frontends are grouped by domain; the source excerpts do not establish every dispatch path, so uncertain internal links are omitted.

Main entry points: [`src/formats/detect.rs`](https://github.com/firecrawl/anydoc/blob/main/src/formats/detect.rs) (Format detection), [`src/lib.rs`](https://github.com/firecrawl/anydoc/blob/main/src/lib.rs) (Rust API), [`src/formats/docx/mod.rs`](https://github.com/firecrawl/anydoc/blob/main/src/formats/docx/mod.rs) (Word parsing), [`src/formats/pptx/mod.rs`](https://github.com/firecrawl/anydoc/blob/main/src/formats/pptx/mod.rs) (Presentation parsing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Public interfaces"]
  node_rust_api["Rust API<br/>[lib.rs]"]
  node_node_binding["Node binding<br/>[lib.rs]"]
  node_python_binding["Python binding<br/>[lib.rs]"]
  node_wasm_binding["Wasm binding<br/>[lib.rs]"]
end

subgraph group_formats["Format frontends"]
  node_format_detection["Format detection<br/>[detect.rs]"]
  node_word["Word parsing<br/>[mod.rs]"]
  node_presentations["Presentation parsing<br/>[mod.rs]"]
  node_spreadsheets["Spreadsheet parsing<br/>[mod.rs]"]
  node_open_document["OpenDocument parsing<br/>[mod.rs]"]
  node_epub["EPUB parsing<br/>[mod.rs]"]
  node_rtf["RTF parsing<br/>[mod.rs]"]
  node_csv["CSV parsing<br/>[csv.rs]"]
  node_pdf["PDF parsing<br/>[pdf.rs]"]
end

subgraph group_core["Shared conversion core"]
  node_package["Archive and XML<br/>[mod.rs]"]
  node_shared_helpers["Parsing helpers<br/>[mod.rs]"]
  node_document_model["Document model<br/>[mod.rs]"]
  node_asset_store[("Embedded assets<br/>[assets.rs]")]
  node_markdown["Markdown renderer<br/>[mod.rs]"]
end

subgraph group_integration["External services"]
  node_firecrawl["Firecrawl Parse"]
end

node_caller(("Application"))

node_caller -->|"calls"| node_rust_api
node_rust_api -->|"detects format"| node_format_detection
node_rust_api -->|"returns document"| node_document_model
node_rust_api -->|"renders Markdown"| node_markdown
node_node_binding -->|"exposes conversion"| node_rust_api
node_python_binding -->|"exposes conversion"| node_rust_api
node_wasm_binding -->|"exposes conversion"| node_rust_api
node_format_detection -.->|"selects parser"| node_word
node_format_detection -.->|"selects parser"| node_presentations
node_format_detection -.->|"selects parser"| node_spreadsheets
node_format_detection -.->|"selects parser"| node_open_document
node_format_detection -.->|"selects parser"| node_epub
node_format_detection -.->|"selects parser"| node_rtf
node_format_detection -.->|"selects parser"| node_csv
node_format_detection -.->|"selects parser"| node_pdf
node_word -->|"builds model"| node_document_model
node_presentations -->|"builds model"| node_document_model
node_rtf -->|"builds model"| node_document_model
node_open_document -->|"reads package"| node_package
node_word -->|"reads package"| node_package
node_presentations -->|"reads package"| node_package
node_word -->|"uses helpers"| node_shared_helpers
node_presentations -->|"uses helpers"| node_shared_helpers
node_rtf -->|"uses helpers"| node_shared_helpers
node_epub -->|"uses HTML conversion"| node_shared_helpers
node_markdown -->|"renders from"| node_document_model
node_word -->|"retains assets"| node_asset_store
node_presentations -->|"retains assets"| node_asset_store
node_caller -.->|"requests OCR"| node_firecrawl
node_firecrawl -.->|"returns conversion"| node_markdown

click node_rust_api "https://github.com/firecrawl/anydoc/blob/main/src/lib.rs"
click node_node_binding "https://github.com/firecrawl/anydoc/blob/main/node/src/lib.rs"
click node_python_binding "https://github.com/firecrawl/anydoc/blob/main/python/src/lib.rs"
click node_wasm_binding "https://github.com/firecrawl/anydoc/blob/main/wasm/src/lib.rs"
click node_format_detection "https://github.com/firecrawl/anydoc/blob/main/src/formats/detect.rs"
click node_word "https://github.com/firecrawl/anydoc/blob/main/src/formats/docx/mod.rs"
click node_presentations "https://github.com/firecrawl/anydoc/blob/main/src/formats/pptx/mod.rs"
click node_spreadsheets "https://github.com/firecrawl/anydoc/blob/main/src/formats/sheet/mod.rs"
click node_open_document "https://github.com/firecrawl/anydoc/blob/main/src/formats/odf/mod.rs"
click node_epub "https://github.com/firecrawl/anydoc/blob/main/src/formats/epub/mod.rs"
click node_rtf "https://github.com/firecrawl/anydoc/blob/main/src/formats/rtf/mod.rs"
click node_csv "https://github.com/firecrawl/anydoc/blob/main/src/formats/csv.rs"
click node_pdf "https://github.com/firecrawl/anydoc/blob/main/src/formats/pdf.rs"
click node_package "https://github.com/firecrawl/anydoc/blob/main/src/package/mod.rs"
click node_shared_helpers "https://github.com/firecrawl/anydoc/blob/main/src/shared/mod.rs"
click node_document_model "https://github.com/firecrawl/anydoc/blob/main/src/model/mod.rs"
click node_asset_store "https://github.com/firecrawl/anydoc/blob/main/src/shared/assets.rs"
click node_markdown "https://github.com/firecrawl/anydoc/blob/main/src/render/markdown/mod.rs"

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_rust_api,node_node_binding,node_python_binding,node_wasm_binding toneBlue
class node_format_detection,node_word,node_presentations,node_spreadsheets,node_open_document,node_epub,node_rtf,node_csv,node_pdf toneAmber
class node_package,node_shared_helpers,node_document_model,node_asset_store,node_markdown toneMint
class node_firecrawl toneRose
class node_caller toneIndigo
```

## Components

### Public interfaces

- [Rust API](https://github.com/firecrawl/anydoc/blob/main/src/lib.rs): `src/lib.rs`
- [Node binding](https://github.com/firecrawl/anydoc/blob/main/node/src/lib.rs): `node/src/lib.rs`
- [Python binding](https://github.com/firecrawl/anydoc/blob/main/python/src/lib.rs): `python/src/lib.rs`
- [Wasm binding](https://github.com/firecrawl/anydoc/blob/main/wasm/src/lib.rs): `wasm/src/lib.rs`

### Format frontends

- [Format detection](https://github.com/firecrawl/anydoc/blob/main/src/formats/detect.rs): `src/formats/detect.rs`
- [Word parsing](https://github.com/firecrawl/anydoc/blob/main/src/formats/docx/mod.rs): `src/formats/docx/mod.rs`
- [Presentation parsing](https://github.com/firecrawl/anydoc/blob/main/src/formats/pptx/mod.rs): `src/formats/pptx/mod.rs`
- [Spreadsheet parsing](https://github.com/firecrawl/anydoc/blob/main/src/formats/sheet/mod.rs): `src/formats/sheet/mod.rs`
- [OpenDocument parsing](https://github.com/firecrawl/anydoc/blob/main/src/formats/odf/mod.rs): `src/formats/odf/mod.rs`
- [EPUB parsing](https://github.com/firecrawl/anydoc/blob/main/src/formats/epub/mod.rs): `src/formats/epub/mod.rs`
- [RTF parsing](https://github.com/firecrawl/anydoc/blob/main/src/formats/rtf/mod.rs): `src/formats/rtf/mod.rs`
- [CSV parsing](https://github.com/firecrawl/anydoc/blob/main/src/formats/csv.rs): `src/formats/csv.rs`
- [PDF parsing](https://github.com/firecrawl/anydoc/blob/main/src/formats/pdf.rs): `src/formats/pdf.rs`

### Shared conversion core

- [Archive and XML](https://github.com/firecrawl/anydoc/blob/main/src/package/mod.rs): `src/package/mod.rs`
- [Parsing helpers](https://github.com/firecrawl/anydoc/blob/main/src/shared/mod.rs): `src/shared/mod.rs`
- [Document model](https://github.com/firecrawl/anydoc/blob/main/src/model/mod.rs): `src/model/mod.rs`
- [Embedded assets](https://github.com/firecrawl/anydoc/blob/main/src/shared/assets.rs): `src/shared/assets.rs`
- [Markdown renderer](https://github.com/firecrawl/anydoc/blob/main/src/render/markdown/mod.rs): `src/render/markdown/mod.rs`

### External services

- **Firecrawl Parse**

### Other components

- **Application**

## Connections

- Application → Rust API: calls (evidence: `README.md`)
- Rust API → Format detection: detects format (evidence: `src/lib.rs`)
- Rust API → Document model: returns document (evidence: `src/lib.rs`)
- Rust API → Markdown renderer: renders Markdown (evidence: `src/lib.rs`)
- Node binding → Rust API: exposes conversion (evidence: `README.md`)
- Python binding → Rust API: exposes conversion (evidence: `README.md`)
- Wasm binding → Rust API: exposes conversion (evidence: `README.md`)
- Format detection → Word parsing: selects parser
- Format detection → Presentation parsing: selects parser
- Format detection → Spreadsheet parsing: selects parser
- Format detection → OpenDocument parsing: selects parser
- Format detection → EPUB parsing: selects parser
- Format detection → RTF parsing: selects parser
- Format detection → CSV parsing: selects parser
- Format detection → PDF parsing: selects parser
- Word parsing → Document model: builds model (evidence: `src/formats/docx/mod.rs`)
- Presentation parsing → Document model: builds model (evidence: `src/formats/pptx/mod.rs`)
- RTF parsing → Document model: builds model (evidence: `src/formats/rtf/mod.rs`)
- OpenDocument parsing → Archive and XML: reads package (evidence: `src/formats/odf/mod.rs`)
- Word parsing → Archive and XML: reads package (evidence: `src/formats/docx/mod.rs`)
- Presentation parsing → Archive and XML: reads package (evidence: `src/formats/pptx/mod.rs`)
- Word parsing → Parsing helpers: uses helpers (evidence: `src/formats/docx/mod.rs`)
- Presentation parsing → Parsing helpers: uses helpers (evidence: `src/formats/pptx/mod.rs`)
- RTF parsing → Parsing helpers: uses helpers (evidence: `src/formats/rtf/mod.rs`)
- EPUB parsing → Parsing helpers: uses HTML conversion
- Markdown renderer → Document model: renders from (evidence: `src/render/markdown/mod.rs`)
- Word parsing → Embedded assets: retains assets (evidence: `src/shared/assets.rs`)
- Presentation parsing → Embedded assets: retains assets (evidence: `src/shared/assets.rs`)
- Application → Firecrawl Parse: requests OCR (evidence: `README.md`)
- Firecrawl Parse → Markdown renderer: returns conversion (evidence: `README.md`)
