# driveaway500/bookish-engine architecture

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

- Interactive diagram: https://gitdiagram.com/driveaway500/bookish-engine
- Repository: https://github.com/driveaway500/bookish-engine

## Overview

MosaicPlus is an offline-first desktop writing app: authors organize Markdown files on a visual canvas, assemble them into a manuscript, and export it; they can separately track and restore project history with Git. The graph includes the documented Structure, Book, and Versions domains, plus the frontend state/bridge and backend persistence layers. Relationships are grounded in the README or shown excerpts and SOURCE INDEX references; unsampled implementation details are represented at their supported directory paths, with uncertain links omitted.

Main entry points: [`src/backend/commands.ts`](https://github.com/driveaway500/bookish-engine/blob/master/src/backend/commands.ts) (Typed backend bridge), [`src/domains/structure/Canvas.tsx`](https://github.com/driveaway500/bookish-engine/blob/master/src/domains/structure/Canvas.tsx) (Structure canvas), [`src-tauri/src/modules/project/app.rs`](https://github.com/driveaway500/bookish-engine/blob/master/src-tauri/src/modules/project/app.rs) (Project lifecycle), [`src-tauri/src/modules/persist/worker.rs`](https://github.com/driveaway500/bookish-engine/blob/master/src-tauri/src/modules/persist/worker.rs) (Async persistence)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend shell"]
  node_app["Desktop application<br/>[App.tsx]"]
  node_picker["Project picker"]
  node_bridge["Typed backend bridge<br/>[commands.ts]"]
  node_state["Frontend state<br/>[index.ts]"]
end

subgraph group_writing["Writing domains"]
  node_structure["Structure canvas<br/>[Canvas.tsx]"]
  node_piece["Canvas pieces<br/>[Piece.tsx]"]
  node_editor["Markdown editor<br/>[EditorBody.tsx]"]
  node_book["Book assembly<br/>[Manuscript.tsx]"]
  node_reading["Reading order<br/>[ReadingOrder.tsx]"]
  node_export["Markdown/DOCX export"]
  node_versions["Versions and diffs"]
  node_gitui["Git workflows<br/>[useCommitFlow.ts]"]
end

subgraph group_project["Project services"]
  node_files["Project files<br/>[useFileOps.ts]"]
  node_markdown["Markdown rendering<br/>[markdown.tsx]"]
end

subgraph group_backend["Rust backend"]
  node_projectsvc["Project lifecycle<br/>[app.rs]"]
  node_ipc["Tauri commands/events"]
  node_store["In-memory project store"]
  node_persist["Async persistence<br/>[worker.rs]"]
  node_atomic["Atomic file writes<br/>[atomic.rs]"]
  node_canvasmeta["Canvas metadata"]
  node_gitbackend["Git operations<br/>[git2_impl.rs]"]
end

node_author(("Author"))
node_localproject["Local project folder"]
node_gitremote[("Optional Git remote")]

node_author -->|"uses"| node_app
node_app -.->|"opens projects"| node_picker
node_picker -->|"invokes commands"| node_bridge
node_bridge -->|"sends typed IPC"| node_ipc
node_author -->|"organizes pieces"| node_structure
node_structure -->|"renders"| node_piece
node_structure -->|"reads and updates"| node_state
node_author -->|"writes Markdown"| node_editor
node_author -->|"sets sequence"| node_reading
node_reading -->|"orders manuscript"| node_book
node_book -->|"renders preview"| node_markdown
node_author -->|"exports book"| node_export
node_author -->|"reviews history"| node_versions
node_author -->|"creates versions"| node_gitui
node_gitui -.->|"requests Git actions"| node_bridge
node_author -->|"manages files"| node_files
node_files -->|"updates file state"| node_state
node_state -->|"uses backend APIs"| node_bridge
node_ipc -.->|"dispatches commands"| node_projectsvc
node_projectsvc -->|"coordinates state"| node_store
node_projectsvc -->|"runs Git operations"| node_gitbackend
node_store -->|"queues disk changes"| node_persist
node_persist -->|"writes atomically"| node_atomic
node_canvasmeta -->|"stores canvas JSON"| node_localproject
node_persist -->|"persists project files"| node_localproject
node_gitbackend -->|"tracks working tree"| node_localproject
node_gitbackend -.->|"syncs optionally"| node_gitremote

click node_app "https://github.com/driveaway500/bookish-engine/blob/master/src/app/App.tsx"
click node_picker "https://github.com/driveaway500/bookish-engine/blob/master/src/hooks/useProjectPicker.ts"
click node_bridge "https://github.com/driveaway500/bookish-engine/blob/master/src/backend/commands.ts"
click node_state "https://github.com/driveaway500/bookish-engine/blob/master/src/state/index.ts"
click node_structure "https://github.com/driveaway500/bookish-engine/blob/master/src/domains/structure/Canvas.tsx"
click node_piece "https://github.com/driveaway500/bookish-engine/blob/master/src/domains/structure/Piece.tsx"
click node_editor "https://github.com/driveaway500/bookish-engine/blob/master/src/shared/editor/EditorBody.tsx"
click node_book "https://github.com/driveaway500/bookish-engine/blob/master/src/domains/book/Manuscript.tsx"
click node_reading "https://github.com/driveaway500/bookish-engine/blob/master/src/domains/book/ReadingOrder.tsx"
click node_export "https://github.com/driveaway500/bookish-engine/tree/master/src-tauri/src/modules/export"
click node_versions "https://github.com/driveaway500/bookish-engine/tree/master/src/domains/versions"
click node_gitui "https://github.com/driveaway500/bookish-engine/blob/master/src/hooks/useCommitFlow.ts"
click node_files "https://github.com/driveaway500/bookish-engine/blob/master/src/hooks/useFileOps.ts"
click node_markdown "https://github.com/driveaway500/bookish-engine/blob/master/src/lib/markdown.tsx"
click node_projectsvc "https://github.com/driveaway500/bookish-engine/blob/master/src-tauri/src/modules/project/app.rs"
click node_ipc "https://github.com/driveaway500/bookish-engine/tree/master/src-tauri/src/modules/ipc"
click node_store "https://github.com/driveaway500/bookish-engine/tree/master/src-tauri/src/modules/store"
click node_persist "https://github.com/driveaway500/bookish-engine/blob/master/src-tauri/src/modules/persist/worker.rs"
click node_atomic "https://github.com/driveaway500/bookish-engine/blob/master/src-tauri/src/modules/fs/atomic.rs"
click node_canvasmeta "https://github.com/driveaway500/bookish-engine/tree/master/src-tauri/src/modules/canvas"
click node_gitbackend "https://github.com/driveaway500/bookish-engine/blob/master/src-tauri/src/modules/git/git2_impl.rs"

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_picker,node_bridge,node_state toneBlue
class node_structure,node_piece,node_editor,node_book,node_reading,node_export,node_versions,node_gitui,node_gitremote toneAmber
class node_files,node_markdown toneMint
class node_projectsvc,node_ipc,node_store,node_persist,node_atomic,node_canvasmeta,node_gitbackend toneRose
class node_author,node_localproject toneIndigo
```

## Components

### Frontend shell

- [Desktop application](https://github.com/driveaway500/bookish-engine/blob/master/src/app/App.tsx): `src/app/App.tsx`
- [Project picker](https://github.com/driveaway500/bookish-engine/blob/master/src/hooks/useProjectPicker.ts): `src/hooks/useProjectPicker.ts`
- [Typed backend bridge](https://github.com/driveaway500/bookish-engine/blob/master/src/backend/commands.ts): `src/backend/commands.ts`
- [Frontend state](https://github.com/driveaway500/bookish-engine/blob/master/src/state/index.ts): `src/state/index.ts`

### Writing domains

- [Structure canvas](https://github.com/driveaway500/bookish-engine/blob/master/src/domains/structure/Canvas.tsx): `src/domains/structure/Canvas.tsx`
- [Canvas pieces](https://github.com/driveaway500/bookish-engine/blob/master/src/domains/structure/Piece.tsx): `src/domains/structure/Piece.tsx`
- [Markdown editor](https://github.com/driveaway500/bookish-engine/blob/master/src/shared/editor/EditorBody.tsx): `src/shared/editor/EditorBody.tsx`
- [Book assembly](https://github.com/driveaway500/bookish-engine/blob/master/src/domains/book/Manuscript.tsx): `src/domains/book/Manuscript.tsx`
- [Reading order](https://github.com/driveaway500/bookish-engine/blob/master/src/domains/book/ReadingOrder.tsx): `src/domains/book/ReadingOrder.tsx`
- [Markdown/DOCX export](https://github.com/driveaway500/bookish-engine/tree/master/src-tauri/src/modules/export): `src-tauri/src/modules/export`
- [Versions and diffs](https://github.com/driveaway500/bookish-engine/tree/master/src/domains/versions): `src/domains/versions`
- [Git workflows](https://github.com/driveaway500/bookish-engine/blob/master/src/hooks/useCommitFlow.ts): `src/hooks/useCommitFlow.ts`

### Project services

- [Project files](https://github.com/driveaway500/bookish-engine/blob/master/src/hooks/useFileOps.ts): `src/hooks/useFileOps.ts`
- [Markdown rendering](https://github.com/driveaway500/bookish-engine/blob/master/src/lib/markdown.tsx): `src/lib/markdown.tsx`

### Rust backend

- [Project lifecycle](https://github.com/driveaway500/bookish-engine/blob/master/src-tauri/src/modules/project/app.rs): `src-tauri/src/modules/project/app.rs`
- [Tauri commands/events](https://github.com/driveaway500/bookish-engine/tree/master/src-tauri/src/modules/ipc): `src-tauri/src/modules/ipc`
- [In-memory project store](https://github.com/driveaway500/bookish-engine/tree/master/src-tauri/src/modules/store): `src-tauri/src/modules/store`
- [Async persistence](https://github.com/driveaway500/bookish-engine/blob/master/src-tauri/src/modules/persist/worker.rs): `src-tauri/src/modules/persist/worker.rs`
- [Atomic file writes](https://github.com/driveaway500/bookish-engine/blob/master/src-tauri/src/modules/fs/atomic.rs): `src-tauri/src/modules/fs/atomic.rs`
- [Canvas metadata](https://github.com/driveaway500/bookish-engine/tree/master/src-tauri/src/modules/canvas): `src-tauri/src/modules/canvas`
- [Git operations](https://github.com/driveaway500/bookish-engine/blob/master/src-tauri/src/modules/git/git2_impl.rs): `src-tauri/src/modules/git/git2_impl.rs`

### Other components

- **Author**
- **Local project folder**
- **Optional Git remote**

## Connections

- Author → Desktop application: uses (evidence: `README.md`)
- Desktop application → Project picker: opens projects
- Project picker → Typed backend bridge: invokes commands (evidence: `src/hooks/useProjectPicker.ts`)
- Typed backend bridge → Tauri commands/events: sends typed IPC (evidence: `README.md`)
- Author → Structure canvas: organizes pieces (evidence: `README.md`)
- Structure canvas → Canvas pieces: renders (evidence: `src/domains/structure/Canvas.tsx`)
- Structure canvas → Frontend state: reads and updates (evidence: `src/domains/structure/Canvas.tsx`)
- Author → Markdown editor: writes Markdown (evidence: `README.md`)
- Author → Reading order: sets sequence (evidence: `README.md`)
- Reading order → Book assembly: orders manuscript (evidence: `README.md`)
- Book assembly → Markdown rendering: renders preview (evidence: `src/domains/book/Manuscript.tsx`)
- Author → Markdown/DOCX export: exports book (evidence: `README.md`)
- Author → Versions and diffs: reviews history (evidence: `README.md`)
- Author → Git workflows: creates versions (evidence: `README.md`)
- Git workflows → Typed backend bridge: requests Git actions
- Author → Project files: manages files (evidence: `src/hooks/useFileOps.ts`)
- Project files → Frontend state: updates file state (evidence: `src/hooks/useFileOps.ts`)
- Frontend state → Typed backend bridge: uses backend APIs
- Tauri commands/events → Project lifecycle: dispatches commands
- Project lifecycle → In-memory project store: coordinates state
- Project lifecycle → Git operations: runs Git operations (evidence: `src-tauri/src/modules/project/app.rs`)
- In-memory project store → Async persistence: queues disk changes (evidence: `README.md`)
- Async persistence → Atomic file writes: writes atomically (evidence: `README.md`)
- Canvas metadata → Local project folder: stores canvas JSON (evidence: `README.md`)
- Async persistence → Local project folder: persists project files (evidence: `README.md`)
- Git operations → Local project folder: tracks working tree (evidence: `README.md`)
- Git operations → Optional Git remote: syncs optionally (evidence: `README.md`)
