# kty2001/novelstory architecture

> Architecture diagram of the GitHub repository kty2001/novelstory, 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/kty2001/novelstory
- Repository: https://github.com/kty2001/novelstory

## Overview

NovelStory (WhiteNoard) is a desktop web app for novelists to organize story structure, settings, and drafts. The main workflow is to choose or create a novel in the library, then work across its board, wiki, overview, narrative order, manuscript, and memo areas; changes are saved locally and can optionally sync across devices after Google login. The README documents the product capabilities; the graph uses the supplied excerpts and source index for implementation relationships and leaves unsampled details unasserted.

Main entry points: [`src/pages/NovelLayout.tsx`](https://github.com/kty2001/novelstory/blob/main/src/pages/NovelLayout.tsx) (Novel workspace), [`src/store/sync.ts`](https://github.com/kty2001/novelstory/blob/main/src/store/sync.ts) (Sync client), [`src/store/novelStore.ts`](https://github.com/kty2001/novelstory/blob/main/src/store/novelStore.ts) (Novel state), [`src/router.tsx`](https://github.com/kty2001/novelstory/blob/main/src/router.tsx) (App routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["App entry"]
  node_router["App routing<br/>[router.tsx]"]
  node_library["Novel library<br/>[LibraryPage.tsx]"]
  node_workspace["Novel workspace<br/>[NovelLayout.tsx]"]
end

subgraph group_planning["Story planning"]
  node_board["Timeline board<br/>[Board.tsx]"]
  node_boardgraph["Board graph<br/>[useBoardGraph.ts]"]
  node_boardflow["Board layout<br/>[flow.ts]"]
  node_boardactions["Board actions<br/>[boardActions.ts]"]
  node_wiki["Settings wiki<br/>[WikiPage.tsx]"]
  node_categories["Wiki categories<br/>[categories.ts]"]
  node_overview["Story overview<br/>[OverviewPage.tsx]"]
  node_narrative["Narrative order<br/>[NarrativePage.tsx]"]
  node_narrativeactions["Episode actions"]
end

subgraph group_writing["Writing workspace"]
  node_manuscript["Manuscript editor<br/>[ManuscriptPage.tsx]"]
  node_memo["Idea memos<br/>[MemoPage.tsx]"]
end

subgraph group_local["Local data"]
  node_store["Novel state<br/>[novelStore.ts]"]
  node_database[("IndexedDB<br/>[db.ts]")]
  node_backup["Novel backup<br/>[novelExport.ts]"]
end

subgraph group_cloud["Account and sync"]
  node_account["Google account<br/>[account.ts]"]
  node_syncclient["Sync client<br/>[sync.ts]"]
  node_authworker["Auth worker<br/>[auth.ts]"]
  node_syncworker["Sync worker<br/>[sync.ts]"]
  node_d1[("Cloud D1")]
end

node_writer(("Writer"))

node_writer -->|"opens app"| node_router
node_router -->|"routes to"| node_library
node_router -->|"routes to"| node_workspace
node_workspace -->|"opens tab"| node_board
node_workspace -->|"opens tab"| node_wiki
node_workspace -->|"opens tab"| node_overview
node_workspace -->|"opens tab"| node_narrative
node_workspace -->|"opens tab"| node_manuscript
node_workspace -->|"opens tab"| node_memo
node_board -->|"builds view"| node_boardgraph
node_boardgraph -->|"maps items"| node_boardflow
node_board -.->|"edits items"| node_boardactions
node_wiki -.->|"manages categories"| node_categories
node_narrative -.->|"edits episodes"| node_narrativeactions
node_library -->|"imports exports"| node_backup
node_library -.->|"opens novel"| node_store
node_store -->|"loads and saves"| node_database
node_boardactions -->|"updates state"| node_store
node_narrativeactions -->|"updates state"| node_store
node_account -->|"controls sync"| node_syncclient
node_syncclient -->|"reads outbox"| node_database
node_syncclient -.->|"uses auth API"| node_authworker
node_syncclient -.->|"syncs changes"| node_syncworker
node_authworker -->|"shares auth"| node_syncworker
node_syncworker -.->|"reads and writes"| node_d1

click node_router "https://github.com/kty2001/novelstory/blob/main/src/router.tsx"
click node_library "https://github.com/kty2001/novelstory/blob/main/src/pages/library/LibraryPage.tsx"
click node_workspace "https://github.com/kty2001/novelstory/blob/main/src/pages/NovelLayout.tsx"
click node_board "https://github.com/kty2001/novelstory/blob/main/src/pages/board/Board.tsx"
click node_boardgraph "https://github.com/kty2001/novelstory/blob/main/src/pages/board/useBoardGraph.ts"
click node_boardflow "https://github.com/kty2001/novelstory/blob/main/src/pages/board/flow.ts"
click node_boardactions "https://github.com/kty2001/novelstory/blob/main/src/store/boardActions.ts"
click node_wiki "https://github.com/kty2001/novelstory/blob/main/src/pages/WikiPage.tsx"
click node_categories "https://github.com/kty2001/novelstory/blob/main/src/pages/wiki/categories.ts"
click node_overview "https://github.com/kty2001/novelstory/blob/main/src/pages/OverviewPage.tsx"
click node_narrative "https://github.com/kty2001/novelstory/blob/main/src/pages/NarrativePage.tsx"
click node_narrativeactions "https://github.com/kty2001/novelstory/blob/main/src/store/narrativeActions.ts"
click node_manuscript "https://github.com/kty2001/novelstory/blob/main/src/pages/ManuscriptPage.tsx"
click node_memo "https://github.com/kty2001/novelstory/blob/main/src/pages/MemoPage.tsx"
click node_store "https://github.com/kty2001/novelstory/blob/main/src/store/novelStore.ts"
click node_database "https://github.com/kty2001/novelstory/blob/main/src/db/db.ts"
click node_backup "https://github.com/kty2001/novelstory/blob/main/src/db/novelExport.ts"
click node_account "https://github.com/kty2001/novelstory/blob/main/src/lib/account.ts"
click node_syncclient "https://github.com/kty2001/novelstory/blob/main/src/store/sync.ts"
click node_authworker "https://github.com/kty2001/novelstory/blob/main/worker/auth.ts"
click node_syncworker "https://github.com/kty2001/novelstory/blob/main/worker/sync.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_router,node_library,node_workspace toneBlue
class node_board,node_boardgraph,node_boardflow,node_boardactions,node_wiki,node_categories,node_overview,node_narrative,node_narrativeactions toneAmber
class node_manuscript,node_memo toneMint
class node_store,node_database,node_backup toneRose
class node_account,node_syncclient,node_authworker,node_syncworker,node_d1,node_writer toneIndigo
```

## Components

### App entry

- [App routing](https://github.com/kty2001/novelstory/blob/main/src/router.tsx): `src/router.tsx`
- [Novel library](https://github.com/kty2001/novelstory/blob/main/src/pages/library/LibraryPage.tsx): `src/pages/library/LibraryPage.tsx`
- [Novel workspace](https://github.com/kty2001/novelstory/blob/main/src/pages/NovelLayout.tsx): `src/pages/NovelLayout.tsx`

### Story planning

- [Timeline board](https://github.com/kty2001/novelstory/blob/main/src/pages/board/Board.tsx): `src/pages/board/Board.tsx`
- [Board graph](https://github.com/kty2001/novelstory/blob/main/src/pages/board/useBoardGraph.ts): `src/pages/board/useBoardGraph.ts`
- [Board layout](https://github.com/kty2001/novelstory/blob/main/src/pages/board/flow.ts): `src/pages/board/flow.ts`
- [Board actions](https://github.com/kty2001/novelstory/blob/main/src/store/boardActions.ts): `src/store/boardActions.ts`
- [Settings wiki](https://github.com/kty2001/novelstory/blob/main/src/pages/WikiPage.tsx): `src/pages/WikiPage.tsx`
- [Wiki categories](https://github.com/kty2001/novelstory/blob/main/src/pages/wiki/categories.ts): `src/pages/wiki/categories.ts`
- [Story overview](https://github.com/kty2001/novelstory/blob/main/src/pages/OverviewPage.tsx): `src/pages/OverviewPage.tsx`
- [Narrative order](https://github.com/kty2001/novelstory/blob/main/src/pages/NarrativePage.tsx): `src/pages/NarrativePage.tsx`
- [Episode actions](https://github.com/kty2001/novelstory/blob/main/src/store/narrativeActions.ts): `src/store/narrativeActions.ts`

### Writing workspace

- [Manuscript editor](https://github.com/kty2001/novelstory/blob/main/src/pages/ManuscriptPage.tsx): `src/pages/ManuscriptPage.tsx`
- [Idea memos](https://github.com/kty2001/novelstory/blob/main/src/pages/MemoPage.tsx): `src/pages/MemoPage.tsx`

### Local data

- [Novel state](https://github.com/kty2001/novelstory/blob/main/src/store/novelStore.ts): `src/store/novelStore.ts`
- [IndexedDB](https://github.com/kty2001/novelstory/blob/main/src/db/db.ts): `src/db/db.ts`
- [Novel backup](https://github.com/kty2001/novelstory/blob/main/src/db/novelExport.ts): `src/db/novelExport.ts`

### Account and sync

- [Google account](https://github.com/kty2001/novelstory/blob/main/src/lib/account.ts): `src/lib/account.ts`
- [Sync client](https://github.com/kty2001/novelstory/blob/main/src/store/sync.ts): `src/store/sync.ts`
- [Auth worker](https://github.com/kty2001/novelstory/blob/main/worker/auth.ts): `worker/auth.ts`
- [Sync worker](https://github.com/kty2001/novelstory/blob/main/worker/sync.ts): `worker/sync.ts`
- **Cloud D1**

### Other components

- **Writer**

## Connections

- Writer → App routing: opens app (evidence: `src/router.tsx`)
- App routing → Novel library: routes to (evidence: `src/router.tsx`)
- App routing → Novel workspace: routes to (evidence: `src/router.tsx`)
- Novel workspace → Timeline board: opens tab
- Novel workspace → Settings wiki: opens tab
- Novel workspace → Story overview: opens tab
- Novel workspace → Narrative order: opens tab
- Novel workspace → Manuscript editor: opens tab
- Novel workspace → Idea memos: opens tab
- Timeline board → Board graph: builds view
- Board graph → Board layout: maps items (evidence: `src/pages/board/useBoardGraph.ts`)
- Timeline board → Board actions: edits items
- Settings wiki → Wiki categories: manages categories
- Narrative order → Episode actions: edits episodes
- Novel library → Novel backup: imports exports (evidence: `src/pages/library/LibraryPage.tsx`)
- Novel library → Novel state: opens novel
- Novel state → IndexedDB: loads and saves (evidence: `src/store/novelStore.ts`)
- Board actions → Novel state: updates state (evidence: `src/store/boardActions.ts`)
- Episode actions → Novel state: updates state (evidence: `src/store/narrativeActions.ts`)
- Google account → Sync client: controls sync (evidence: `src/lib/account.ts`)
- Sync client → IndexedDB: reads outbox (evidence: `src/store/sync.ts`)
- Sync client → Auth worker: uses auth API
- Sync client → Sync worker: syncs changes
- Auth worker → Sync worker: shares auth (evidence: `worker/index.ts`)
- Sync worker → Cloud D1: reads and writes
