# cnwxi/epub_tool_rust architecture

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

- Interactive diagram: https://gitdiagram.com/cnwxi/epub_tool_rust
- Repository: https://github.com/cnwxi/epub_tool_rust

## Overview

Epub Tool Rust is a desktop and Android EPUB batch-processing app. Users select or import EPUBs, choose a task and its options, run processing, then review results and export or open outputs. The frontend communicates with a Tauri Rust shell through task and file commands; the shell adapts requests to a shared, in-process Rust core. The README documents the core’s EPUB, font/OCR, image, cover, and Chinese-conversion capabilities. The shared core is an external dependency, and unsampled command/runtime details are represented only where the README or sampled code supports them.

Main entry points: [`frontend/src/composables/useTaskBridge.ts`](https://github.com/cnwxi/epub_tool_rust/blob/main/frontend/src/composables/useTaskBridge.ts) (Task bridge), [`src-tauri/src/commands/tasks.rs`](https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/commands/tasks.rs) (Task commands), [`src-tauri/src/app.rs`](https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/app.rs) (Tauri app), [`frontend/src/App.vue`](https://github.com/cnwxi/epub_tool_rust/blob/main/frontend/src/App.vue) (Task interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_app["Task interface<br/>[App.vue]"]
  node_bridge["Task bridge<br/>[useTaskBridge.ts]"]
  node_persistent["Persistent settings"]
end

subgraph group_shell["Tauri Shell"]
  node_protocol["IPC contract<br/>[engine.proto]"]
  node_app_shell["Tauri app<br/>[app.rs]"]
  node_task_commands["Task commands<br/>[tasks.rs]"]
  node_file_commands["File commands<br/>[files.rs]"]
  node_state_commands["State commands<br/>[state.rs]"]
  node_engine_commands["Engine status<br/>[engine.rs]"]
end

subgraph group_runtime["Rust Runtime"]
  node_adapter["Protocol adapter<br/>[engine_adapter.rs]"]
  node_engine["In-process engine<br/>[engine.rs]"]
  node_platform_files["Platform file access<br/>[files.rs]"]
  node_resources_runtime["Resource setup<br/>[resources.rs]"]
end

subgraph group_processing["EPUB Processing"]
  node_core["EPUB task core"]
  node_font_pipeline["Font and OCR"]
  node_epub_tasks["EPUB transformations"]
  node_image_tasks["Image and covers"]
  node_chinese["Chinese conversion"]
  node_output["EPUB outputs"]
end

subgraph group_resources["Bundled Resources"]
  node_ocr_models["ONNX OCR models"]
  node_opencc_data["OpenCC data"]
  node_opencc_service["OpenCC"]
end

node_user(("App user"))

node_user -->|"configures tasks"| node_app
node_app -->|"requests operations"| node_bridge
node_app -->|"persists settings"| node_persistent
node_bridge -->|"invokes tasks"| node_task_commands
node_bridge -->|"invokes file actions"| node_file_commands
node_bridge -->|"loads and saves"| node_state_commands
node_bridge -->|"reads status"| node_engine_commands
node_bridge -->|"uses contract"| node_protocol
node_app_shell -->|"registers commands"| node_task_commands
node_app_shell -->|"registers commands"| node_file_commands
node_app_shell -->|"registers commands"| node_state_commands
node_app_shell -->|"registers commands"| node_engine_commands
node_task_commands -->|"validates wire types"| node_protocol
node_task_commands -->|"converts request and events"| node_adapter
node_task_commands -->|"executes task"| node_engine
node_task_commands -->|"streams task events"| node_bridge
node_engine_commands -->|"reads status"| node_engine
node_file_commands -->|"uses file access"| node_platform_files
node_state_commands -->|"uses managed store"| node_app_shell
node_engine -->|"runs task"| node_core
node_core -->|"performs font tasks"| node_font_pipeline
node_core -->|"performs EPUB tasks"| node_epub_tasks
node_core -->|"performs image tasks"| node_image_tasks
node_core -->|"converts text"| node_chinese
node_resources_runtime -->|"configures resources"| node_engine
node_resources_runtime -->|"locates models"| node_ocr_models
node_resources_runtime -->|"locates dictionaries"| node_opencc_data
node_font_pipeline -->|"uses OCR models"| node_ocr_models
node_chinese -->|"uses conversion"| node_opencc_service
node_opencc_service -->|"reads dictionaries"| node_opencc_data
node_core -->|"writes results"| node_output
node_app -->|"reviews results"| node_output

click node_app "https://github.com/cnwxi/epub_tool_rust/blob/main/frontend/src/App.vue"
click node_bridge "https://github.com/cnwxi/epub_tool_rust/blob/main/frontend/src/composables/useTaskBridge.ts"
click node_persistent "https://github.com/cnwxi/epub_tool_rust/blob/main/frontend/src/composables/usePersistentState.ts"
click node_protocol "https://github.com/cnwxi/epub_tool_rust/blob/main/proto/epub_tool/v1/engine.proto"
click node_app_shell "https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/app.rs"
click node_task_commands "https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/commands/tasks.rs"
click node_file_commands "https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/commands/files.rs"
click node_state_commands "https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/commands/state.rs"
click node_engine_commands "https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/commands/engine.rs"
click node_adapter "https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/engine_adapter.rs"
click node_engine "https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/runtime/engine.rs"
click node_platform_files "https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/runtime/files.rs"
click node_resources_runtime "https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/runtime/resources.rs"
click node_ocr_models "https://github.com/cnwxi/epub_tool_rust/tree/main/src-tauri/bundle-resources/ocr-models"
click node_opencc_data "https://github.com/cnwxi/epub_tool_rust/tree/main/src-tauri/bundle-resources/opencc"

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_persistent,node_user toneBlue
class node_protocol,node_app_shell,node_task_commands,node_file_commands,node_state_commands,node_engine_commands toneAmber
class node_adapter,node_engine,node_platform_files,node_resources_runtime toneMint
class node_core,node_font_pipeline,node_epub_tasks,node_image_tasks,node_chinese,node_output toneRose
class node_ocr_models,node_opencc_data,node_opencc_service toneIndigo
```

## Components

### Frontend

- [Task interface](https://github.com/cnwxi/epub_tool_rust/blob/main/frontend/src/App.vue): `frontend/src/App.vue`
- [Task bridge](https://github.com/cnwxi/epub_tool_rust/blob/main/frontend/src/composables/useTaskBridge.ts): `frontend/src/composables/useTaskBridge.ts`
- [Persistent settings](https://github.com/cnwxi/epub_tool_rust/blob/main/frontend/src/composables/usePersistentState.ts): `frontend/src/composables/usePersistentState.ts`

### Tauri Shell

- [IPC contract](https://github.com/cnwxi/epub_tool_rust/blob/main/proto/epub_tool/v1/engine.proto): `proto/epub_tool/v1/engine.proto`
- [Tauri app](https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/app.rs): `src-tauri/src/app.rs`
- [Task commands](https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/commands/tasks.rs): `src-tauri/src/commands/tasks.rs`
- [File commands](https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/commands/files.rs): `src-tauri/src/commands/files.rs`
- [State commands](https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/commands/state.rs): `src-tauri/src/commands/state.rs`
- [Engine status](https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/commands/engine.rs): `src-tauri/src/commands/engine.rs`

### Rust Runtime

- [Protocol adapter](https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/engine_adapter.rs): `src-tauri/src/engine_adapter.rs`
- [In-process engine](https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/runtime/engine.rs): `src-tauri/src/runtime/engine.rs`
- [Platform file access](https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/runtime/files.rs): `src-tauri/src/runtime/files.rs`
- [Resource setup](https://github.com/cnwxi/epub_tool_rust/blob/main/src-tauri/src/runtime/resources.rs): `src-tauri/src/runtime/resources.rs`

### EPUB Processing

- **EPUB task core**
- **Font and OCR**
- **EPUB transformations**
- **Image and covers**
- **Chinese conversion**
- **EPUB outputs**

### Bundled Resources

- [ONNX OCR models](https://github.com/cnwxi/epub_tool_rust/tree/main/src-tauri/bundle-resources/ocr-models): `src-tauri/bundle-resources/ocr-models`
- [OpenCC data](https://github.com/cnwxi/epub_tool_rust/tree/main/src-tauri/bundle-resources/opencc): `src-tauri/bundle-resources/opencc`
- **OpenCC**

### Other components

- **App user**

## Connections

- App user → Task interface: configures tasks
- Task interface → Task bridge: requests operations
- Task interface → Persistent settings: persists settings
- Task bridge → Task commands: invokes tasks
- Task bridge → File commands: invokes file actions
- Task bridge → State commands: loads and saves
- Task bridge → Engine status: reads status
- Task bridge → IPC contract: uses contract
- Tauri app → Task commands: registers commands
- Tauri app → File commands: registers commands
- Tauri app → State commands: registers commands
- Tauri app → Engine status: registers commands
- Task commands → IPC contract: validates wire types
- Task commands → Protocol adapter: converts request and events
- Task commands → In-process engine: executes task
- Task commands → Task bridge: streams task events
- Engine status → In-process engine: reads status
- File commands → Platform file access: uses file access
- State commands → Tauri app: uses managed store
- In-process engine → EPUB task core: runs task
- EPUB task core → Font and OCR: performs font tasks
- EPUB task core → EPUB transformations: performs EPUB tasks
- EPUB task core → Image and covers: performs image tasks
- EPUB task core → Chinese conversion: converts text
- Resource setup → In-process engine: configures resources
- Resource setup → ONNX OCR models: locates models
- Resource setup → OpenCC data: locates dictionaries
- Font and OCR → ONNX OCR models: uses OCR models
- Chinese conversion → OpenCC: uses conversion
- OpenCC → OpenCC data: reads dictionaries
- EPUB task core → EPUB outputs: writes results
- Task interface → EPUB outputs: reviews results
