# dukechristyd/garlea-storywriter architecture

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

- Interactive diagram: https://gitdiagram.com/dukechristyd/garlea-storywriter
- Repository: https://github.com/dukechristyd/garlea-storywriter

## Overview

Garlea Storywriter is a collaborative interactive-fiction editor. Writers enter through Google sign-in or sandbox preview, then select and edit stories and chapters, manage cast and suggestions, and optionally playtest Ink-style branches. The app persists work locally and can sync it to Firebase, while version history supports rollback and Discord can announce activity. The graph reflects calls visible in excerpts and component references in the source index; README documentation was empty, so unsampled capabilities are represented only where the index and excerpts support them.

Main entry points: [`garlea-storywriter/src/App.tsx`](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/App.tsx) (Workspace Controller), [`garlea-storywriter/src/types/story.ts`](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/types/story.ts) (Story Types), [`garlea-storywriter/src/services/versionService.ts`](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/services/versionService.ts) (Version Service), [`garlea-storywriter/src/services/firebase.ts`](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/services/firebase.ts) (Firebase Auth and DB)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Writer Workflow"]
  node_app["Workspace Controller<br/>[App.tsx]"]
  node_login["Login Screen"]
  node_chapters["Chapter Navigator<br/>[ChapterList.tsx]"]
  node_tabs["Story Tabs"]
  node_editor["Story Editor<br/>[StoryEditor.tsx]"]
  node_characters["Cast Manager"]
  node_suggestions["Suggestions"]
  node_conflicts["Sync Conflicts"]
  node_history["Version History"]
  node_settings["Workspace Settings<br/>[SettingsModal.tsx]"]
end

subgraph group_persistence["Persistence and Identity"]
  node_storage["Story Storage<br/>[storageService.ts]"]
  node_versions["Version Service<br/>[versionService.ts]"]
  node_firebase["Firebase Auth and DB<br/>[firebase.ts]"]
  node_firestore[("Firestore")]
  node_local[("Browser Storage")]
end

subgraph group_extensions["Playtest and Integrations"]
  node_inkmodal["Ink Playtest UI"]
  node_ink["Ink Parser<br/>[inkEngine.ts]"]
  node_discord["Discord Notifier<br/>[discordService.ts]"]
  node_discordsvc["Discord Webhook"]
  node_ai["Custom Story API"]
end

subgraph group_model["Story Domain"]
  node_story["Story Types<br/>[story.ts]"]
end

node_writer(("Writer"))

node_writer -->|"starts with"| node_login
node_app -->|"renders"| node_login
node_app -->|"signs in via"| node_firebase
node_app -->|"loads and saves"| node_storage
node_app -->|"renders"| node_tabs
node_app -->|"renders"| node_chapters
node_app -->|"renders"| node_editor
node_app -->|"renders"| node_characters
node_app -->|"renders"| node_suggestions
node_app -->|"renders"| node_conflicts
node_app -->|"renders"| node_history
node_app -->|"renders"| node_settings
node_app -->|"creates snapshots"| node_versions
node_app -->|"fetches history"| node_versions
node_storage -->|"gets instances"| node_firebase
node_storage -->|"syncs stories"| node_firestore
node_storage -->|"persists settings and stories"| node_local
node_versions -->|"gets instances"| node_firebase
node_versions -->|"stores snapshots"| node_firestore
node_versions -->|"caches snapshots"| node_local
node_firebase -->|"initializes database"| node_firestore
node_firebase -->|"authenticates"| node_writer
node_app -->|"updates story data"| node_story
node_editor -->|"edits chapters"| node_story
node_chapters -->|"navigates chapters"| node_story
node_characters -->|"manages cast"| node_story
node_suggestions -->|"manages suggestions"| node_story
node_history -->|"displays versions"| node_story
node_inkmodal -->|"parses chapter"| node_ink
node_editor -->|"opens playtest"| node_inkmodal
node_editor -.->|"requests assistance"| node_ai
node_settings -->|"tests webhook"| node_discord
node_app -.->|"notifies activity"| node_discord
node_discord -->|"posts webhook"| node_discordsvc
node_settings -->|"configures workspace"| node_story

click node_app "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/App.tsx"
click node_login "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/IntroLoginScreen.tsx"
click node_chapters "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/ChapterList.tsx"
click node_tabs "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/ChromeTabSidebar.tsx"
click node_editor "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/StoryEditor.tsx"
click node_characters "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/CharactersDrawer.tsx"
click node_suggestions "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/SuggestionsDrawer.tsx"
click node_conflicts "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/SyncConflictModal.tsx"
click node_history "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/VersionHistoryModal.tsx"
click node_settings "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/SettingsModal.tsx"
click node_storage "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/services/storageService.ts"
click node_versions "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/services/versionService.ts"
click node_firebase "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/services/firebase.ts"
click node_inkmodal "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/InkPlaytestModal.tsx"
click node_ink "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/services/inkEngine.ts"
click node_discord "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/services/discordService.ts"
click node_story "https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/types/story.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_app,node_login,node_chapters,node_tabs,node_editor,node_characters,node_suggestions,node_conflicts,node_history,node_settings toneBlue
class node_storage,node_versions,node_firebase,node_firestore,node_local toneAmber
class node_inkmodal,node_ink,node_discord,node_discordsvc,node_ai toneMint
class node_story toneRose
class node_writer toneIndigo
```

## Components

### Writer Workflow

- [Workspace Controller](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/App.tsx): `garlea-storywriter/src/App.tsx`
- [Login Screen](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/IntroLoginScreen.tsx): `garlea-storywriter/src/components/IntroLoginScreen.tsx`
- [Chapter Navigator](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/ChapterList.tsx): `garlea-storywriter/src/components/ChapterList.tsx`
- [Story Tabs](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/ChromeTabSidebar.tsx): `garlea-storywriter/src/components/ChromeTabSidebar.tsx`
- [Story Editor](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/StoryEditor.tsx): `garlea-storywriter/src/components/StoryEditor.tsx`
- [Cast Manager](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/CharactersDrawer.tsx): `garlea-storywriter/src/components/CharactersDrawer.tsx`
- [Suggestions](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/SuggestionsDrawer.tsx): `garlea-storywriter/src/components/SuggestionsDrawer.tsx`
- [Sync Conflicts](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/SyncConflictModal.tsx): `garlea-storywriter/src/components/SyncConflictModal.tsx`
- [Version History](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/VersionHistoryModal.tsx): `garlea-storywriter/src/components/VersionHistoryModal.tsx`
- [Workspace Settings](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/SettingsModal.tsx): `garlea-storywriter/src/components/SettingsModal.tsx`

### Persistence and Identity

- [Story Storage](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/services/storageService.ts): `garlea-storywriter/src/services/storageService.ts`
- [Version Service](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/services/versionService.ts): `garlea-storywriter/src/services/versionService.ts`
- [Firebase Auth and DB](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/services/firebase.ts): `garlea-storywriter/src/services/firebase.ts`
- **Firestore**
- **Browser Storage**

### Playtest and Integrations

- [Ink Playtest UI](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/components/InkPlaytestModal.tsx): `garlea-storywriter/src/components/InkPlaytestModal.tsx`
- [Ink Parser](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/services/inkEngine.ts): `garlea-storywriter/src/services/inkEngine.ts`
- [Discord Notifier](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/services/discordService.ts): `garlea-storywriter/src/services/discordService.ts`
- **Discord Webhook**
- **Custom Story API**

### Story Domain

- [Story Types](https://github.com/dukechristyd/garlea-storywriter/blob/main/garlea-storywriter/src/types/story.ts): `garlea-storywriter/src/types/story.ts`

### Other components

- **Writer**

## Connections

- Writer → Login Screen: starts with (evidence: `garlea-storywriter/src/components/IntroLoginScreen.tsx`)
- Workspace Controller → Login Screen: renders (evidence: `garlea-storywriter/src/App.tsx`)
- Workspace Controller → Firebase Auth and DB: signs in via (evidence: `garlea-storywriter/src/App.tsx`)
- Workspace Controller → Story Storage: loads and saves (evidence: `garlea-storywriter/src/App.tsx`)
- Workspace Controller → Story Tabs: renders (evidence: `garlea-storywriter/src/App.tsx`)
- Workspace Controller → Chapter Navigator: renders (evidence: `garlea-storywriter/src/App.tsx`)
- Workspace Controller → Story Editor: renders (evidence: `garlea-storywriter/src/App.tsx`)
- Workspace Controller → Cast Manager: renders (evidence: `garlea-storywriter/src/App.tsx`)
- Workspace Controller → Suggestions: renders (evidence: `garlea-storywriter/src/App.tsx`)
- Workspace Controller → Sync Conflicts: renders (evidence: `garlea-storywriter/src/App.tsx`)
- Workspace Controller → Version History: renders (evidence: `garlea-storywriter/src/App.tsx`)
- Workspace Controller → Workspace Settings: renders (evidence: `garlea-storywriter/src/App.tsx`)
- Workspace Controller → Version Service: creates snapshots (evidence: `garlea-storywriter/src/App.tsx`)
- Workspace Controller → Version Service: fetches history (evidence: `garlea-storywriter/src/App.tsx`)
- Story Storage → Firebase Auth and DB: gets instances (evidence: `garlea-storywriter/src/services/storageService.ts`)
- Story Storage → Firestore: syncs stories (evidence: `garlea-storywriter/src/services/storageService.ts`)
- Story Storage → Browser Storage: persists settings and stories (evidence: `garlea-storywriter/src/services/storageService.ts`)
- Version Service → Firebase Auth and DB: gets instances (evidence: `garlea-storywriter/src/services/versionService.ts`)
- Version Service → Firestore: stores snapshots (evidence: `garlea-storywriter/src/services/versionService.ts`)
- Version Service → Browser Storage: caches snapshots (evidence: `garlea-storywriter/src/services/versionService.ts`)
- Firebase Auth and DB → Firestore: initializes database (evidence: `garlea-storywriter/src/services/firebase.ts`)
- Firebase Auth and DB → Writer: authenticates (evidence: `garlea-storywriter/src/services/firebase.ts`)
- Workspace Controller → Story Types: updates story data (evidence: `garlea-storywriter/src/App.tsx`)
- Story Editor → Story Types: edits chapters (evidence: `garlea-storywriter/src/components/StoryEditor.tsx`)
- Chapter Navigator → Story Types: navigates chapters (evidence: `garlea-storywriter/src/components/ChapterList.tsx`)
- Cast Manager → Story Types: manages cast (evidence: `garlea-storywriter/src/components/CharactersDrawer.tsx`)
- Suggestions → Story Types: manages suggestions (evidence: `garlea-storywriter/src/components/SuggestionsDrawer.tsx`)
- Version History → Story Types: displays versions (evidence: `garlea-storywriter/src/components/VersionHistoryModal.tsx`)
- Ink Playtest UI → Ink Parser: parses chapter (evidence: `garlea-storywriter/src/components/InkPlaytestModal.tsx`)
- Story Editor → Ink Playtest UI: opens playtest (evidence: `garlea-storywriter/src/components/StoryEditor.tsx`)
- Story Editor → Custom Story API: requests assistance
- Workspace Settings → Discord Notifier: tests webhook (evidence: `garlea-storywriter/src/components/SettingsModal.tsx`)
- Workspace Controller → Discord Notifier: notifies activity (evidence: `garlea-storywriter/src/App.tsx`)
- Discord Notifier → Discord Webhook: posts webhook (evidence: `garlea-storywriter/src/services/discordService.ts`)
- Workspace Settings → Story Types: configures workspace (evidence: `garlea-storywriter/src/components/SettingsModal.tsx`)
