# sakthi-gyan/story-book architecture

> Architecture diagram of the GitHub repository sakthi-gyan/story-book, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sakthi-gyan/story-book
- Repository: https://github.com/sakthi-gyan/story-book

## Overview

Shot Image Pipeline turns a story or shot-breakdown PDF into approved visual deliverables through a five-stage workflow: planning, references, storyboard, final renders, and library export. The browser app guides uploads, review, approvals, project history, and cost visibility; an API coordinates generation and persists project state. Agent and walkthrough modes are additional ways to use the workflow. The README establishes the product stages and capabilities; source excerpts and the index support only some internal call paths, so unsampled links are omitted.

Main entry points: [`server/src/store.ts`](https://github.com/sakthi-gyan/story-book/blob/main/server/src/store.ts) (Project state), [`client/src/App.tsx`](https://github.com/sakthi-gyan/story-book/blob/main/client/src/App.tsx) (Workflow app), [`server/src/routes.ts`](https://github.com/sakthi-gyan/story-book/blob/main/server/src/routes.ts) (HTTP routes), [`client/src/api.ts`](https://github.com/sakthi-gyan/story-book/blob/main/client/src/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Creator experience"]
  node_app["Workflow app<br/>[App.tsx]"]
  node_api["API client<br/>[api.ts]"]
  node_project_ui["Project steps"]
  node_review_ui["Review interface<br/>[ReviewDrawer.tsx]"]
  node_guide["Guide mode"]
  node_agent_ui["Agent mode"]
  node_ui_state["Project derivations<br/>[derive.ts]"]
  node_ui_hooks["Project hooks<br/>[hooks.tsx]"]
  node_icons["Icon system<br/>[DualToneIcon.tsx]"]
  node_icon_registry["Icon registry<br/>[register.ts]"]
  node_motion["Motion effects<br/>[Motion.tsx]"]
  node_stepper["Pipeline stepper"]
  node_step_header["Step header<br/>[StepHeader.tsx]"]
  node_theme["Visual theme<br/>[theme.ts]"]
end

subgraph group_workflow["Visual workflow"]
  node_planner["PDF planning<br/>[parsePlan.ts]"]
  node_reference_gen["Reference sheets<br/>[references.ts]"]
  node_storyboard["Storyboard panels<br/>[storyboard.ts]"]
  node_shot_ops["Shot generation<br/>[shots.ts]"]
  node_review["AI image review<br/>[review.ts]"]
  node_render["Final rendering<br/>[render.ts]"]
  node_prompts["Prompt design<br/>[prompts.ts]"]
end

subgraph group_services["AI and state"]
  node_routes["HTTP routes<br/>[routes.ts]"]
  node_schema["Project schema<br/>[schema.ts]"]
  node_openai["Model gateway<br/>[openai.ts]"]
  node_usage["Usage tracking<br/>[usage.ts]"]
  node_store[("Project state<br/>[store.ts]")]
  node_storage[("Storage adapters<br/>[index.ts]")]
end

subgraph group_delivery["Delivery"]
  node_library["Project library<br/>[LibraryStep.tsx]"]
  node_exports["Export assets<br/>[pack.ts]"]
  node_agent_pack["Agent package<br/>[agentPack.ts]"]
  node_agent_cli["Agent CLI<br/>[cli.mjs]"]
end

node_creator(("Creator"))
node_openai_service{{"OpenAI"}}

node_creator -->|"uses"| node_app
node_app -->|"requests"| node_api
node_app -->|"shows steps"| node_project_ui
node_app -->|"shows progress"| node_stepper
node_app -->|"offers walkthrough"| node_guide
node_app -->|"uses"| node_ui_hooks
node_review_ui -->|"sends review actions"| node_api
node_review_ui -->|"derives review state"| node_ui_state
node_project_ui -->|"requests workflow"| node_api
node_project_ui -.->|"opens review"| node_review_ui
node_ui_hooks -->|"loads projects"| node_api
node_ui_hooks -->|"derives status"| node_ui_state
node_stepper -->|"derives progress"| node_ui_state
node_icons -->|"uses icons"| node_icon_registry
node_app -->|"applies styling"| node_theme
node_api -->|"calls API"| node_routes
node_routes -->|"starts parsing"| node_planner
node_routes -->|"starts generation"| node_reference_gen
node_routes -->|"dispatches shot actions"| node_shot_ops
node_routes -->|"dispatches renders"| node_render
node_routes -->|"dispatches boards"| node_storyboard
node_routes -->|"reads and saves"| node_store
node_planner -->|"requests model output"| node_openai
node_planner -->|"uses prompts"| node_prompts
node_reference_gen -->|"requests images"| node_openai
node_reference_gen -->|"uses prompts"| node_prompts
node_shot_ops -->|"requests images"| node_openai
node_shot_ops -->|"uses prompts"| node_prompts
node_review -->|"requests review"| node_openai
node_review -->|"uses prompts"| node_prompts
node_storyboard -.->|"delegates generation"| node_shot_ops
node_render -.->|"delegates generation"| node_shot_ops
node_openai -->|"calls model service"| node_openai_service
node_openai -->|"records tokens"| node_usage
node_planner -->|"updates project"| node_store
node_reference_gen -->|"updates project"| node_store
node_shot_ops -->|"updates project"| node_store
node_review -->|"updates project"| node_store
node_store -->|"validates state"| node_schema
node_store -->|"persists data"| node_storage
node_library -.->|"loads project assets"| node_api
node_library -->|"downloads bundle"| node_exports
node_exports -->|"packages project data"| node_store
node_agent_ui -->|"guides workflow"| node_api
node_agent_cli -.->|"uses package"| node_agent_pack
node_creator -->|"runs agent"| node_agent_cli

click node_app "https://github.com/sakthi-gyan/story-book/blob/main/client/src/App.tsx"
click node_api "https://github.com/sakthi-gyan/story-book/blob/main/client/src/api.ts"
click node_project_ui "https://github.com/sakthi-gyan/story-book/tree/main/client/src/steps"
click node_review_ui "https://github.com/sakthi-gyan/story-book/blob/main/client/src/components/ReviewDrawer.tsx"
click node_guide "https://github.com/sakthi-gyan/story-book/blob/main/client/src/components/OnboardingGuide.tsx"
click node_agent_ui "https://github.com/sakthi-gyan/story-book/blob/main/client/src/pages/AgentLiveTerminal.tsx"
click node_ui_state "https://github.com/sakthi-gyan/story-book/blob/main/client/src/derive.ts"
click node_ui_hooks "https://github.com/sakthi-gyan/story-book/blob/main/client/src/hooks.tsx"
click node_icons "https://github.com/sakthi-gyan/story-book/blob/main/client/src/icons/DualToneIcon.tsx"
click node_icon_registry "https://github.com/sakthi-gyan/story-book/blob/main/client/src/icons/register.ts"
click node_motion "https://github.com/sakthi-gyan/story-book/blob/main/client/src/components/Motion.tsx"
click node_stepper "https://github.com/sakthi-gyan/story-book/blob/main/client/src/components/PipelineStepper.tsx"
click node_step_header "https://github.com/sakthi-gyan/story-book/blob/main/client/src/components/StepHeader.tsx"
click node_theme "https://github.com/sakthi-gyan/story-book/blob/main/client/src/theme.ts"
click node_planner "https://github.com/sakthi-gyan/story-book/blob/main/server/src/pipeline/parsePlan.ts"
click node_reference_gen "https://github.com/sakthi-gyan/story-book/blob/main/server/src/pipeline/references.ts"
click node_storyboard "https://github.com/sakthi-gyan/story-book/blob/main/server/src/pipeline/storyboard.ts"
click node_shot_ops "https://github.com/sakthi-gyan/story-book/blob/main/server/src/pipeline/shots.ts"
click node_review "https://github.com/sakthi-gyan/story-book/blob/main/server/src/pipeline/review.ts"
click node_render "https://github.com/sakthi-gyan/story-book/blob/main/server/src/pipeline/render.ts"
click node_prompts "https://github.com/sakthi-gyan/story-book/blob/main/server/src/prompts.ts"
click node_routes "https://github.com/sakthi-gyan/story-book/blob/main/server/src/routes.ts"
click node_schema "https://github.com/sakthi-gyan/story-book/blob/main/server/src/schema.ts"
click node_openai "https://github.com/sakthi-gyan/story-book/blob/main/server/src/openai.ts"
click node_usage "https://github.com/sakthi-gyan/story-book/blob/main/server/src/usage.ts"
click node_store "https://github.com/sakthi-gyan/story-book/blob/main/server/src/store.ts"
click node_storage "https://github.com/sakthi-gyan/story-book/blob/main/server/src/storage/index.ts"
click node_library "https://github.com/sakthi-gyan/story-book/blob/main/client/src/steps/LibraryStep.tsx"
click node_exports "https://github.com/sakthi-gyan/story-book/blob/main/server/src/export/pack.ts"
click node_agent_pack "https://github.com/sakthi-gyan/story-book/blob/main/server/src/export/agentPack.ts"
click node_agent_cli "https://github.com/sakthi-gyan/story-book/blob/main/agent/cli.mjs"

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_api,node_project_ui,node_review_ui,node_guide,node_agent_ui,node_ui_state,node_ui_hooks,node_icons,node_icon_registry,node_motion,node_stepper,node_step_header,node_theme toneBlue
class node_planner,node_reference_gen,node_storyboard,node_shot_ops,node_review,node_render,node_prompts toneAmber
class node_routes,node_schema,node_openai,node_usage,node_store,node_storage toneMint
class node_library,node_exports,node_agent_pack,node_agent_cli toneRose
class node_creator,node_openai_service toneIndigo
```

## Components

### Creator experience

- [Workflow app](https://github.com/sakthi-gyan/story-book/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [API client](https://github.com/sakthi-gyan/story-book/blob/main/client/src/api.ts): `client/src/api.ts`
- [Project steps](https://github.com/sakthi-gyan/story-book/tree/main/client/src/steps): `client/src/steps`
- [Review interface](https://github.com/sakthi-gyan/story-book/blob/main/client/src/components/ReviewDrawer.tsx): `client/src/components/ReviewDrawer.tsx`
- [Guide mode](https://github.com/sakthi-gyan/story-book/blob/main/client/src/components/OnboardingGuide.tsx): `client/src/components/OnboardingGuide.tsx`
- [Agent mode](https://github.com/sakthi-gyan/story-book/blob/main/client/src/pages/AgentLiveTerminal.tsx): `client/src/pages/AgentLiveTerminal.tsx`
- [Project derivations](https://github.com/sakthi-gyan/story-book/blob/main/client/src/derive.ts): `client/src/derive.ts`
- [Project hooks](https://github.com/sakthi-gyan/story-book/blob/main/client/src/hooks.tsx): `client/src/hooks.tsx`
- [Icon system](https://github.com/sakthi-gyan/story-book/blob/main/client/src/icons/DualToneIcon.tsx): `client/src/icons/DualToneIcon.tsx`
- [Icon registry](https://github.com/sakthi-gyan/story-book/blob/main/client/src/icons/register.ts): `client/src/icons/register.ts`
- [Motion effects](https://github.com/sakthi-gyan/story-book/blob/main/client/src/components/Motion.tsx): `client/src/components/Motion.tsx`
- [Pipeline stepper](https://github.com/sakthi-gyan/story-book/blob/main/client/src/components/PipelineStepper.tsx): `client/src/components/PipelineStepper.tsx`
- [Step header](https://github.com/sakthi-gyan/story-book/blob/main/client/src/components/StepHeader.tsx): `client/src/components/StepHeader.tsx`
- [Visual theme](https://github.com/sakthi-gyan/story-book/blob/main/client/src/theme.ts): `client/src/theme.ts`

### Visual workflow

- [PDF planning](https://github.com/sakthi-gyan/story-book/blob/main/server/src/pipeline/parsePlan.ts): `server/src/pipeline/parsePlan.ts`
- [Reference sheets](https://github.com/sakthi-gyan/story-book/blob/main/server/src/pipeline/references.ts): `server/src/pipeline/references.ts`
- [Storyboard panels](https://github.com/sakthi-gyan/story-book/blob/main/server/src/pipeline/storyboard.ts): `server/src/pipeline/storyboard.ts`
- [Shot generation](https://github.com/sakthi-gyan/story-book/blob/main/server/src/pipeline/shots.ts): `server/src/pipeline/shots.ts`
- [AI image review](https://github.com/sakthi-gyan/story-book/blob/main/server/src/pipeline/review.ts): `server/src/pipeline/review.ts`
- [Final rendering](https://github.com/sakthi-gyan/story-book/blob/main/server/src/pipeline/render.ts): `server/src/pipeline/render.ts`
- [Prompt design](https://github.com/sakthi-gyan/story-book/blob/main/server/src/prompts.ts): `server/src/prompts.ts`

### AI and state

- [HTTP routes](https://github.com/sakthi-gyan/story-book/blob/main/server/src/routes.ts): `server/src/routes.ts`
- [Project schema](https://github.com/sakthi-gyan/story-book/blob/main/server/src/schema.ts): `server/src/schema.ts`
- [Model gateway](https://github.com/sakthi-gyan/story-book/blob/main/server/src/openai.ts): `server/src/openai.ts`
- [Usage tracking](https://github.com/sakthi-gyan/story-book/blob/main/server/src/usage.ts): `server/src/usage.ts`
- [Project state](https://github.com/sakthi-gyan/story-book/blob/main/server/src/store.ts): `server/src/store.ts`
- [Storage adapters](https://github.com/sakthi-gyan/story-book/blob/main/server/src/storage/index.ts): `server/src/storage/index.ts`

### Delivery

- [Project library](https://github.com/sakthi-gyan/story-book/blob/main/client/src/steps/LibraryStep.tsx): `client/src/steps/LibraryStep.tsx`
- [Export assets](https://github.com/sakthi-gyan/story-book/blob/main/server/src/export/pack.ts): `server/src/export/pack.ts`
- [Agent package](https://github.com/sakthi-gyan/story-book/blob/main/server/src/export/agentPack.ts): `server/src/export/agentPack.ts`
- [Agent CLI](https://github.com/sakthi-gyan/story-book/blob/main/agent/cli.mjs): `agent/cli.mjs`

### Other components

- **Creator**
- **OpenAI**

## Connections

- Creator → Workflow app: uses (evidence: `README.md`)
- Workflow app → API client: requests (evidence: `client/src/App.tsx`)
- Workflow app → Project steps: shows steps (evidence: `client/src/App.tsx`)
- Workflow app → Pipeline stepper: shows progress (evidence: `client/src/App.tsx`)
- Workflow app → Guide mode: offers walkthrough (evidence: `client/src/App.tsx`)
- Workflow app → Project hooks: uses (evidence: `client/src/App.tsx`)
- Review interface → API client: sends review actions (evidence: `client/src/components/ReviewDrawer.tsx`)
- Review interface → Project derivations: derives review state (evidence: `client/src/components/ReviewDrawer.tsx`)
- Project steps → API client: requests workflow (evidence: `client/src/steps/ReferencesStep.tsx`)
- Project steps → Review interface: opens review
- Project hooks → API client: loads projects (evidence: `client/src/hooks.tsx`)
- Project hooks → Project derivations: derives status (evidence: `client/src/hooks.tsx`)
- Pipeline stepper → Project derivations: derives progress (evidence: `client/src/components/PipelineStepper.tsx`)
- Icon system → Icon registry: uses icons (evidence: `client/src/icons/DualToneIcon.tsx`)
- Workflow app → Visual theme: applies styling (evidence: `client/src/main.tsx`)
- API client → HTTP routes: calls API (evidence: `client/src/api.ts`)
- HTTP routes → PDF planning: starts parsing (evidence: `server/src/routes.ts`)
- HTTP routes → Reference sheets: starts generation (evidence: `server/src/routes.ts`)
- HTTP routes → Shot generation: dispatches shot actions (evidence: `server/src/routes.ts`)
- HTTP routes → Final rendering: dispatches renders (evidence: `server/src/routes.ts`)
- HTTP routes → Storyboard panels: dispatches boards (evidence: `server/src/routes.ts`)
- HTTP routes → Project state: reads and saves (evidence: `server/src/routes.ts`)
- PDF planning → Model gateway: requests model output (evidence: `server/src/pipeline/parsePlan.ts`)
- PDF planning → Prompt design: uses prompts (evidence: `server/src/pipeline/parsePlan.ts`)
- Reference sheets → Model gateway: requests images (evidence: `server/src/pipeline/references.ts`)
- Reference sheets → Prompt design: uses prompts (evidence: `server/src/pipeline/references.ts`)
- Shot generation → Model gateway: requests images (evidence: `server/src/pipeline/shots.ts`)
- Shot generation → Prompt design: uses prompts (evidence: `server/src/pipeline/shots.ts`)
- AI image review → Model gateway: requests review (evidence: `server/src/pipeline/review.ts`)
- AI image review → Prompt design: uses prompts (evidence: `server/src/pipeline/review.ts`)
- Storyboard panels → Shot generation: delegates generation
- Final rendering → Shot generation: delegates generation
- Model gateway → OpenAI: calls model service (evidence: `server/src/openai.ts`)
- Model gateway → Usage tracking: records tokens (evidence: `server/src/openai.ts`)
- PDF planning → Project state: updates project (evidence: `server/src/pipeline/parsePlan.ts`)
- Reference sheets → Project state: updates project (evidence: `server/src/pipeline/references.ts`)
- Shot generation → Project state: updates project (evidence: `server/src/pipeline/shots.ts`)
- AI image review → Project state: updates project (evidence: `server/src/pipeline/review.ts`)
- Project state → Project schema: validates state (evidence: `server/src/store.ts`)
- Project state → Storage adapters: persists data (evidence: `server/src/store.ts`)
- Project library → API client: loads project assets
- Project library → Export assets: downloads bundle (evidence: `README.md`)
- Export assets → Project state: packages project data
- Agent mode → API client: guides workflow (evidence: `client/src/pages/AgentLiveTerminal.tsx`)
- Agent CLI → Agent package: uses package
- Creator → Agent CLI: runs agent (evidence: `README.md`)
