# sneharathi24/storystitch architecture

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

- Interactive diagram: https://gitdiagram.com/sneharathi24/storystitch
- Repository: https://github.com/sneharathi24/storystitch

## Overview

StoryStitch is a browser-based AI writing companion. Authors capture rough notes, which are categorized into an Idea Vault; they can brainstorm questions, draft and save chapters, inspect each chapter’s Origin/Beats/Resolution context, and request context-aware rewrites. A separate analysis action checks pacing and continuity. FastAPI routes own the backend workflow, StoryStore persists ideas and chapters in SQLite, and LLMClient supplies local heuristics or optional hosted-model responses. The sampled files show the main route and call structure; some UI wiring and provider details are only partially excerpted.

Main entry points: [`public/app.js`](https://github.com/sneharathi24/storystitch/blob/main/public/app.js) (StoryStitch UI), [`app.py`](https://github.com/sneharathi24/storystitch/blob/main/app.py) (Idea & brainstorm API), [`llm_client.py`](https://github.com/sneharathi24/storystitch/blob/main/llm_client.py) (LLM workflows), [`story_store.py`](https://github.com/sneharathi24/storystitch/blob/main/story_store.py) (Chapter records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Writing experience"]
  node_browser["StoryStitch UI<br/>[app.js]"]
  node_web_app["Web interface<br/>[index.html]"]
end

subgraph group_api["API workflows"]
  node_idea_routes["Idea &amp; brainstorm API<br/>[app.py]"]
  node_chapter_routes["Chapter API<br/>[app.py]"]
  node_rewrite_route["Rewrite API<br/>[app.py]"]
  node_analysis_route["Analysis API<br/>[app.py]"]
end

subgraph group_domain["Story context"]
  node_idea_vault["Idea Vault<br/>[story_store.py]"]
  node_chapter_editor["Chapter records<br/>[story_store.py]"]
  node_tri_pillar["Tri-Pillar context<br/>[story_store.py]"]
end

subgraph group_intelligence["Writing intelligence"]
  node_llm_client["LLM workflows<br/>[llm_client.py]"]
  node_brainstorm["Brainstorm questions<br/>[llm_client.py]"]
  node_rewrite_options["Stitch &amp; Polish<br/>[llm_client.py]"]
  node_pacing_analysis["Pacing &amp; continuity<br/>[llm_client.py]"]
end

subgraph group_persistence["Persistence"]
  node_sqlite[("SQLite store<br/>[story_store.py]")]
end

node_author(("Author"))
node_hosted_model{{"Hosted model"}}

node_author -->|"uses"| node_browser
node_browser -->|"renders"| node_web_app
node_browser -->|"requests ideas"| node_idea_routes
node_browser -->|"requests questions"| node_idea_routes
node_browser -->|"saves chapters"| node_chapter_routes
node_browser -->|"loads context"| node_chapter_routes
node_browser -->|"requests rewrites"| node_rewrite_route
node_browser -->|"requests analysis"| node_analysis_route
node_idea_routes -->|"categorizes notes"| node_llm_client
node_idea_routes -->|"stores and lists"| node_idea_vault
node_idea_routes -->|"gets questions"| node_brainstorm
node_brainstorm -->|"generates questions"| node_llm_client
node_chapter_routes -->|"creates and updates"| node_chapter_editor
node_chapter_routes -->|"builds context"| node_tri_pillar
node_rewrite_route -->|"loads chapter"| node_chapter_editor
node_rewrite_route -->|"builds context"| node_tri_pillar
node_rewrite_route -->|"requests options"| node_rewrite_options
node_rewrite_options -->|"generates rewrites"| node_llm_client
node_analysis_route -->|"loads draft"| node_chapter_editor
node_analysis_route -->|"builds context"| node_tri_pillar
node_analysis_route -->|"requests review"| node_pacing_analysis
node_pacing_analysis -->|"analyzes draft"| node_llm_client
node_idea_vault -->|"reads and writes"| node_sqlite
node_chapter_editor -->|"reads and writes"| node_sqlite
node_tri_pillar -->|"selects notes"| node_idea_vault
node_llm_client -.->|"calls when configured"| node_hosted_model

click node_browser "https://github.com/sneharathi24/storystitch/blob/main/public/app.js"
click node_web_app "https://github.com/sneharathi24/storystitch/blob/main/public/index.html"
click node_idea_routes "https://github.com/sneharathi24/storystitch/blob/main/app.py"
click node_chapter_routes "https://github.com/sneharathi24/storystitch/blob/main/app.py"
click node_rewrite_route "https://github.com/sneharathi24/storystitch/blob/main/app.py"
click node_analysis_route "https://github.com/sneharathi24/storystitch/blob/main/app.py"
click node_idea_vault "https://github.com/sneharathi24/storystitch/blob/main/story_store.py"
click node_chapter_editor "https://github.com/sneharathi24/storystitch/blob/main/story_store.py"
click node_tri_pillar "https://github.com/sneharathi24/storystitch/blob/main/story_store.py"
click node_llm_client "https://github.com/sneharathi24/storystitch/blob/main/llm_client.py"
click node_sqlite "https://github.com/sneharathi24/storystitch/blob/main/story_store.py"
click node_brainstorm "https://github.com/sneharathi24/storystitch/blob/main/llm_client.py"
click node_rewrite_options "https://github.com/sneharathi24/storystitch/blob/main/llm_client.py"
click node_pacing_analysis "https://github.com/sneharathi24/storystitch/blob/main/llm_client.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_browser,node_web_app toneBlue
class node_idea_routes,node_chapter_routes,node_rewrite_route,node_analysis_route toneAmber
class node_idea_vault,node_chapter_editor,node_tri_pillar toneMint
class node_llm_client,node_brainstorm,node_rewrite_options,node_pacing_analysis toneRose
class node_sqlite,node_author,node_hosted_model toneIndigo
```

## Components

### Writing experience

- [StoryStitch UI](https://github.com/sneharathi24/storystitch/blob/main/public/app.js): `public/app.js`
- [Web interface](https://github.com/sneharathi24/storystitch/blob/main/public/index.html): `public/index.html`

### API workflows

- [Idea & brainstorm API](https://github.com/sneharathi24/storystitch/blob/main/app.py): `app.py`
- [Chapter API](https://github.com/sneharathi24/storystitch/blob/main/app.py): `app.py`
- [Rewrite API](https://github.com/sneharathi24/storystitch/blob/main/app.py): `app.py`
- [Analysis API](https://github.com/sneharathi24/storystitch/blob/main/app.py): `app.py`

### Story context

- [Idea Vault](https://github.com/sneharathi24/storystitch/blob/main/story_store.py): `story_store.py`
- [Chapter records](https://github.com/sneharathi24/storystitch/blob/main/story_store.py): `story_store.py`
- [Tri-Pillar context](https://github.com/sneharathi24/storystitch/blob/main/story_store.py): `story_store.py`

### Writing intelligence

- [LLM workflows](https://github.com/sneharathi24/storystitch/blob/main/llm_client.py): `llm_client.py`
- [Brainstorm questions](https://github.com/sneharathi24/storystitch/blob/main/llm_client.py): `llm_client.py`
- [Stitch & Polish](https://github.com/sneharathi24/storystitch/blob/main/llm_client.py): `llm_client.py`
- [Pacing & continuity](https://github.com/sneharathi24/storystitch/blob/main/llm_client.py): `llm_client.py`

### Persistence

- [SQLite store](https://github.com/sneharathi24/storystitch/blob/main/story_store.py): `story_store.py`

### Other components

- **Author**
- **Hosted model**

## Connections

- Author → StoryStitch UI: uses (evidence: `README.md`)
- StoryStitch UI → Web interface: renders (evidence: `public/app.js`)
- StoryStitch UI → Idea & brainstorm API: requests ideas (evidence: `public/app.js`)
- StoryStitch UI → Idea & brainstorm API: requests questions (evidence: `public/app.js`)
- StoryStitch UI → Chapter API: saves chapters (evidence: `public/app.js`)
- StoryStitch UI → Chapter API: loads context (evidence: `public/app.js`)
- StoryStitch UI → Rewrite API: requests rewrites (evidence: `public/app.js`)
- StoryStitch UI → Analysis API: requests analysis (evidence: `public/app.js`)
- Idea & brainstorm API → LLM workflows: categorizes notes (evidence: `app.py`)
- Idea & brainstorm API → Idea Vault: stores and lists (evidence: `app.py`)
- Idea & brainstorm API → Brainstorm questions: gets questions (evidence: `app.py`)
- Brainstorm questions → LLM workflows: generates questions (evidence: `llm_client.py`)
- Chapter API → Chapter records: creates and updates (evidence: `app.py`)
- Chapter API → Tri-Pillar context: builds context (evidence: `app.py`)
- Rewrite API → Chapter records: loads chapter (evidence: `app.py`)
- Rewrite API → Tri-Pillar context: builds context (evidence: `app.py`)
- Rewrite API → Stitch & Polish: requests options (evidence: `app.py`)
- Stitch & Polish → LLM workflows: generates rewrites (evidence: `llm_client.py`)
- Analysis API → Chapter records: loads draft (evidence: `app.py`)
- Analysis API → Tri-Pillar context: builds context (evidence: `app.py`)
- Analysis API → Pacing & continuity: requests review (evidence: `app.py`)
- Pacing & continuity → LLM workflows: analyzes draft (evidence: `llm_client.py`)
- Idea Vault → SQLite store: reads and writes (evidence: `story_store.py`)
- Chapter records → SQLite store: reads and writes (evidence: `story_store.py`)
- Tri-Pillar context → Idea Vault: selects notes (evidence: `story_store.py`)
- LLM workflows → Hosted model: calls when configured (evidence: `llm_client.py`)
