# openooxml/betteroffice architecture

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

- Interactive diagram: https://gitdiagram.com/openooxml/betteroffice
- Repository: https://github.com/openooxml/betteroffice

## Overview

BetterOffice is a Rust-native office suite for DOCX, XLSX, PPTX, and source-preview VSDX, exposed through Rust/Python APIs and browser editors backed by WebAssembly. Users open an Office file, edit it in an editor or headless API, and render or save it; collaboration and reviewable agent proposals extend that flow. The graph preserves documented format capabilities, including XLSX calculation and host-controlled editing. Source excerpts chiefly illuminate DOCX worker/layout and proposal handling; other format and integration links below rely on README statements rather than sampled implementation.

Main entry points: [`packages/docx-react/src`](https://github.com/openooxml/betteroffice/tree/main/packages/docx-react/src) (React editors), [`packages/xlsx-react/src`](https://github.com/openooxml/betteroffice/tree/main/packages/xlsx-react/src) (XLSX React editor), [`packages/docx/src/yrs/index.ts`](https://github.com/openooxml/betteroffice/blob/main/packages/docx/src/yrs/index.ts) (DOCX editor core), [`packages/pptx-react/src`](https://github.com/openooxml/betteroffice/tree/main/packages/pptx-react/src) (PPTX React editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User-facing clients"]
  node_react_editors["React editors"]
  node_docx_layout["DOCX layout pipeline"]
  node_xlsx_editor["XLSX React editor"]
  node_xlsx_commands["XLSX commands"]
  node_pptx_editor["PPTX React editor"]
end

subgraph group_docx["DOCX engine"]
  node_docx_core["DOCX editor core<br/>[index.ts]"]
  node_docx_types["Document model<br/>[content.ts]"]
  node_docx_worker["Resident engine worker"]
  node_docx_session["Resident session"]
  node_docx_wasm["Rust edit engine<br/>[lib.rs]"]
end

subgraph group_office["Other office formats"]
  node_xlsx_engine["XLSX engine<br/>[lib.rs]"]
  node_xlsx_calc["Formula calculation<br/>[engine.rs]"]
  node_pptx_engine["PPTX engine<br/>[lib.rs]"]
  node_vsdx_engine["VSDX source preview<br/>[lib.rs]"]
end

subgraph group_collaboration["Collaboration and review"]
  node_docx_proposals["Tracked proposals<br/>[proposals.ts]"]
  node_relay["Collaboration relay<br/>[index.ts]"]
end

subgraph group_apis["Developer APIs"]
  node_rust_api["Rust APIs<br/>[lib.rs]"]
  node_python_api["Python APIs<br/>[lib.rs]"]
end

node_user(("Editor user"))
node_office_file["Office files"]
node_peers(("Collaborators"))

node_user -->|"edits in"| node_react_editors
node_office_file -->|"opens"| node_react_editors
node_react_editors -->|"lays out"| node_docx_layout
node_docx_layout -->|"schedules layout"| node_docx_worker
node_docx_worker -->|"creates session"| node_docx_session
node_docx_session -->|"loads edit engine"| node_docx_wasm
node_docx_core -->|"wraps Rust core"| node_docx_wasm
node_docx_core -->|"uses model"| node_docx_types
node_docx_core -->|"supports review"| node_docx_proposals
node_user -->|"edits workbook"| node_xlsx_editor
node_office_file -->|"opens"| node_xlsx_editor
node_xlsx_editor -->|"dispatches commands"| node_xlsx_commands
node_xlsx_editor -->|"edits and renders"| node_xlsx_engine
node_xlsx_engine -.->|"calculates formulas"| node_xlsx_calc
node_user -->|"edits slides"| node_pptx_editor
node_office_file -->|"opens"| node_pptx_editor
node_pptx_editor -->|"edits and renders"| node_pptx_engine
node_office_file -->|"previews source"| node_vsdx_engine
node_peers -->|"collaborate in"| node_react_editors
node_react_editors -.->|"syncs updates"| node_relay
node_relay -.->|"relays updates"| node_peers
node_user -->|"automates with"| node_rust_api
node_user -->|"automates with"| node_python_api
node_rust_api -->|"opens and saves"| node_office_file
node_python_api -->|"opens and saves"| node_office_file

click node_react_editors "https://github.com/openooxml/betteroffice/tree/main/packages/docx-react/src"
click node_docx_layout "https://github.com/openooxml/betteroffice/blob/main/packages/docx-react/src/components/DocxEditor/hooks/useLayoutPipeline.ts"
click node_docx_core "https://github.com/openooxml/betteroffice/blob/main/packages/docx/src/yrs/index.ts"
click node_docx_types "https://github.com/openooxml/betteroffice/blob/main/packages/docx/src/types/content.ts"
click node_docx_worker "https://github.com/openooxml/betteroffice/blob/main/packages/docx/src/yrs/residentEngineWorker.ts"
click node_docx_session "https://github.com/openooxml/betteroffice/blob/main/packages/docx/src/yrs/residentEngineSession.ts"
click node_docx_wasm "https://github.com/openooxml/betteroffice/blob/main/crates/docx-edit/src/lib.rs"
click node_docx_proposals "https://github.com/openooxml/betteroffice/blob/main/packages/docx/src/yrs/proposals.ts"
click node_xlsx_editor "https://github.com/openooxml/betteroffice/tree/main/packages/xlsx-react/src"
click node_xlsx_commands "https://github.com/openooxml/betteroffice/blob/main/packages/xlsx-react/src/commands/useWorkerXlsxCommands.ts"
click node_xlsx_engine "https://github.com/openooxml/betteroffice/blob/main/crates/betteroffice-xlsx/src/lib.rs"
click node_xlsx_calc "https://github.com/openooxml/betteroffice/blob/main/crates/xlsx-calc/src/engine.rs"
click node_pptx_editor "https://github.com/openooxml/betteroffice/tree/main/packages/pptx-react/src"
click node_pptx_engine "https://github.com/openooxml/betteroffice/blob/main/crates/betteroffice-pptx/src/lib.rs"
click node_vsdx_engine "https://github.com/openooxml/betteroffice/blob/main/crates/vsdx-render/src/lib.rs"
click node_relay "https://github.com/openooxml/betteroffice/blob/main/apps/relay/src/index.ts"
click node_rust_api "https://github.com/openooxml/betteroffice/blob/main/crates/betteroffice-docx/src/lib.rs"
click node_python_api "https://github.com/openooxml/betteroffice/blob/main/bindings/python-docx/src/lib.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_react_editors,node_docx_layout,node_xlsx_editor,node_xlsx_commands,node_pptx_editor,node_user toneBlue
class node_docx_core,node_docx_types,node_docx_worker,node_docx_session,node_docx_wasm toneAmber
class node_xlsx_engine,node_xlsx_calc,node_pptx_engine,node_vsdx_engine toneMint
class node_docx_proposals,node_relay toneRose
class node_rust_api,node_python_api,node_office_file,node_peers toneIndigo
```

## Components

### User-facing clients

- [React editors](https://github.com/openooxml/betteroffice/tree/main/packages/docx-react/src): `packages/docx-react/src`
- [DOCX layout pipeline](https://github.com/openooxml/betteroffice/blob/main/packages/docx-react/src/components/DocxEditor/hooks/useLayoutPipeline.ts): `packages/docx-react/src/components/DocxEditor/hooks/useLayoutPipeline.ts`
- [XLSX React editor](https://github.com/openooxml/betteroffice/tree/main/packages/xlsx-react/src): `packages/xlsx-react/src`
- [XLSX commands](https://github.com/openooxml/betteroffice/blob/main/packages/xlsx-react/src/commands/useWorkerXlsxCommands.ts): `packages/xlsx-react/src/commands/useWorkerXlsxCommands.ts`
- [PPTX React editor](https://github.com/openooxml/betteroffice/tree/main/packages/pptx-react/src): `packages/pptx-react/src`

### DOCX engine

- [DOCX editor core](https://github.com/openooxml/betteroffice/blob/main/packages/docx/src/yrs/index.ts): `packages/docx/src/yrs/index.ts`
- [Document model](https://github.com/openooxml/betteroffice/blob/main/packages/docx/src/types/content.ts): `packages/docx/src/types/content.ts`
- [Resident engine worker](https://github.com/openooxml/betteroffice/blob/main/packages/docx/src/yrs/residentEngineWorker.ts): `packages/docx/src/yrs/residentEngineWorker.ts`
- [Resident session](https://github.com/openooxml/betteroffice/blob/main/packages/docx/src/yrs/residentEngineSession.ts): `packages/docx/src/yrs/residentEngineSession.ts`
- [Rust edit engine](https://github.com/openooxml/betteroffice/blob/main/crates/docx-edit/src/lib.rs): `crates/docx-edit/src/lib.rs`

### Other office formats

- [XLSX engine](https://github.com/openooxml/betteroffice/blob/main/crates/betteroffice-xlsx/src/lib.rs): `crates/betteroffice-xlsx/src/lib.rs`
- [Formula calculation](https://github.com/openooxml/betteroffice/blob/main/crates/xlsx-calc/src/engine.rs): `crates/xlsx-calc/src/engine.rs`
- [PPTX engine](https://github.com/openooxml/betteroffice/blob/main/crates/betteroffice-pptx/src/lib.rs): `crates/betteroffice-pptx/src/lib.rs`
- [VSDX source preview](https://github.com/openooxml/betteroffice/blob/main/crates/vsdx-render/src/lib.rs): `crates/vsdx-render/src/lib.rs`

### Collaboration and review

- [Tracked proposals](https://github.com/openooxml/betteroffice/blob/main/packages/docx/src/yrs/proposals.ts): `packages/docx/src/yrs/proposals.ts`
- [Collaboration relay](https://github.com/openooxml/betteroffice/blob/main/apps/relay/src/index.ts): `apps/relay/src/index.ts`

### Developer APIs

- [Rust APIs](https://github.com/openooxml/betteroffice/blob/main/crates/betteroffice-docx/src/lib.rs): `crates/betteroffice-docx/src/lib.rs`
- [Python APIs](https://github.com/openooxml/betteroffice/blob/main/bindings/python-docx/src/lib.rs): `bindings/python-docx/src/lib.rs`

### Other components

- **Editor user**
- **Office files**
- **Collaborators**

## Connections

- Editor user → React editors: edits in (evidence: `README.md`)
- Office files → React editors: opens (evidence: `README.md`)
- React editors → DOCX layout pipeline: lays out (evidence: `packages/docx-react/src/components/DocxEditor/hooks/useLayoutPipeline.ts`)
- DOCX layout pipeline → Resident engine worker: schedules layout (evidence: `packages/docx-react/src/components/DocxEditor/hooks/useLayoutPipeline.ts`)
- Resident engine worker → Resident session: creates session (evidence: `packages/docx/src/yrs/residentEngineWorker.ts`)
- Resident session → Rust edit engine: loads edit engine (evidence: `packages/docx/src/yrs/residentEngineSession.ts`)
- DOCX editor core → Rust edit engine: wraps Rust core (evidence: `packages/docx/src/yrs/index.ts`)
- DOCX editor core → Document model: uses model (evidence: `packages/docx/src/yrs/index.ts`)
- DOCX editor core → Tracked proposals: supports review (evidence: `packages/docx/src/yrs/proposalGeometry.ts`)
- Editor user → XLSX React editor: edits workbook (evidence: `README.md`)
- Office files → XLSX React editor: opens (evidence: `README.md`)
- XLSX React editor → XLSX commands: dispatches commands (evidence: `packages/xlsx-react/src/commands/useWorkerXlsxCommands.ts`)
- XLSX React editor → XLSX engine: edits and renders (evidence: `README.md`)
- XLSX engine → Formula calculation: calculates formulas
- Editor user → PPTX React editor: edits slides (evidence: `README.md`)
- Office files → PPTX React editor: opens (evidence: `README.md`)
- PPTX React editor → PPTX engine: edits and renders (evidence: `README.md`)
- Office files → VSDX source preview: previews source (evidence: `README.md`)
- Collaborators → React editors: collaborate in (evidence: `README.md`)
- React editors → Collaboration relay: syncs updates
- Collaboration relay → Collaborators: relays updates
- Editor user → Rust APIs: automates with (evidence: `README.md`)
- Editor user → Python APIs: automates with (evidence: `README.md`)
- Rust APIs → Office files: opens and saves (evidence: `README.md`)
- Python APIs → Office files: opens and saves (evidence: `README.md`)
