# uurtech/jdf architecture

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

- Interactive diagram: https://gitdiagram.com/uurtech/jdf
- Repository: https://github.com/uurtech/jdf

## Overview

JDF is a JSON document format with three product surfaces: a desktop reader/editor, an embeddable JavaScript viewer, and a CLI supporting conversion, validation, and retrieval-oriented processing. The main user workflow is opening or converting a document, rendering and editing its structure, then saving it; the CLI adds PDF/Markdown/JSON import and chunking, embedding, transcription, and description workflows. Edges are limited to README statements and relationships visible in the supplied excerpts or SOURCE INDEX; unsampled implementation details are not asserted.

Main entry points: [`apps/reader/src/App.tsx`](https://github.com/uurtech/jdf/blob/master/apps/reader/src/App.tsx) (Reader application), [`tools/jdf-cli/src/index.ts`](https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/index.ts) (CLI command dispatcher), [`tools/jdf-cli/src/commands/rag.ts`](https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/rag.ts) (RAG workflow), [`tools/jdf-cli/src/commands/transcribe.ts`](https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/transcribe.ts) (Media transcription)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_format["Document format"]
  node_core["JDF types and defaults<br/>[types.ts]"]
  node_manifest["JDFX manifest<br/>[manifest.ts]"]
end

subgraph group_reader["Desktop reader"]
  node_desktop["Reader application<br/>[App.tsx]"]
  node_fs["File access<br/>[fs.ts]"]
  node_guard["Document normalization<br/>[docGuard.ts]"]
  node_edit["Edit mutations<br/>[mutations.ts]"]
  node_history["Undo and redo<br/>[history.ts]"]
  node_docview["Document rendering<br/>[DocumentViewer.tsx]"]
  node_toolbar["Editing toolbar<br/>[Toolbar.tsx]"]
  node_search["Document search<br/>[SearchPanel.tsx]"]
  node_jsonview["JSON editor<br/>[JsonViewer.tsx]"]
  node_mdview["Markdown editing and preview<br/>[MarkdownViewer.tsx]"]
end

subgraph group_web["Web viewer"]
  node_webentry["Web embed entry<br/>[auto-init.ts]"]
  node_webviewer["Web document viewer<br/>[viewer.ts]"]
  node_element["Element renderer<br/>[element.ts]"]
  node_style["Style resolution<br/>[style.ts]"]
end

subgraph group_import["Document import"]
  node_pdfimport["PDF conversion<br/>[core.ts]"]
  node_paragraphs["Paragraph folding<br/>[paragraphs.ts]"]
  node_tables["PDF table extraction<br/>[tables.ts]"]
  node_mdimport["Markdown image preprocessing<br/>[markdownImages.ts]"]
end

subgraph group_cli["CLI and retrieval"]
  node_cli["CLI command dispatcher<br/>[index.ts]"]
  node_validate["Document validation<br/>[validate.ts]"]
  node_importmd["Markdown conversion<br/>[import-md.ts]"]
  node_importpdf["PDF conversion command<br/>[import-pdf.ts]"]
  node_importjson["JSON conversion<br/>[import-json.ts]"]
  node_chunk["Retrieval chunking<br/>[chunk.ts]"]
  node_embed["Vector embedding<br/>[embed.ts]"]
  node_transcribe["Media transcription<br/>[transcribe.ts]"]
  node_describe["Media description<br/>[describe.ts]"]
  node_rag["RAG workflow<br/>[rag.ts]"]
  node_jdfx["JDFX bundle handling<br/>[jdfx.ts]"]
end

node_user(("Document user"))
node_embeddingservice(("Embedding provider"))
node_ocrservice(("OCR and caption providers"))

node_user -->|"opens and edits"| node_desktop
node_desktop -->|"reads and saves"| node_fs
node_desktop -->|"normalizes"| node_guard
node_desktop -->|"applies changes"| node_edit
node_desktop -.->|"tracks edits"| node_history
node_desktop -->|"renders documents"| node_docview
node_desktop -->|"shows controls"| node_toolbar
node_desktop -->|"provides search"| node_search
node_desktop -->|"shows JSON"| node_jsonview
node_desktop -->|"opens Markdown"| node_mdview
node_desktop -->|"imports PDF"| node_pdfimport
node_desktop -->|"preprocesses images"| node_mdimport
node_desktop -.->|"uses document model"| node_core
node_pdfimport -->|"extracts tables"| node_tables
node_pdfimport -->|"folds paragraphs"| node_paragraphs
node_user -->|"embeds viewer"| node_webentry
node_webentry -->|"initializes"| node_webviewer
node_webviewer -->|"renders elements"| node_element
node_webviewer -->|"resolves styles"| node_style
node_user -->|"runs commands"| node_cli
node_cli -->|"dispatches validation"| node_validate
node_cli -->|"dispatches conversion"| node_importmd
node_cli -->|"dispatches conversion"| node_importpdf
node_cli -->|"dispatches conversion"| node_importjson
node_cli -->|"dispatches chunking"| node_chunk
node_cli -->|"dispatches embedding"| node_embed
node_cli -->|"dispatches transcription"| node_transcribe
node_cli -->|"dispatches description"| node_describe
node_cli -->|"dispatches RAG"| node_rag
node_rag -->|"transcribes media"| node_transcribe
node_rag -->|"describes media"| node_describe
node_rag -->|"creates vectors"| node_embed
node_rag -->|"creates chunks"| node_chunk
node_embed -.->|"requests vectors"| node_embeddingservice
node_describe -.->|"uses providers"| node_ocrservice
node_transcribe -.->|"uses provider"| node_ocrservice
node_importmd -->|"packages assets"| node_jdfx
node_describe -->|"handles bundles"| node_jdfx
node_transcribe -->|"handles bundles"| node_jdfx

click node_core "https://github.com/uurtech/jdf/blob/master/packages/jdf-core/src/types.ts"
click node_manifest "https://github.com/uurtech/jdf/blob/master/packages/jdf-core/src/manifest.ts"
click node_desktop "https://github.com/uurtech/jdf/blob/master/apps/reader/src/App.tsx"
click node_fs "https://github.com/uurtech/jdf/blob/master/apps/reader/src/lib/fs.ts"
click node_guard "https://github.com/uurtech/jdf/blob/master/apps/reader/src/lib/docGuard.ts"
click node_edit "https://github.com/uurtech/jdf/blob/master/apps/reader/src/edit/mutations.ts"
click node_history "https://github.com/uurtech/jdf/blob/master/apps/reader/src/edit/history.ts"
click node_docview "https://github.com/uurtech/jdf/blob/master/apps/reader/src/components/viewer/DocumentViewer.tsx"
click node_toolbar "https://github.com/uurtech/jdf/blob/master/apps/reader/src/components/shared/Toolbar.tsx"
click node_search "https://github.com/uurtech/jdf/blob/master/apps/reader/src/components/shared/SearchPanel.tsx"
click node_jsonview "https://github.com/uurtech/jdf/blob/master/apps/reader/src/components/json/JsonViewer.tsx"
click node_mdview "https://github.com/uurtech/jdf/blob/master/apps/reader/src/components/markdown/MarkdownViewer.tsx"
click node_pdfimport "https://github.com/uurtech/jdf/blob/master/packages/jdf-pdf-import/src/core.ts"
click node_paragraphs "https://github.com/uurtech/jdf/blob/master/packages/jdf-pdf-import/src/paragraphs.ts"
click node_tables "https://github.com/uurtech/jdf/blob/master/packages/jdf-pdf-import/src/tables.ts"
click node_mdimport "https://github.com/uurtech/jdf/blob/master/apps/reader/src/import/markdownImages.ts"
click node_webentry "https://github.com/uurtech/jdf/blob/master/jdfjs/src/auto-init.ts"
click node_webviewer "https://github.com/uurtech/jdf/blob/master/jdfjs/src/viewer.ts"
click node_element "https://github.com/uurtech/jdf/blob/master/jdfjs/src/renderers/element.ts"
click node_style "https://github.com/uurtech/jdf/blob/master/jdfjs/src/utils/style.ts"
click node_cli "https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/index.ts"
click node_validate "https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/validate.ts"
click node_importmd "https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/import-md.ts"
click node_importpdf "https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/import-pdf.ts"
click node_importjson "https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/import-json.ts"
click node_chunk "https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/chunk.ts"
click node_embed "https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/embed.ts"
click node_transcribe "https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/transcribe.ts"
click node_describe "https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/describe.ts"
click node_rag "https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/rag.ts"
click node_jdfx "https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/jdfx.ts"

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_core,node_manifest,node_user toneBlue
class node_desktop,node_fs,node_guard,node_edit,node_history,node_docview,node_toolbar,node_search,node_jsonview,node_mdview toneAmber
class node_webentry,node_webviewer,node_element,node_style toneMint
class node_pdfimport,node_paragraphs,node_tables,node_mdimport toneRose
class node_cli,node_validate,node_importmd,node_importpdf,node_importjson,node_chunk,node_embed,node_transcribe,node_describe,node_rag,node_jdfx,node_embeddingservice,node_ocrservice toneIndigo
```

## Components

### Document format

- [JDF types and defaults](https://github.com/uurtech/jdf/blob/master/packages/jdf-core/src/types.ts): `packages/jdf-core/src/types.ts`
- [JDFX manifest](https://github.com/uurtech/jdf/blob/master/packages/jdf-core/src/manifest.ts): `packages/jdf-core/src/manifest.ts`

### Desktop reader

- [Reader application](https://github.com/uurtech/jdf/blob/master/apps/reader/src/App.tsx): `apps/reader/src/App.tsx`
- [File access](https://github.com/uurtech/jdf/blob/master/apps/reader/src/lib/fs.ts): `apps/reader/src/lib/fs.ts`
- [Document normalization](https://github.com/uurtech/jdf/blob/master/apps/reader/src/lib/docGuard.ts): `apps/reader/src/lib/docGuard.ts`
- [Edit mutations](https://github.com/uurtech/jdf/blob/master/apps/reader/src/edit/mutations.ts): `apps/reader/src/edit/mutations.ts`
- [Undo and redo](https://github.com/uurtech/jdf/blob/master/apps/reader/src/edit/history.ts): `apps/reader/src/edit/history.ts`
- [Document rendering](https://github.com/uurtech/jdf/blob/master/apps/reader/src/components/viewer/DocumentViewer.tsx): `apps/reader/src/components/viewer/DocumentViewer.tsx`
- [Editing toolbar](https://github.com/uurtech/jdf/blob/master/apps/reader/src/components/shared/Toolbar.tsx): `apps/reader/src/components/shared/Toolbar.tsx`
- [Document search](https://github.com/uurtech/jdf/blob/master/apps/reader/src/components/shared/SearchPanel.tsx): `apps/reader/src/components/shared/SearchPanel.tsx`
- [JSON editor](https://github.com/uurtech/jdf/blob/master/apps/reader/src/components/json/JsonViewer.tsx): `apps/reader/src/components/json/JsonViewer.tsx`
- [Markdown editing and preview](https://github.com/uurtech/jdf/blob/master/apps/reader/src/components/markdown/MarkdownViewer.tsx): `apps/reader/src/components/markdown/MarkdownViewer.tsx`

### Web viewer

- [Web embed entry](https://github.com/uurtech/jdf/blob/master/jdfjs/src/auto-init.ts): `jdfjs/src/auto-init.ts`
- [Web document viewer](https://github.com/uurtech/jdf/blob/master/jdfjs/src/viewer.ts): `jdfjs/src/viewer.ts`
- [Element renderer](https://github.com/uurtech/jdf/blob/master/jdfjs/src/renderers/element.ts): `jdfjs/src/renderers/element.ts`
- [Style resolution](https://github.com/uurtech/jdf/blob/master/jdfjs/src/utils/style.ts): `jdfjs/src/utils/style.ts`

### Document import

- [PDF conversion](https://github.com/uurtech/jdf/blob/master/packages/jdf-pdf-import/src/core.ts): `packages/jdf-pdf-import/src/core.ts`
- [Paragraph folding](https://github.com/uurtech/jdf/blob/master/packages/jdf-pdf-import/src/paragraphs.ts): `packages/jdf-pdf-import/src/paragraphs.ts`
- [PDF table extraction](https://github.com/uurtech/jdf/blob/master/packages/jdf-pdf-import/src/tables.ts): `packages/jdf-pdf-import/src/tables.ts`
- [Markdown image preprocessing](https://github.com/uurtech/jdf/blob/master/apps/reader/src/import/markdownImages.ts): `apps/reader/src/import/markdownImages.ts`

### CLI and retrieval

- [CLI command dispatcher](https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/index.ts): `tools/jdf-cli/src/index.ts`
- [Document validation](https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/validate.ts): `tools/jdf-cli/src/commands/validate.ts`
- [Markdown conversion](https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/import-md.ts): `tools/jdf-cli/src/commands/import-md.ts`
- [PDF conversion command](https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/import-pdf.ts): `tools/jdf-cli/src/commands/import-pdf.ts`
- [JSON conversion](https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/import-json.ts): `tools/jdf-cli/src/commands/import-json.ts`
- [Retrieval chunking](https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/chunk.ts): `tools/jdf-cli/src/commands/chunk.ts`
- [Vector embedding](https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/embed.ts): `tools/jdf-cli/src/commands/embed.ts`
- [Media transcription](https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/transcribe.ts): `tools/jdf-cli/src/commands/transcribe.ts`
- [Media description](https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/describe.ts): `tools/jdf-cli/src/commands/describe.ts`
- [RAG workflow](https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/commands/rag.ts): `tools/jdf-cli/src/commands/rag.ts`
- [JDFX bundle handling](https://github.com/uurtech/jdf/blob/master/tools/jdf-cli/src/jdfx.ts): `tools/jdf-cli/src/jdfx.ts`

### Other components

- **Document user**
- **Embedding provider**
- **OCR and caption providers**

## Connections

- Document user → Reader application: opens and edits
- Reader application → File access: reads and saves (evidence: `apps/reader/src/App.tsx`)
- Reader application → Document normalization: normalizes (evidence: `apps/reader/src/App.tsx`)
- Reader application → Edit mutations: applies changes (evidence: `apps/reader/src/App.tsx`)
- Reader application → Undo and redo: tracks edits (evidence: `apps/reader/src/App.tsx`)
- Reader application → Document rendering: renders documents (evidence: `apps/reader/src/App.tsx`)
- Reader application → Editing toolbar: shows controls (evidence: `apps/reader/src/App.tsx`)
- Reader application → Document search: provides search (evidence: `apps/reader/src/App.tsx`)
- Reader application → JSON editor: shows JSON (evidence: `apps/reader/src/App.tsx`)
- Reader application → Markdown editing and preview: opens Markdown (evidence: `apps/reader/src/App.tsx`)
- Reader application → PDF conversion: imports PDF
- Reader application → Markdown image preprocessing: preprocesses images (evidence: `apps/reader/src/App.tsx`)
- Reader application → JDF types and defaults: uses document model
- PDF conversion → PDF table extraction: extracts tables (evidence: `packages/jdf-pdf-import/src/core.ts`)
- PDF conversion → Paragraph folding: folds paragraphs (evidence: `packages/jdf-pdf-import/src/core.ts`)
- Document user → Web embed entry: embeds viewer
- Web embed entry → Web document viewer: initializes (evidence: `jdfjs/src/auto-init.ts`)
- Web document viewer → Element renderer: renders elements (evidence: `jdfjs/src/viewer.ts`)
- Web document viewer → Style resolution: resolves styles (evidence: `jdfjs/src/viewer.ts`)
- Document user → CLI command dispatcher: runs commands
- CLI command dispatcher → Document validation: dispatches validation (evidence: `tools/jdf-cli/src/index.ts`)
- CLI command dispatcher → Markdown conversion: dispatches conversion (evidence: `tools/jdf-cli/src/index.ts`)
- CLI command dispatcher → PDF conversion command: dispatches conversion (evidence: `tools/jdf-cli/src/index.ts`)
- CLI command dispatcher → JSON conversion: dispatches conversion (evidence: `tools/jdf-cli/src/index.ts`)
- CLI command dispatcher → Retrieval chunking: dispatches chunking (evidence: `tools/jdf-cli/src/index.ts`)
- CLI command dispatcher → Vector embedding: dispatches embedding (evidence: `tools/jdf-cli/src/index.ts`)
- CLI command dispatcher → Media transcription: dispatches transcription (evidence: `tools/jdf-cli/src/index.ts`)
- CLI command dispatcher → Media description: dispatches description (evidence: `tools/jdf-cli/src/index.ts`)
- CLI command dispatcher → RAG workflow: dispatches RAG (evidence: `tools/jdf-cli/src/index.ts`)
- RAG workflow → Media transcription: transcribes media (evidence: `tools/jdf-cli/src/commands/rag.ts`)
- RAG workflow → Media description: describes media (evidence: `tools/jdf-cli/src/commands/rag.ts`)
- RAG workflow → Vector embedding: creates vectors (evidence: `tools/jdf-cli/src/commands/rag.ts`)
- RAG workflow → Retrieval chunking: creates chunks (evidence: `tools/jdf-cli/src/commands/rag.ts`)
- Vector embedding → Embedding provider: requests vectors
- Media description → OCR and caption providers: uses providers
- Media transcription → OCR and caption providers: uses provider
- Markdown conversion → JDFX bundle handling: packages assets (evidence: `tools/jdf-cli/src/commands/import-md.ts`)
- Media description → JDFX bundle handling: handles bundles (evidence: `tools/jdf-cli/src/commands/describe.ts`)
- Media transcription → JDFX bundle handling: handles bundles (evidence: `tools/jdf-cli/src/commands/transcribe.ts`)
