# vrishi6615-creator/kiwix-js architecture

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

- Interactive diagram: https://gitdiagram.com/vrishi6615-creator/kiwix-js
- Repository: https://github.com/vrishi6615-creator/kiwix-js

## Overview

Kiwix JS is an offline reader for compressed ZIM archives. The main workflow is selecting a local archive, loading and parsing it, then browsing and searching its content in the UI. The README also highlights an in-app content library, multiple storage choices, translations, and ServiceWorker mode for dynamic archives. The sampled excerpts and source index support the main UI-to-archive and storage relationships; several decoder and worker internals were not sampled, so their connections are left unasserted.

Main entry points: [`www/js/app.js`](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/app.js) (Reader UI), [`www/js/lib/abstractFilesystemAccess.js`](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/abstractFilesystemAccess.js) (Filesystem access), [`www/js/lib/uiUtil.js`](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/uiUtil.js) (UI utilities), [`www/js/lib/zimArchive.js`](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/zimArchive.js) (ZIM archive access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Reader experience"]
  node_reader["Reader UI<br/>[app.js]"]
  node_uihelpers["UI utilities<br/>[uiUtil.js]"]
  node_popovers["Article popovers<br/>[popovers.js]"]
  node_translations["UI translation<br/>[translateUI.js]"]
  node_init["App initialization<br/>[init.js]"]
end

subgraph group_archive["Archive access"]
  node_archive_loader["Archive loader"]
  node_zim_archive["ZIM archive access<br/>[zimArchive.js]"]
  node_directory_entry["Directory entries<br/>[zimDirEntry.js]"]
  node_zimfile["Archive file access<br/>[zimfile.js]"]
  node_library["Content library<br/>[kiwixLibrary.js]"]
end

subgraph group_storage["Storage and settings"]
  node_filesystem["Filesystem access"]
  node_cache[("Asset cache<br/>[cache.js]")]
  node_filecache[("File cache<br/>[filecache.js]")]
  node_settings[("Settings store<br/>[settingsStore.js]")]
end

subgraph group_decoding["Compression decoding"]
  node_xz_stream["XZ stream decoder<br/>[xz_dec_stream.c]"]
  node_lzma2["LZMA2 decoder<br/>[xz_dec_lzma2.c]"]
  node_xz_wasm["XZ WebAssembly<br/>[xzdec-wasm.js]"]
  node_xz_wrapper["XZ decoder wrapper<br/>[xzdec_wrapper.js]"]
  node_zstd_wasm["Zstandard WebAssembly<br/>[zstddec-wasm.js]"]
  node_zstd_wrapper["Zstandard wrapper<br/>[zstddec_wrapper.js]"]
end

subgraph group_platform["Platform runtime"]
  node_service_worker["Service worker<br/>[service-worker.js]"]
  node_background["Extension background"]
  node_replay_worker["Replay worker<br/>[replayWorker.js]"]
end

node_user(("Reader"))
node_archive_file["Local ZIM archive"]
node_library_service["Kiwix library"]

node_user -->|"uses"| node_reader
node_reader -->|"loads archives"| node_archive_loader
node_user -->|"selects"| node_archive_file
node_archive_file -.->|"opened through"| node_filesystem
node_archive_loader -->|"creates archive"| node_zim_archive
node_zim_archive -->|"reads archive"| node_zimfile
node_zim_archive -->|"uses entries"| node_directory_entry
node_reader -->|"uses"| node_uihelpers
node_reader -->|"uses"| node_popovers
node_reader -->|"reads settings"| node_settings
node_reader -->|"uses"| node_filesystem
node_reader -->|"translates UI"| node_translations
node_reader -->|"uses library"| node_library
node_library_service -.->|"provides listings"| node_library
node_library -->|"uses"| node_translations
node_uihelpers -->|"reads settings"| node_settings
node_uihelpers -->|"uses"| node_translations
node_filesystem -->|"uses cache"| node_cache
node_filesystem -->|"uses settings"| node_settings
node_reader -.->|"requests mode"| node_service_worker

click node_reader "https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/app.js"
click node_uihelpers "https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/uiUtil.js"
click node_popovers "https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/popovers.js"
click node_translations "https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/translateUI.js"
click node_init "https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/init.js"
click node_archive_loader "https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/zimArchiveLoader.js"
click node_zim_archive "https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/zimArchive.js"
click node_directory_entry "https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/zimDirEntry.js"
click node_zimfile "https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/zimfile.js"
click node_library "https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/kiwixLibrary.js"
click node_filesystem "https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/abstractFilesystemAccess.js"
click node_cache "https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/cache.js"
click node_filecache "https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/filecache.js"
click node_settings "https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/settingsStore.js"
click node_xz_stream "https://github.com/vrishi6615-creator/kiwix-js/blob/main/emscripten/xzdec/xz_dec_stream.c"
click node_lzma2 "https://github.com/vrishi6615-creator/kiwix-js/blob/main/emscripten/xzdec/xz_dec_lzma2.c"
click node_xz_wasm "https://github.com/vrishi6615-creator/kiwix-js/blob/main/emscripten/xzdec/xzdec-wasm.js"
click node_xz_wrapper "https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/xzdec_wrapper.js"
click node_zstd_wasm "https://github.com/vrishi6615-creator/kiwix-js/blob/main/emscripten/zstandard/zstddec-wasm.js"
click node_zstd_wrapper "https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/zstddec_wrapper.js"
click node_service_worker "https://github.com/vrishi6615-creator/kiwix-js/blob/main/service-worker.js"
click node_background "https://github.com/vrishi6615-creator/kiwix-js/blob/main/backgroundscript.js"
click node_replay_worker "https://github.com/vrishi6615-creator/kiwix-js/blob/main/replayWorker.js"

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_reader,node_uihelpers,node_popovers,node_translations,node_init toneBlue
class node_archive_loader,node_zim_archive,node_directory_entry,node_zimfile,node_library toneAmber
class node_filesystem,node_cache,node_filecache,node_settings toneMint
class node_xz_stream,node_lzma2,node_xz_wasm,node_xz_wrapper,node_zstd_wasm,node_zstd_wrapper toneRose
class node_service_worker,node_background,node_replay_worker,node_user,node_archive_file,node_library_service toneIndigo
```

## Components

### Reader experience

- [Reader UI](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/app.js): `www/js/app.js`
- [UI utilities](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/uiUtil.js): `www/js/lib/uiUtil.js`
- [Article popovers](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/popovers.js): `www/js/lib/popovers.js`
- [UI translation](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/translateUI.js): `www/js/lib/translateUI.js`
- [App initialization](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/init.js): `www/js/init.js`

### Archive access

- [Archive loader](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/zimArchiveLoader.js): `www/js/lib/zimArchiveLoader.js`
- [ZIM archive access](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/zimArchive.js): `www/js/lib/zimArchive.js`
- [Directory entries](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/zimDirEntry.js): `www/js/lib/zimDirEntry.js`
- [Archive file access](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/zimfile.js): `www/js/lib/zimfile.js`
- [Content library](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/kiwixLibrary.js): `www/js/lib/kiwixLibrary.js`

### Storage and settings

- [Filesystem access](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/abstractFilesystemAccess.js): `www/js/lib/abstractFilesystemAccess.js`
- [Asset cache](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/cache.js): `www/js/lib/cache.js`
- [File cache](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/filecache.js): `www/js/lib/filecache.js`
- [Settings store](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/settingsStore.js): `www/js/lib/settingsStore.js`

### Compression decoding

- [XZ stream decoder](https://github.com/vrishi6615-creator/kiwix-js/blob/main/emscripten/xzdec/xz_dec_stream.c): `emscripten/xzdec/xz_dec_stream.c`
- [LZMA2 decoder](https://github.com/vrishi6615-creator/kiwix-js/blob/main/emscripten/xzdec/xz_dec_lzma2.c): `emscripten/xzdec/xz_dec_lzma2.c`
- [XZ WebAssembly](https://github.com/vrishi6615-creator/kiwix-js/blob/main/emscripten/xzdec/xzdec-wasm.js): `emscripten/xzdec/xzdec-wasm.js`
- [XZ decoder wrapper](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/xzdec_wrapper.js): `www/js/lib/xzdec_wrapper.js`
- [Zstandard WebAssembly](https://github.com/vrishi6615-creator/kiwix-js/blob/main/emscripten/zstandard/zstddec-wasm.js): `emscripten/zstandard/zstddec-wasm.js`
- [Zstandard wrapper](https://github.com/vrishi6615-creator/kiwix-js/blob/main/www/js/lib/zstddec_wrapper.js): `www/js/lib/zstddec_wrapper.js`

### Platform runtime

- [Service worker](https://github.com/vrishi6615-creator/kiwix-js/blob/main/service-worker.js): `service-worker.js`
- [Extension background](https://github.com/vrishi6615-creator/kiwix-js/blob/main/backgroundscript.js): `backgroundscript.js`
- [Replay worker](https://github.com/vrishi6615-creator/kiwix-js/blob/main/replayWorker.js): `replayWorker.js`

### Other components

- **Reader**
- **Local ZIM archive**
- **Kiwix library**

## Connections

- Reader → Reader UI: uses
- Reader UI → Archive loader: loads archives (evidence: `www/js/app.js`)
- Reader → Local ZIM archive: selects
- Local ZIM archive → Filesystem access: opened through
- Archive loader → ZIM archive access: creates archive (evidence: `www/js/lib/zimArchiveLoader.js`)
- ZIM archive access → Archive file access: reads archive (evidence: `www/js/lib/zimArchive.js`)
- ZIM archive access → Directory entries: uses entries (evidence: `www/js/lib/zimArchive.js`)
- Reader UI → UI utilities: uses (evidence: `www/js/app.js`)
- Reader UI → Article popovers: uses (evidence: `www/js/app.js`)
- Reader UI → Settings store: reads settings (evidence: `www/js/app.js`)
- Reader UI → Filesystem access: uses (evidence: `www/js/app.js`)
- Reader UI → UI translation: translates UI (evidence: `www/js/app.js`)
- Reader UI → Content library: uses library (evidence: `www/js/app.js`)
- Kiwix library → Content library: provides listings
- Content library → UI translation: uses (evidence: `www/js/lib/kiwixLibrary.js`)
- UI utilities → Settings store: reads settings (evidence: `www/js/lib/uiUtil.js`)
- UI utilities → UI translation: uses (evidence: `www/js/lib/uiUtil.js`)
- Filesystem access → Asset cache: uses cache (evidence: `www/js/lib/abstractFilesystemAccess.js`)
- Filesystem access → Settings store: uses settings (evidence: `www/js/lib/abstractFilesystemAccess.js`)
- Reader UI → Service worker: requests mode
