# szelenkov/code-djvu architecture

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

- Interactive diagram: https://gitdiagram.com/szelenkov/code-djvu
- Repository: https://github.com/szelenkov/code-djvu
- Video tour (about a minute): https://gitdiagram.com/szelenkov/code-djvu/video

## Overview

code-djvu is a read-only VS Code custom editor for local DJVU files. A user opens a .djvu file; the registered editor reads its bytes and passes them to a webview, where the vendored DjVu.js worker decodes pages and supplies rendered images and text status. The webview supports page navigation, page selection, zoom, and basic text detection; editing and saving are not supported. The source excerpts show the editor-to-webview and webview-to-decoder behavior. The README documents the product workflow and capabilities; no separate backend or persistent store is shown.

Main entry points: [`src/djvuCustomEditor.ts`](https://github.com/szelenkov/code-djvu/blob/master/src/djvuCustomEditor.ts) (Custom Editor Provider), [`media/djvu.js`](https://github.com/szelenkov/code-djvu/blob/master/media/djvu.js) (DjVu.js Worker), [`src/extension.ts`](https://github.com/szelenkov/code-djvu/blob/master/src/extension.ts) (Extension Activation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["VS Code Integration"]
  node_extension["Extension Activation<br/>[extension.ts]"]
  node_provider["Custom Editor Provider"]
  node_document["Local DJVU File"]
end

subgraph group_viewer["Viewer Interface"]
  node_webview["Viewer Controls"]
end

subgraph group_decode["Document Rendering"]
  node_worker["DjVu.js Worker<br/>[djvu.js]"]
  node_page["Rendered Page"]
end

node_user(("User"))
node_vscode["VS Code Editor Host"]

node_user -->|"opens file"| node_vscode
node_vscode -->|"routes .djvu"| node_provider
node_extension -->|"registers"| node_provider
node_provider -->|"reads bytes"| node_document
node_provider -->|"posts bytes"| node_webview
node_provider -->|"loads script"| node_worker
node_webview -->|"decodes and renders"| node_worker
node_worker -->|"provides image"| node_page

click node_extension "https://github.com/szelenkov/code-djvu/blob/master/src/extension.ts"
click node_provider "https://github.com/szelenkov/code-djvu/blob/master/src/djvuCustomEditor.ts"
click node_webview "https://github.com/szelenkov/code-djvu/blob/master/src/djvuCustomEditor.ts"
click node_worker "https://github.com/szelenkov/code-djvu/blob/master/media/djvu.js"
click node_page "https://github.com/szelenkov/code-djvu/blob/master/src/djvuCustomEditor.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_extension,node_provider,node_document,node_user toneBlue
class node_webview toneAmber
class node_worker,node_page toneMint
class node_vscode toneIndigo
```

## Components

### VS Code Integration

- [Extension Activation](https://github.com/szelenkov/code-djvu/blob/master/src/extension.ts): `src/extension.ts`
- [Custom Editor Provider](https://github.com/szelenkov/code-djvu/blob/master/src/djvuCustomEditor.ts): `src/djvuCustomEditor.ts`
- **Local DJVU File**

### Viewer Interface

- [Viewer Controls](https://github.com/szelenkov/code-djvu/blob/master/src/djvuCustomEditor.ts): `src/djvuCustomEditor.ts`

### Document Rendering

- [DjVu.js Worker](https://github.com/szelenkov/code-djvu/blob/master/media/djvu.js): `media/djvu.js`
- [Rendered Page](https://github.com/szelenkov/code-djvu/blob/master/src/djvuCustomEditor.ts): `src/djvuCustomEditor.ts`

### Other components

- **User**
- **VS Code Editor Host**

## Connections

- User → VS Code Editor Host: opens file (evidence: `README.md`)
- VS Code Editor Host → Custom Editor Provider: routes .djvu
- Extension Activation → Custom Editor Provider: registers (evidence: `src/extension.ts`)
- Custom Editor Provider → Local DJVU File: reads bytes (evidence: `src/djvuCustomEditor.ts`)
- Custom Editor Provider → Viewer Controls: posts bytes (evidence: `src/djvuCustomEditor.ts`)
- Custom Editor Provider → DjVu.js Worker: loads script (evidence: `src/djvuCustomEditor.ts`)
- Viewer Controls → DjVu.js Worker: decodes and renders (evidence: `src/djvuCustomEditor.ts`)
- DjVu.js Worker → Rendered Page: provides image (evidence: `src/djvuCustomEditor.ts`)
