# 0xh4ku/foluma architecture

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

- Interactive diagram: https://gitdiagram.com/0xh4ku/foluma
- Repository: https://github.com/0xh4ku/foluma

## Overview

Foluma is a local desktop workspace for organizing image-based books into portable series, editing page order and spreads, reviewing them, and exporting books or batches. The principal workflow runs from desktop project/import actions through the Python engine’s series and document services, then through format plugins for import or export. Editing, previews, metadata, cache management, and plugin administration are supporting branches. The excerpts show selected service, model, media, and worker behavior; several UI and plugin subsystems are represented from README capabilities and the source index, so their unshown links are omitted or marked unverified.

Main entry points: [`engine/foluma/service.py`](https://github.com/0xh4ku/foluma/blob/main/engine/foluma/service.py) (Engine service), [`engine/foluma/worker.py`](https://github.com/0xh4ku/foluma/blob/main/engine/foluma/worker.py) (Worker protocol), [`desktop/main.tsx`](https://github.com/0xh4ku/foluma/blob/main/desktop/main.tsx) (Desktop app), [`desktop/series.tsx`](https://github.com/0xh4ku/foluma/blob/main/desktop/series.tsx) (Series workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop workspace"]
  node_app["Desktop app<br/>[main.tsx]"]
  node_bridge["Host bridge<br/>[bridge.ts]"]
  node_bookui["Book workspace<br/>[document.tsx]"]
  node_seriesui["Series workspace<br/>[series.tsx]"]
  node_project["Project setup<br/>[project-wizard.tsx]"]
  node_exportui["Batch export<br/>[series-export.tsx]"]
  node_pluginui["Plugin manager<br/>[plugin-manager.tsx]"]
  node_storageui["Cache settings<br/>[storage.tsx]"]
end

subgraph group_engine["Document engine"]
  node_service["Engine service<br/>[service.py]"]
  node_series["Series state<br/>[series.py]"]
  node_model["Book model<br/>[model.py]"]
  node_storage[("Project storage<br/>[storage.py]")]
  node_media["Image processing<br/>[media.py]"]
  node_workers["Task workers<br/>[workers.py]"]
  node_worker["Worker protocol<br/>[worker.py]"]
  node_cache[("Preview cache<br/>[cache.py]")]
end

subgraph group_edit["Editing and review"]
  node_editor["Page editor<br/>[editor.tsx]"]
  node_pageops["Page operations<br/>[pages.ts]"]
  node_spreads["Spread review<br/>[spreads.ts]"]
end

subgraph group_formats["Format plugins"]
  node_pdfimport["PDF importer<br/>[importer.py]"]
  node_epubimport["EPUB importer<br/>[worker.py]"]
  node_archive["Image archive<br/>[image_archive.py]"]
  node_pdfexport["PDF exporter<br/>[worker.py]"]
  node_epubexport["EPUB exporter<br/>[exporter.py]"]
  node_cbz["CBZ import/export<br/>[worker.py]"]
end

node_user(("Reader / organizer"))

node_user -->|"uses"| node_app
node_app -->|"invokes host"| node_bridge
node_app -->|"opens workspace"| node_bookui
node_app -->|"opens series"| node_seriesui
node_user -->|"creates project"| node_project
node_project -.->|"requests setup"| node_service
node_bookui -.->|"requests document actions"| node_service
node_seriesui -.->|"requests series actions"| node_service
node_seriesui -->|"opens batch export"| node_exportui
node_exportui -.->|"requests batch export"| node_service
node_pluginui -.->|"manages plugins"| node_service
node_storageui -->|"calls storage RPC"| node_service
node_service -->|"updates series"| node_series
node_service -->|"dispatches tasks"| node_workers
node_service -->|"serves previews"| node_cache
node_service -->|"persists configuration"| node_storage
node_series -->|"saves projects"| node_storage
node_series -->|"validates books"| node_model
node_workers -->|"uses protocol"| node_worker
node_worker -->|"runs image tasks"| node_media
node_user -->|"edits pages"| node_editor
node_editor -->|"uses page operations"| node_pageops
node_editor -.->|"reviews spreads"| node_spreads
node_user -->|"imports PDF"| node_pdfimport
node_user -->|"imports EPUB"| node_epubimport
node_user -->|"imports ZIP / CBZ"| node_archive
node_pdfimport -->|"uses worker protocol"| node_worker
node_epubimport -->|"uses worker protocol"| node_worker
node_archive -->|"imports images"| node_media
node_user -->|"exports PDF"| node_pdfexport
node_user -->|"exports EPUB"| node_epubexport
node_user -->|"exports CBZ"| node_cbz
node_pdfexport -->|"uses worker protocol"| node_worker
node_epubexport -->|"uses worker protocol"| node_worker
node_cbz -->|"uses worker protocol"| node_worker

click node_app "https://github.com/0xh4ku/foluma/blob/main/desktop/main.tsx"
click node_bridge "https://github.com/0xh4ku/foluma/blob/main/desktop/bridge.ts"
click node_bookui "https://github.com/0xh4ku/foluma/blob/main/desktop/document.tsx"
click node_seriesui "https://github.com/0xh4ku/foluma/blob/main/desktop/series.tsx"
click node_project "https://github.com/0xh4ku/foluma/blob/main/desktop/project-wizard.tsx"
click node_exportui "https://github.com/0xh4ku/foluma/blob/main/desktop/series-export.tsx"
click node_pluginui "https://github.com/0xh4ku/foluma/blob/main/desktop/plugin-manager.tsx"
click node_storageui "https://github.com/0xh4ku/foluma/blob/main/desktop/storage.tsx"
click node_service "https://github.com/0xh4ku/foluma/blob/main/engine/foluma/service.py"
click node_series "https://github.com/0xh4ku/foluma/blob/main/engine/foluma/series.py"
click node_model "https://github.com/0xh4ku/foluma/blob/main/engine/foluma/model.py"
click node_storage "https://github.com/0xh4ku/foluma/blob/main/engine/foluma/storage.py"
click node_media "https://github.com/0xh4ku/foluma/blob/main/engine/foluma/media.py"
click node_workers "https://github.com/0xh4ku/foluma/blob/main/engine/foluma/workers.py"
click node_worker "https://github.com/0xh4ku/foluma/blob/main/engine/foluma/worker.py"
click node_cache "https://github.com/0xh4ku/foluma/blob/main/engine/foluma/cache.py"
click node_editor "https://github.com/0xh4ku/foluma/blob/main/plugins/editor/src/editor.tsx"
click node_pageops "https://github.com/0xh4ku/foluma/blob/main/plugins/editor/src/pages.ts"
click node_spreads "https://github.com/0xh4ku/foluma/blob/main/plugins/editor/src/spreads.ts"
click node_pdfimport "https://github.com/0xh4ku/foluma/blob/main/plugins/pdf-import/foluma_pdf/importer.py"
click node_epubimport "https://github.com/0xh4ku/foluma/blob/main/plugins/epub-import/worker.py"
click node_archive "https://github.com/0xh4ku/foluma/blob/main/plugins/image_archive.py"
click node_pdfexport "https://github.com/0xh4ku/foluma/blob/main/plugins/pdf-export/worker.py"
click node_epubexport "https://github.com/0xh4ku/foluma/blob/main/plugins/epub-export/foluma_epub/exporter.py"
click node_cbz "https://github.com/0xh4ku/foluma/blob/main/plugins/cbz-export/worker.py"

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_bridge,node_bookui,node_seriesui,node_project,node_exportui,node_pluginui,node_storageui toneBlue
class node_service,node_series,node_model,node_storage,node_media,node_workers,node_worker,node_cache toneAmber
class node_editor,node_pageops,node_spreads toneMint
class node_pdfimport,node_epubimport,node_archive,node_pdfexport,node_epubexport,node_cbz toneRose
class node_user toneIndigo
```

## Components

### Desktop workspace

- [Desktop app](https://github.com/0xh4ku/foluma/blob/main/desktop/main.tsx): `desktop/main.tsx`
- [Host bridge](https://github.com/0xh4ku/foluma/blob/main/desktop/bridge.ts): `desktop/bridge.ts`
- [Book workspace](https://github.com/0xh4ku/foluma/blob/main/desktop/document.tsx): `desktop/document.tsx`
- [Series workspace](https://github.com/0xh4ku/foluma/blob/main/desktop/series.tsx): `desktop/series.tsx`
- [Project setup](https://github.com/0xh4ku/foluma/blob/main/desktop/project-wizard.tsx): `desktop/project-wizard.tsx`
- [Batch export](https://github.com/0xh4ku/foluma/blob/main/desktop/series-export.tsx): `desktop/series-export.tsx`
- [Plugin manager](https://github.com/0xh4ku/foluma/blob/main/desktop/plugin-manager.tsx): `desktop/plugin-manager.tsx`
- [Cache settings](https://github.com/0xh4ku/foluma/blob/main/desktop/storage.tsx): `desktop/storage.tsx`

### Document engine

- [Engine service](https://github.com/0xh4ku/foluma/blob/main/engine/foluma/service.py): `engine/foluma/service.py`
- [Series state](https://github.com/0xh4ku/foluma/blob/main/engine/foluma/series.py): `engine/foluma/series.py`
- [Book model](https://github.com/0xh4ku/foluma/blob/main/engine/foluma/model.py): `engine/foluma/model.py`
- [Project storage](https://github.com/0xh4ku/foluma/blob/main/engine/foluma/storage.py): `engine/foluma/storage.py`
- [Image processing](https://github.com/0xh4ku/foluma/blob/main/engine/foluma/media.py): `engine/foluma/media.py`
- [Task workers](https://github.com/0xh4ku/foluma/blob/main/engine/foluma/workers.py): `engine/foluma/workers.py`
- [Worker protocol](https://github.com/0xh4ku/foluma/blob/main/engine/foluma/worker.py): `engine/foluma/worker.py`
- [Preview cache](https://github.com/0xh4ku/foluma/blob/main/engine/foluma/cache.py): `engine/foluma/cache.py`

### Editing and review

- [Page editor](https://github.com/0xh4ku/foluma/blob/main/plugins/editor/src/editor.tsx): `plugins/editor/src/editor.tsx`
- [Page operations](https://github.com/0xh4ku/foluma/blob/main/plugins/editor/src/pages.ts): `plugins/editor/src/pages.ts`
- [Spread review](https://github.com/0xh4ku/foluma/blob/main/plugins/editor/src/spreads.ts): `plugins/editor/src/spreads.ts`

### Format plugins

- [PDF importer](https://github.com/0xh4ku/foluma/blob/main/plugins/pdf-import/foluma_pdf/importer.py): `plugins/pdf-import/foluma_pdf/importer.py`
- [EPUB importer](https://github.com/0xh4ku/foluma/blob/main/plugins/epub-import/worker.py): `plugins/epub-import/worker.py`
- [Image archive](https://github.com/0xh4ku/foluma/blob/main/plugins/image_archive.py): `plugins/image_archive.py`
- [PDF exporter](https://github.com/0xh4ku/foluma/blob/main/plugins/pdf-export/worker.py): `plugins/pdf-export/worker.py`
- [EPUB exporter](https://github.com/0xh4ku/foluma/blob/main/plugins/epub-export/foluma_epub/exporter.py): `plugins/epub-export/foluma_epub/exporter.py`
- [CBZ import/export](https://github.com/0xh4ku/foluma/blob/main/plugins/cbz-export/worker.py): `plugins/cbz-export/worker.py`

### Other components

- **Reader / organizer**

## Connections

- Reader / organizer → Desktop app: uses (evidence: `README.md`)
- Desktop app → Host bridge: invokes host (evidence: `desktop/main.tsx`)
- Desktop app → Book workspace: opens workspace (evidence: `desktop/main.tsx`)
- Desktop app → Series workspace: opens series (evidence: `desktop/main.tsx`)
- Reader / organizer → Project setup: creates project (evidence: `README.md`)
- Project setup → Engine service: requests setup
- Book workspace → Engine service: requests document actions
- Series workspace → Engine service: requests series actions
- Series workspace → Batch export: opens batch export (evidence: `desktop/series.tsx`)
- Batch export → Engine service: requests batch export
- Plugin manager → Engine service: manages plugins
- Cache settings → Engine service: calls storage RPC (evidence: `desktop/storage.tsx`)
- Engine service → Series state: updates series (evidence: `engine/foluma/service.py`)
- Engine service → Task workers: dispatches tasks (evidence: `engine/foluma/service.py`)
- Engine service → Preview cache: serves previews (evidence: `engine/foluma/service.py`)
- Engine service → Project storage: persists configuration (evidence: `engine/foluma/service.py`)
- Series state → Project storage: saves projects (evidence: `engine/foluma/series.py`)
- Series state → Book model: validates books (evidence: `engine/foluma/series.py`)
- Task workers → Worker protocol: uses protocol (evidence: `engine/foluma/workers.py`)
- Worker protocol → Image processing: runs image tasks (evidence: `engine/foluma/worker.py`)
- Reader / organizer → Page editor: edits pages (evidence: `README.md`)
- Page editor → Page operations: uses page operations
- Page editor → Spread review: reviews spreads
- Reader / organizer → PDF importer: imports PDF (evidence: `README.md`)
- Reader / organizer → EPUB importer: imports EPUB (evidence: `README.md`)
- Reader / organizer → Image archive: imports ZIP / CBZ (evidence: `README.md`)
- PDF importer → Worker protocol: uses worker protocol (evidence: `plugins/pdf-import/worker.py`)
- EPUB importer → Worker protocol: uses worker protocol (evidence: `plugins/epub-import/worker.py`)
- Image archive → Image processing: imports images (evidence: `plugins/image_archive.py`)
- Reader / organizer → PDF exporter: exports PDF (evidence: `README.md`)
- Reader / organizer → EPUB exporter: exports EPUB (evidence: `README.md`)
- Reader / organizer → CBZ import/export: exports CBZ (evidence: `README.md`)
- PDF exporter → Worker protocol: uses worker protocol (evidence: `plugins/pdf-export/worker.py`)
- EPUB exporter → Worker protocol: uses worker protocol (evidence: `plugins/epub-export/worker.py`)
- CBZ import/export → Worker protocol: uses worker protocol (evidence: `plugins/cbz-export/worker.py`)
