# vijayk1989/thestorynexustauriapp architecture

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

- Interactive diagram: https://gitdiagram.com/vijayk1989/thestorynexustauriapp
- Repository: https://github.com/vijayk1989/thestorynexustauriapp

## Overview

The Story Nexus is a local-first fiction-writing desktop app organized around an editor-first workflow: writers select a story and chapter, edit autosaved chapter content, and use contextual writing tools. Supporting branches include lorebook matching, prompts, brainstorm chats, AI settings, agents and pipelines, images, and backup/export. IndexedDB via Dexie is the documented local store. The map combines README capabilities with shown source references; several feature internals are unsampled, so their finer call paths are omitted.

Main entry points: [`src/services/database.ts`](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/services/database.ts) (IndexedDB), [`src/features/scenebeats/hooks/useSceneBeatGeneration.ts`](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/scenebeats/hooks/useSceneBeatGeneration.ts) (Scene beat generation), [`src/features/ai/stores/useAIStore.ts`](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/ai/stores/useAIStore.ts) (AI settings state), [`src/features/chapters/stores/useChapterStore.ts`](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/chapters/stores/useChapterStore.ts) (Chapter state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Writing workspace"]
  node_workspace["Editor workspace"]
  node_chapterui["Chapter editor"]
  node_lexical["Lexical editor"]
end

subgraph group_context["Story context"]
  node_loreui["Lorebook tools<br/>[LorebookPanel.tsx]"]
  node_lorestate["Lorebook state"]
  node_promptui["Prompt manager<br/>[PromptsManager.tsx]"]
  node_promptstate["Prompt state<br/>[promptStore.ts]"]
  node_parser["Prompt parser<br/>[promptParser.ts]"]
end

subgraph group_generation["AI generation"]
  node_aiui["AI settings<br/>[AISettingsPage.tsx]"]
  node_aistate["AI settings state<br/>[useAIStore.ts]"]
  node_aiservice["AI providers<br/>[AIService.ts]"]
  node_scene["Inline scene beats"]
  node_scenegen["Scene beat generation"]
  node_agents["Agents and pipelines"]
  node_orchestrator["Agent orchestrator"]
end

subgraph group_persistence["Local data"]
  node_chapterstate["Chapter state<br/>[useChapterStore.ts]"]
  node_db[("IndexedDB<br/>[database.ts]")]
end

subgraph group_support["Writing tools"]
  node_brainstorm["Brainstorm chats"]
  node_timeline["Timeline tools"]
  node_notes["Notes and drafts"]
  node_images["Image generation"]
  node_backup["Site backup"]
  node_export["Story export"]
end

node_writer(("Writer"))

node_writer -->|"opens"| node_workspace
node_workspace -->|"selects chapter"| node_chapterui
node_chapterui -->|"edits in"| node_lexical
node_chapterui -->|"manages chapter"| node_chapterstate
node_chapterstate -->|"reads and writes"| node_db
node_loreui -.->|"uses"| node_lorestate
node_lorestate -->|"reads and writes"| node_db
node_promptui -->|"manages prompts"| node_promptstate
node_promptstate -->|"reads and writes"| node_db
node_parser -->|"reads chapter context"| node_chapterstate
node_parser -->|"reads lore context"| node_lorestate
node_aiui -.->|"configures"| node_aistate
node_aistate -->|"delegates generation"| node_aiservice
node_aiservice -->|"loads settings"| node_db
node_scene -->|"starts generation"| node_scenegen
node_scenegen -->|"uses AI settings"| node_aistate
node_scenegen -->|"builds prompt"| node_parser
node_scenegen -->|"runs agent workflows"| node_agents
node_agents -.->|"executes pipeline"| node_orchestrator
node_brainstorm -.->|"uses AI generation"| node_aistate
node_images -->|"stores assets"| node_db
node_backup -->|"imports and exports data"| node_db
node_export -.->|"exports story content"| node_chapterstate

click node_workspace "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/editor/pages/EditorWorkspace.tsx"
click node_chapterui "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/chapters/pages/ChapterEditorPage.tsx"
click node_lexical "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/components/editor/mainLexicalEditor/MainLexicalEditor.tsx"
click node_chapterstate "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/chapters/stores/useChapterStore.ts"
click node_db "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/services/database.ts"
click node_loreui "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/lorebook/components/LorebookPanel.tsx"
click node_lorestate "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/lorebook/stores/useLorebookStore.ts"
click node_promptui "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/prompts/components/PromptsManager.tsx"
click node_promptstate "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/prompts/store/promptStore.ts"
click node_parser "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/prompts/services/promptParser.ts"
click node_brainstorm "https://github.com/vijayk1989/thestorynexustauriapp/tree/main/src/features/brainstorm"
click node_timeline "https://github.com/vijayk1989/thestorynexustauriapp/tree/main/src/features/timeline"
click node_notes "https://github.com/vijayk1989/thestorynexustauriapp/tree/main/src/features/notes"
click node_aiui "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/ai/pages/AISettingsPage.tsx"
click node_aistate "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/ai/stores/useAIStore.ts"
click node_aiservice "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/services/ai/AIService.ts"
click node_scene "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/components/editor/mainLexicalEditor/nodes/scene-beat/useSceneBeatLifecycle.ts"
click node_scenegen "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/scenebeats/hooks/useSceneBeatGeneration.ts"
click node_agents "https://github.com/vijayk1989/thestorynexustauriapp/tree/main/src/features/agents"
click node_orchestrator "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/services/ai/AgentOrchestrator.ts"
click node_images "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/images/services/imageGenerationService.ts"
click node_backup "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/services/siteBackupService.ts"
click node_export "https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/services/storyExportService.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_workspace,node_chapterui,node_lexical toneBlue
class node_loreui,node_lorestate,node_promptui,node_promptstate,node_parser toneAmber
class node_aiui,node_aistate,node_aiservice,node_scene,node_scenegen,node_agents,node_orchestrator toneMint
class node_chapterstate,node_db toneRose
class node_brainstorm,node_timeline,node_notes,node_images,node_backup,node_export,node_writer toneIndigo
```

## Components

### Writing workspace

- [Editor workspace](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/editor/pages/EditorWorkspace.tsx): `src/features/editor/pages/EditorWorkspace.tsx`
- [Chapter editor](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/chapters/pages/ChapterEditorPage.tsx): `src/features/chapters/pages/ChapterEditorPage.tsx`
- [Lexical editor](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/components/editor/mainLexicalEditor/MainLexicalEditor.tsx): `src/components/editor/mainLexicalEditor/MainLexicalEditor.tsx`

### Story context

- [Lorebook tools](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/lorebook/components/LorebookPanel.tsx): `src/features/lorebook/components/LorebookPanel.tsx`
- [Lorebook state](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/lorebook/stores/useLorebookStore.ts): `src/features/lorebook/stores/useLorebookStore.ts`
- [Prompt manager](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/prompts/components/PromptsManager.tsx): `src/features/prompts/components/PromptsManager.tsx`
- [Prompt state](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/prompts/store/promptStore.ts): `src/features/prompts/store/promptStore.ts`
- [Prompt parser](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/prompts/services/promptParser.ts): `src/features/prompts/services/promptParser.ts`

### AI generation

- [AI settings](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/ai/pages/AISettingsPage.tsx): `src/features/ai/pages/AISettingsPage.tsx`
- [AI settings state](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/ai/stores/useAIStore.ts): `src/features/ai/stores/useAIStore.ts`
- [AI providers](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/services/ai/AIService.ts): `src/services/ai/AIService.ts`
- [Inline scene beats](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/components/editor/mainLexicalEditor/nodes/scene-beat/useSceneBeatLifecycle.ts): `src/components/editor/mainLexicalEditor/nodes/scene-beat/useSceneBeatLifecycle.ts`
- [Scene beat generation](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/scenebeats/hooks/useSceneBeatGeneration.ts): `src/features/scenebeats/hooks/useSceneBeatGeneration.ts`
- [Agents and pipelines](https://github.com/vijayk1989/thestorynexustauriapp/tree/main/src/features/agents): `src/features/agents`
- [Agent orchestrator](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/services/ai/AgentOrchestrator.ts): `src/services/ai/AgentOrchestrator.ts`

### Local data

- [Chapter state](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/chapters/stores/useChapterStore.ts): `src/features/chapters/stores/useChapterStore.ts`
- [IndexedDB](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/services/database.ts): `src/services/database.ts`

### Writing tools

- [Brainstorm chats](https://github.com/vijayk1989/thestorynexustauriapp/tree/main/src/features/brainstorm): `src/features/brainstorm`
- [Timeline tools](https://github.com/vijayk1989/thestorynexustauriapp/tree/main/src/features/timeline): `src/features/timeline`
- [Notes and drafts](https://github.com/vijayk1989/thestorynexustauriapp/tree/main/src/features/notes): `src/features/notes`
- [Image generation](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/features/images/services/imageGenerationService.ts): `src/features/images/services/imageGenerationService.ts`
- [Site backup](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/services/siteBackupService.ts): `src/services/siteBackupService.ts`
- [Story export](https://github.com/vijayk1989/thestorynexustauriapp/blob/main/src/services/storyExportService.ts): `src/services/storyExportService.ts`

### Other components

- **Writer**

## Connections

- Writer → Editor workspace: opens (evidence: `README.md`)
- Editor workspace → Chapter editor: selects chapter (evidence: `README.md`)
- Chapter editor → Lexical editor: edits in (evidence: `README.md`)
- Chapter editor → Chapter state: manages chapter (evidence: `README.md`)
- Chapter state → IndexedDB: reads and writes (evidence: `src/features/chapters/stores/useChapterStore.ts`)
- Lorebook tools → Lorebook state: uses
- Lorebook state → IndexedDB: reads and writes (evidence: `src/features/lorebook/stores/useLorebookStore.ts`)
- Prompt manager → Prompt state: manages prompts (evidence: `src/features/prompts/components/PromptsManager.tsx`)
- Prompt state → IndexedDB: reads and writes (evidence: `src/features/prompts/store/promptStore.ts`)
- Prompt parser → Chapter state: reads chapter context (evidence: `src/features/prompts/services/promptParser.ts`)
- Prompt parser → Lorebook state: reads lore context (evidence: `src/features/prompts/services/promptParser.ts`)
- AI settings → AI settings state: configures
- AI settings state → AI providers: delegates generation (evidence: `src/features/ai/stores/useAIStore.ts`)
- AI providers → IndexedDB: loads settings (evidence: `src/services/ai/AIService.ts`)
- Inline scene beats → Scene beat generation: starts generation (evidence: `src/components/editor/mainLexicalEditor/nodes/scene-beat/useSceneBeatLifecycle.ts`)
- Scene beat generation → AI settings state: uses AI settings (evidence: `src/features/scenebeats/hooks/useSceneBeatGeneration.ts`)
- Scene beat generation → Prompt parser: builds prompt (evidence: `src/features/scenebeats/hooks/useSceneBeatGeneration.ts`)
- Scene beat generation → Agents and pipelines: runs agent workflows (evidence: `src/features/scenebeats/hooks/useSceneBeatGeneration.ts`)
- Agents and pipelines → Agent orchestrator: executes pipeline (evidence: `src/services/ai/AgentOrchestrator.ts`)
- Brainstorm chats → AI settings state: uses AI generation
- Image generation → IndexedDB: stores assets
- Site backup → IndexedDB: imports and exports data (evidence: `src/services/siteBackupService.ts`)
- Story export → Chapter state: exports story content
