# edrlab/thorium-web architecture

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

- Interactive diagram: https://gitdiagram.com/edrlab/thorium-web
- Repository: https://github.com/edrlab/thorium-web

## Overview

Thorium Web is a Next.js digital-publication reader and reusable React reader package. The app presents a publication library, opens a publication, initializes a format-specific reader and navigation, then lets readers navigate and adjust reading preferences. Its broader documented customization and accessibility capabilities are represented alongside that workflow. The graph includes state, preferences, plugins, audio, and reader UI subsystems; several links for unsampled format readers and route behavior are documented or inferred only at a broad level, so uncertain links are dashed.

Main entry points: [`src/components/Reader/StatefulReaderWrapper.tsx`](https://github.com/edrlab/thorium-web/blob/develop/src/components/Reader/StatefulReaderWrapper.tsx) (Reader wrapper), [`src/core/Navigator/hooks/useNavigatorContext.ts`](https://github.com/edrlab/thorium-web/blob/develop/src/core/Navigator/hooks/useNavigatorContext.ts) (Navigator context), [`src/app/read/[identifier]/page.tsx`](https://github.com/edrlab/thorium-web/blob/develop/src/app/read/%5Bidentifier%5D/page.tsx) (Reader), [`src/components/Epub/StatefulReader.tsx`](https://github.com/edrlab/thorium-web/blob/develop/src/components/Epub/StatefulReader.tsx) (EPUB reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and loading"]
  node_reader["Reader<br/>[page.tsx]"]
  node_library["Publication library<br/>[page.tsx]"]
end

subgraph group_formats["Publication formats"]
  node_pubhook["Publication loading<br/>[usePublication.ts]"]
  node_wrapper["Reader wrapper"]
  node_epub["EPUB reader<br/>[StatefulReader.tsx]"]
  node_webpub["WebPub reader<br/>[StatefulReader.tsx]"]
  node_divina["Divina reader<br/>[StatefulReader.tsx]"]
  node_audio["Audio player<br/>[StatefulPlayer.tsx]"]
end

subgraph group_reading["Reading experience"]
  node_navctx["Navigator context"]
  node_epubnav["EPUB navigation"]
  node_webnav["WebPub navigation"]
  node_divnav["Divina navigation"]
  node_audnav["Audio navigation"]
  node_actions["Reader actions"]
  node_settingsui["Reading settings"]
  node_theme["Themes and accessibility<br/>[useTheming.ts]"]
  node_docking["Docking layout<br/>[useDocking.ts]"]
end

subgraph group_state["State and preferences"]
  node_redux[("Reader state<br/>[store.ts]")]
  node_readerreducer["Reader state reducer<br/>[readerReducer.ts]"]
  node_preferences["Preferences context"]
  node_position["Position persistence"]
  node_localstorage[("Browser storage<br/>[useLocalStorage.ts]")]
end

subgraph group_extensions["Plugins and integrations"]
  node_plugins["Plugin registry<br/>[PluginRegistry.ts]"]
  node_manifest["Manifest verification<br/>[verifyManifest.ts]"]
  node_proxy["Resource proxy<br/>[route.ts]"]
  node_fontservices["Font resources<br/>[fonts.ts]"]
end

node_user(("Reader"))
node_readium{{"Readium libraries"}}

node_user -->|"opens library"| node_library
node_user -.->|"opens publication"| node_reader
node_library -.->|"selects publication"| node_reader
node_reader -.->|"loads publication"| node_pubhook
node_reader -.->|"renders reader"| node_wrapper
node_wrapper -.->|"selects format"| node_epub
node_wrapper -.->|"selects format"| node_webpub
node_wrapper -.->|"selects format"| node_divina
node_wrapper -.->|"selects format"| node_audio
node_epub -->|"initializes navigation"| node_navctx
node_webpub -->|"initializes navigation"| node_navctx
node_navctx -->|"uses navigator"| node_epubnav
node_navctx -->|"uses navigator"| node_webnav
node_navctx -->|"uses navigator"| node_divnav
node_navctx -->|"uses navigator"| node_audnav
node_epub -.->|"renders publication"| node_readium
node_webpub -.->|"renders publication"| node_readium
node_actions -->|"resolves actions"| node_plugins
node_actions -.->|"uses docking"| node_docking
node_settingsui -->|"reads preferences"| node_preferences
node_settingsui -->|"dispatches settings"| node_redux
node_theme -.->|"applies theme"| node_preferences
node_theme -->|"fetches cover"| node_proxy
node_epub -->|"loads fonts"| node_fontservices
node_webpub -->|"loads fonts"| node_fontservices
node_reader -.->|"verifies manifest"| node_manifest
node_redux -.->|"registers reducer"| node_readerreducer
node_wrapper -->|"persists position"| node_position
node_position -->|"stores position"| node_localstorage

click node_reader "https://github.com/edrlab/thorium-web/blob/develop/src/app/read/%5Bidentifier%5D/page.tsx"
click node_library "https://github.com/edrlab/thorium-web/blob/develop/src/app/page.tsx"
click node_pubhook "https://github.com/edrlab/thorium-web/blob/develop/src/hooks/usePublication.ts"
click node_wrapper "https://github.com/edrlab/thorium-web/blob/develop/src/components/Reader/StatefulReaderWrapper.tsx"
click node_epub "https://github.com/edrlab/thorium-web/blob/develop/src/components/Epub/StatefulReader.tsx"
click node_webpub "https://github.com/edrlab/thorium-web/blob/develop/src/components/WebPub/StatefulReader.tsx"
click node_divina "https://github.com/edrlab/thorium-web/blob/develop/src/components/Divina/StatefulReader.tsx"
click node_audio "https://github.com/edrlab/thorium-web/blob/develop/src/components/Audio/StatefulPlayer.tsx"
click node_navctx "https://github.com/edrlab/thorium-web/blob/develop/src/core/Navigator/hooks/useNavigatorContext.ts"
click node_epubnav "https://github.com/edrlab/thorium-web/blob/develop/src/core/Hooks/Epub/useEpubNavigator.ts"
click node_webnav "https://github.com/edrlab/thorium-web/blob/develop/src/core/Hooks/WebPub/useWebPubNavigator.ts"
click node_divnav "https://github.com/edrlab/thorium-web/blob/develop/src/core/Hooks/Divina/useDivinaNavigator.ts"
click node_audnav "https://github.com/edrlab/thorium-web/blob/develop/src/core/Hooks/Audio/useAudioNavigator.ts"
click node_actions "https://github.com/edrlab/thorium-web/blob/develop/src/components/Actions/StatefulCollapsibleActionsBar.tsx"
click node_settingsui "https://github.com/edrlab/thorium-web/blob/develop/src/components/Settings/Spacing/hooks/useSpacingPresets.ts"
click node_theme "https://github.com/edrlab/thorium-web/blob/develop/src/preferences/hooks/useTheming.ts"
click node_docking "https://github.com/edrlab/thorium-web/blob/develop/src/components/Docking/hooks/useDocking.ts"
click node_plugins "https://github.com/edrlab/thorium-web/blob/develop/src/components/Plugins/PluginRegistry.ts"
click node_manifest "https://github.com/edrlab/thorium-web/blob/develop/src/next-lib/helpers/verifyManifest.ts"
click node_proxy "https://github.com/edrlab/thorium-web/blob/develop/src/app/api/proxy/route.ts"
click node_redux "https://github.com/edrlab/thorium-web/blob/develop/src/lib/store.ts"
click node_readerreducer "https://github.com/edrlab/thorium-web/blob/develop/src/lib/readerReducer.ts"
click node_preferences "https://github.com/edrlab/thorium-web/blob/develop/src/preferences/ThPreferencesContext.ts"
click node_position "https://github.com/edrlab/thorium-web/blob/develop/src/hooks/usePositionStorage.ts"
click node_localstorage "https://github.com/edrlab/thorium-web/blob/develop/src/core/Hooks/useLocalStorage.ts"
click node_fontservices "https://github.com/edrlab/thorium-web/blob/develop/src/preferences/services/fonts.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_reader,node_library toneBlue
class node_pubhook,node_wrapper,node_epub,node_webpub,node_divina,node_audio toneAmber
class node_navctx,node_epubnav,node_webnav,node_divnav,node_audnav,node_actions,node_settingsui,node_theme,node_docking toneMint
class node_redux,node_readerreducer,node_preferences,node_position,node_localstorage toneRose
class node_plugins,node_manifest,node_proxy,node_fontservices,node_user,node_readium toneIndigo
```

## Components

### App and loading

- [Reader](https://github.com/edrlab/thorium-web/blob/develop/src/app/read/%5Bidentifier%5D/page.tsx): `src/app/read/[identifier]/page.tsx`
- [Publication library](https://github.com/edrlab/thorium-web/blob/develop/src/app/page.tsx): `src/app/page.tsx`

### Publication formats

- [Publication loading](https://github.com/edrlab/thorium-web/blob/develop/src/hooks/usePublication.ts): `src/hooks/usePublication.ts`
- [Reader wrapper](https://github.com/edrlab/thorium-web/blob/develop/src/components/Reader/StatefulReaderWrapper.tsx): `src/components/Reader/StatefulReaderWrapper.tsx`
- [EPUB reader](https://github.com/edrlab/thorium-web/blob/develop/src/components/Epub/StatefulReader.tsx): `src/components/Epub/StatefulReader.tsx`
- [WebPub reader](https://github.com/edrlab/thorium-web/blob/develop/src/components/WebPub/StatefulReader.tsx): `src/components/WebPub/StatefulReader.tsx`
- [Divina reader](https://github.com/edrlab/thorium-web/blob/develop/src/components/Divina/StatefulReader.tsx): `src/components/Divina/StatefulReader.tsx`
- [Audio player](https://github.com/edrlab/thorium-web/blob/develop/src/components/Audio/StatefulPlayer.tsx): `src/components/Audio/StatefulPlayer.tsx`

### Reading experience

- [Navigator context](https://github.com/edrlab/thorium-web/blob/develop/src/core/Navigator/hooks/useNavigatorContext.ts): `src/core/Navigator/hooks/useNavigatorContext.ts`
- [EPUB navigation](https://github.com/edrlab/thorium-web/blob/develop/src/core/Hooks/Epub/useEpubNavigator.ts): `src/core/Hooks/Epub/useEpubNavigator.ts`
- [WebPub navigation](https://github.com/edrlab/thorium-web/blob/develop/src/core/Hooks/WebPub/useWebPubNavigator.ts): `src/core/Hooks/WebPub/useWebPubNavigator.ts`
- [Divina navigation](https://github.com/edrlab/thorium-web/blob/develop/src/core/Hooks/Divina/useDivinaNavigator.ts): `src/core/Hooks/Divina/useDivinaNavigator.ts`
- [Audio navigation](https://github.com/edrlab/thorium-web/blob/develop/src/core/Hooks/Audio/useAudioNavigator.ts): `src/core/Hooks/Audio/useAudioNavigator.ts`
- [Reader actions](https://github.com/edrlab/thorium-web/blob/develop/src/components/Actions/StatefulCollapsibleActionsBar.tsx): `src/components/Actions/StatefulCollapsibleActionsBar.tsx`
- [Reading settings](https://github.com/edrlab/thorium-web/blob/develop/src/components/Settings/Spacing/hooks/useSpacingPresets.ts): `src/components/Settings/Spacing/hooks/useSpacingPresets.ts`
- [Themes and accessibility](https://github.com/edrlab/thorium-web/blob/develop/src/preferences/hooks/useTheming.ts): `src/preferences/hooks/useTheming.ts`
- [Docking layout](https://github.com/edrlab/thorium-web/blob/develop/src/components/Docking/hooks/useDocking.ts): `src/components/Docking/hooks/useDocking.ts`

### State and preferences

- [Reader state](https://github.com/edrlab/thorium-web/blob/develop/src/lib/store.ts): `src/lib/store.ts`
- [Reader state reducer](https://github.com/edrlab/thorium-web/blob/develop/src/lib/readerReducer.ts): `src/lib/readerReducer.ts`
- [Preferences context](https://github.com/edrlab/thorium-web/blob/develop/src/preferences/ThPreferencesContext.ts): `src/preferences/ThPreferencesContext.ts`
- [Position persistence](https://github.com/edrlab/thorium-web/blob/develop/src/hooks/usePositionStorage.ts): `src/hooks/usePositionStorage.ts`
- [Browser storage](https://github.com/edrlab/thorium-web/blob/develop/src/core/Hooks/useLocalStorage.ts): `src/core/Hooks/useLocalStorage.ts`

### Plugins and integrations

- [Plugin registry](https://github.com/edrlab/thorium-web/blob/develop/src/components/Plugins/PluginRegistry.ts): `src/components/Plugins/PluginRegistry.ts`
- [Manifest verification](https://github.com/edrlab/thorium-web/blob/develop/src/next-lib/helpers/verifyManifest.ts): `src/next-lib/helpers/verifyManifest.ts`
- [Resource proxy](https://github.com/edrlab/thorium-web/blob/develop/src/app/api/proxy/route.ts): `src/app/api/proxy/route.ts`
- [Font resources](https://github.com/edrlab/thorium-web/blob/develop/src/preferences/services/fonts.ts): `src/preferences/services/fonts.ts`

### Other components

- **Reader**
- **Readium libraries**

## Connections

- Reader → Publication library: opens library
- Reader → Reader: opens publication
- Publication library → Reader: selects publication
- Reader → Publication loading: loads publication
- Reader → Reader wrapper: renders reader
- Reader wrapper → EPUB reader: selects format
- Reader wrapper → WebPub reader: selects format
- Reader wrapper → Divina reader: selects format
- Reader wrapper → Audio player: selects format
- EPUB reader → Navigator context: initializes navigation
- WebPub reader → Navigator context: initializes navigation
- Navigator context → EPUB navigation: uses navigator (evidence: `src/core/Navigator/hooks/useNavigatorContext.ts`)
- Navigator context → WebPub navigation: uses navigator (evidence: `src/core/Navigator/hooks/useNavigatorContext.ts`)
- Navigator context → Divina navigation: uses navigator (evidence: `src/core/Navigator/hooks/useNavigatorContext.ts`)
- Navigator context → Audio navigation: uses navigator (evidence: `src/core/Navigator/hooks/useNavigatorContext.ts`)
- EPUB reader → Readium libraries: renders publication
- WebPub reader → Readium libraries: renders publication
- Reader actions → Plugin registry: resolves actions
- Reader actions → Docking layout: uses docking
- Reading settings → Preferences context: reads preferences (evidence: `src/components/Settings/Spacing/hooks/useSpacingPresets.ts`)
- Reading settings → Reader state: dispatches settings (evidence: `src/components/Settings/Spacing/hooks/useSpacingPresets.ts`)
- Themes and accessibility → Preferences context: applies theme
- Themes and accessibility → Resource proxy: fetches cover (evidence: `src/preferences/hooks/useTheming.ts`)
- EPUB reader → Font resources: loads fonts
- WebPub reader → Font resources: loads fonts
- Reader → Manifest verification: verifies manifest
- Reader state → Reader state reducer: registers reducer
- Reader wrapper → Position persistence: persists position (evidence: `src/hooks/usePositionStorage.ts`)
- Position persistence → Browser storage: stores position (evidence: `src/hooks/usePositionStorage.ts`)
