# tanishq-kushwaha/zendoc architecture

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

- Interactive diagram: https://gitdiagram.com/tanishq-kushwaha/zendoc
- Repository: https://github.com/tanishq-kushwaha/zendoc

## Overview

ZenDoc is a private, browser-based PDF and image toolbox with local OCR, PII scanning, semantic search, natural-language commands, and peer-to-peer sharing. The main workflow is user → app/tool selection → in-browser processing → downloadable result. The graph preserves these distinct capabilities and the assistant’s supporting layers. Relationships use the README, sampled excerpts, or SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`js/app.js`](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/app.js) (App controller), [`js/tools/pdf-tools.js`](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/pdf-tools.js) (PDF operations), [`js/tools/smart-assistant.js`](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/smart-assistant.js) (Smart assistant), [`js/pdf-worker-client.js`](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/pdf-worker-client.js) (PDF worker client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App experience"]
  node_app["App controller<br/>[app.js]"]
  node_ui["Tool interface<br/>[ui.js]"]
  node_utils["File utilities<br/>[utils.js]"]
end

subgraph group_documents["Document tools"]
  node_pdf["PDF operations<br/>[pdf-tools.js]"]
  node_pdfworkerclient["PDF worker client"]
  node_pdfworker["PDF worker<br/>[pdf-worker.js]"]
  node_image["Image operations<br/>[image-tools.js]"]
  node_imagecompress["Image compression<br/>[image-compress.js]"]
  node_utility["Utility tools<br/>[utility-tools.js]"]
  node_ocr["OCR processing<br/>[ocr-tools.js]"]
end

subgraph group_ai["Local AI"]
  node_trust["TrustShield scan<br/>[trustshield.js]"]
  node_search["PDF semantic search<br/>[pdf-search.js]"]
  node_assistant["Smart assistant<br/>[smart-assistant.js]"]
  node_intent["Intent parser<br/>[intent-parser.js]"]
  node_registry["Command registry<br/>[tool-registry.js]"]
  node_chunking["Text chunking<br/>[chunking.js]"]
  node_embeddingworker["Embedding worker"]
  node_indexdb[("Assistant index<br/>[indexeddb.js]")]
end

subgraph group_sharing["Peer sharing"]
  node_ghostui["Ghost Share interface<br/>[ghost-share-ui.js]"]
  node_ghost["Ghost Share transfer<br/>[ghost-share.js]"]
end

subgraph group_runtime["Browser runtime"]
  node_pwa["Offline app support<br/>[sw.js]"]
  node_model["Local embedding model"]
end

node_user(("User"))
node_peer(("Peer device"))
node_browser(("Browser"))

node_user -->|"opens"| node_app
node_app -->|"renders tools"| node_ui
node_app -->|"dispatches PDF tools"| node_pdf
node_app -->|"dispatches image tools"| node_image
node_app -->|"dispatches utilities"| node_utility
node_app -->|"dispatches OCR"| node_ocr
node_app -->|"dispatches scans"| node_trust
node_app -->|"dispatches search"| node_search
node_app -->|"opens assistant"| node_assistant
node_app -->|"opens sharing"| node_ghostui
node_ui -.->|"collects tool input"| node_app
node_pdf -->|"delegates operations"| node_pdfworkerclient
node_pdfworkerclient -->|"sends worker jobs"| node_pdfworker
node_pdfworkerclient -->|"returns results"| node_pdf
node_ocr -->|"loads PDF pages"| node_pdf
node_trust -->|"loads PDF pages"| node_pdf
node_search -->|"loads PDF.js"| node_pdf
node_image -.->|"uses compression"| node_imagecompress
node_assistant -->|"classifies requests"| node_intent
node_assistant -->|"executes commands"| node_registry
node_assistant -->|"chunks document text"| node_chunking
node_assistant -->|"loads and saves index"| node_indexdb
node_assistant -->|"requests embeddings"| node_embeddingworker
node_registry -->|"runs PDF operations"| node_pdf
node_registry -->|"runs OCR"| node_ocr
node_search -->|"embeds paragraphs"| node_model
node_embeddingworker -.->|"loads local model"| node_model
node_ghostui -->|"controls transfer"| node_ghost
node_ghost -->|"sends files directly"| node_peer
node_app -->|"parses page ranges"| node_utils
node_browser -->|"runs offline"| node_pwa
node_app -->|"processes files locally"| node_browser

click node_app "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/app.js"
click node_ui "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/ui.js"
click node_utils "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/utils.js"
click node_pdf "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/pdf-tools.js"
click node_pdfworkerclient "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/pdf-worker-client.js"
click node_pdfworker "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/workers/pdf-worker.js"
click node_image "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/image-tools.js"
click node_imagecompress "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/lib/image-compress.js"
click node_utility "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/utility-tools.js"
click node_ocr "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/ocr-tools.js"
click node_trust "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/trustshield.js"
click node_search "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/pdf-search.js"
click node_assistant "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/smart-assistant.js"
click node_intent "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/assistant/intent-parser.js"
click node_registry "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/assistant/tool-registry.js"
click node_chunking "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/assistant/chunking.js"
click node_embeddingworker "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/workers/embedding-worker.js"
click node_indexdb "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/assistant/indexeddb.js"
click node_ghostui "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/ghost-share-ui.js"
click node_ghost "https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/ghost-share.js"
click node_pwa "https://github.com/tanishq-kushwaha/zendoc/blob/main/sw.js"
click node_model "https://github.com/tanishq-kushwaha/zendoc/tree/main/models/Xenova/all-MiniLM-L6-v2"

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_app,node_ui,node_utils,node_user,node_browser toneBlue
class node_pdf,node_pdfworkerclient,node_pdfworker,node_image,node_imagecompress,node_utility,node_ocr toneAmber
class node_trust,node_search,node_assistant,node_intent,node_registry,node_chunking,node_embeddingworker,node_indexdb toneMint
class node_ghostui,node_ghost toneRose
class node_pwa,node_model,node_peer toneIndigo
```

## Components

### App experience

- [App controller](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/app.js): `js/app.js`
- [Tool interface](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/ui.js): `js/ui.js`
- [File utilities](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/utils.js): `js/utils.js`

### Document tools

- [PDF operations](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/pdf-tools.js): `js/tools/pdf-tools.js`
- [PDF worker client](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/pdf-worker-client.js): `js/pdf-worker-client.js`
- [PDF worker](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/workers/pdf-worker.js): `js/workers/pdf-worker.js`
- [Image operations](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/image-tools.js): `js/tools/image-tools.js`
- [Image compression](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/lib/image-compress.js): `js/lib/image-compress.js`
- [Utility tools](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/utility-tools.js): `js/tools/utility-tools.js`
- [OCR processing](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/ocr-tools.js): `js/ocr-tools.js`

### Local AI

- [TrustShield scan](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/trustshield.js): `js/tools/trustshield.js`
- [PDF semantic search](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/pdf-search.js): `js/tools/pdf-search.js`
- [Smart assistant](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/smart-assistant.js): `js/tools/smart-assistant.js`
- [Intent parser](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/assistant/intent-parser.js): `js/tools/assistant/intent-parser.js`
- [Command registry](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/assistant/tool-registry.js): `js/tools/assistant/tool-registry.js`
- [Text chunking](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/assistant/chunking.js): `js/tools/assistant/chunking.js`
- [Embedding worker](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/workers/embedding-worker.js): `js/workers/embedding-worker.js`
- [Assistant index](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/assistant/indexeddb.js): `js/tools/assistant/indexeddb.js`

### Peer sharing

- [Ghost Share interface](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/ghost-share-ui.js): `js/tools/ghost-share-ui.js`
- [Ghost Share transfer](https://github.com/tanishq-kushwaha/zendoc/blob/main/js/tools/ghost-share.js): `js/tools/ghost-share.js`

### Browser runtime

- [Offline app support](https://github.com/tanishq-kushwaha/zendoc/blob/main/sw.js): `sw.js`
- [Local embedding model](https://github.com/tanishq-kushwaha/zendoc/tree/main/models/Xenova/all-MiniLM-L6-v2): `models/Xenova/all-MiniLM-L6-v2`

### Other components

- **User**
- **Peer device**
- **Browser**

## Connections

- User → App controller: opens (evidence: `README.md`)
- App controller → Tool interface: renders tools (evidence: `js/app.js`)
- App controller → PDF operations: dispatches PDF tools (evidence: `js/app.js`)
- App controller → Image operations: dispatches image tools (evidence: `js/app.js`)
- App controller → Utility tools: dispatches utilities (evidence: `js/app.js`)
- App controller → OCR processing: dispatches OCR (evidence: `js/app.js`)
- App controller → TrustShield scan: dispatches scans (evidence: `js/app.js`)
- App controller → PDF semantic search: dispatches search (evidence: `js/app.js`)
- App controller → Smart assistant: opens assistant (evidence: `js/app.js`)
- App controller → Ghost Share interface: opens sharing (evidence: `js/app.js`)
- Tool interface → App controller: collects tool input (evidence: `js/app.js`)
- PDF operations → PDF worker client: delegates operations (evidence: `js/tools/pdf-tools.js`)
- PDF worker client → PDF worker: sends worker jobs (evidence: `js/pdf-worker-client.js`)
- PDF worker client → PDF operations: returns results (evidence: `js/pdf-worker-client.js`)
- OCR processing → PDF operations: loads PDF pages (evidence: `js/ocr-tools.js`)
- TrustShield scan → PDF operations: loads PDF pages (evidence: `js/tools/trustshield.js`)
- PDF semantic search → PDF operations: loads PDF.js (evidence: `js/tools/pdf-search.js`)
- Image operations → Image compression: uses compression
- Smart assistant → Intent parser: classifies requests (evidence: `js/tools/smart-assistant.js`)
- Smart assistant → Command registry: executes commands (evidence: `js/tools/smart-assistant.js`)
- Smart assistant → Text chunking: chunks document text (evidence: `js/tools/smart-assistant.js`)
- Smart assistant → Assistant index: loads and saves index (evidence: `js/tools/smart-assistant.js`)
- Smart assistant → Embedding worker: requests embeddings (evidence: `js/tools/smart-assistant.js`)
- Command registry → PDF operations: runs PDF operations (evidence: `js/tools/assistant/tool-registry.js`)
- Command registry → OCR processing: runs OCR (evidence: `js/tools/assistant/tool-registry.js`)
- PDF semantic search → Local embedding model: embeds paragraphs (evidence: `js/tools/pdf-search.js`)
- Embedding worker → Local embedding model: loads local model
- Ghost Share interface → Ghost Share transfer: controls transfer (evidence: `js/tools/ghost-share-ui.js`)
- Ghost Share transfer → Peer device: sends files directly (evidence: `README.md`)
- App controller → File utilities: parses page ranges (evidence: `js/app.js`)
- Browser → Offline app support: runs offline (evidence: `README.md`)
- App controller → Browser: processes files locally (evidence: `README.md`)
