The Problem

Authors who want to edit narrative text by rearranging visual timelines must manually keep story events, character locations, and actions in sync. Maintaining that consistency is error‑prone and slows iterative writing or user‑study design.

What This Does

The repo implements a browser‑based editor that visualizes a story’s chronology, characters, and actions, then drives GPT‑4o prompts to rewrite the underlying text. Core UI lives in src/App.tsx and src/view/VisualWritingInterface.tsx, while the domain model lives in src/model/Model.tsx and related prompt files such as src/model/prompts/textExtractors/SentenceActionsExtractor.tsx. Study‑specific flows (e.g., baseline or reading tasks) are in src/study/StudyInterface.tsx and the data files under src/study/data/.

How It Is Wired

Execution starts from index.html, which loads the Vite bundle generated from src/main.tsx. main.tsx mounts <App /> (in src/App.tsx) onto the DOM. <App /> creates a Model instance (src/model/Model.tsx) and passes it to the VisualWritingInterface.

  • Model (src/model/Model.tsx) – the central hub (42 inbound imports, 9 outbound). It holds the story state, orchestrates prompt execution, and exposes methods used by UI components and study modules.
  • StudyModel (src/study/StudyModel.tsx) – secondary hub (19 inbound, 8 outbound) that wraps Model for experimental protocols.
  • Prompt extractors (e.g., SentenceActionsExtractor.tsx, EntitiesExtractor.tsx) are invoked by Model to turn text into visual elements; they call OpenAI via the generic BasePrompt utilities.
  • View components (src/view/*) render the timeline, entity nodes, and editors. They call back into Model for mutations, which then trigger GPT‑4o calls and update the UI.

Circular imports link Model.tsx, StudyModel.tsx, and HistoryModel.tsx, meaning each module both imports and is imported by the others. This inflates the blast radius: a change in any of these three ripples through 42 dependent modules. Deeply nested functions (up to 14 levels) appear in EntityNodeComponent.tsx and SentenceActionsExtractor.tsx, making the control flow hard to trace. Large data files (src/study/data/TextF.tsx, TextG.tsx) each exceed 650 lines, bundling many story variants in a single module.

How To Use It

# Clone the repo
git clone https://github.com/moses-y/VisualStoryWriting
cd VisualStoryWriting

# Install dependencies
npm install

# Run the development server
npm run dev

The UI prompts for an OpenAI API key; enter it in the launch dialog—no environment variable is required. The application runs entirely in the browser; no backend server or database is started.

Real‑World Use

A research team can embed this UI in a participant‑facing web app, load a story script via the src/study/data/ files, and run a controlled study where users reorder timeline nodes. Each reorder triggers a GPT‑4o prompt (through the BasePrompt utilities) that suggests textual edits, which are then displayed instantly in the text editor pane.

Code Health & Issues

  • HIGH – Import cycles – 24 modules, e.g., src/model/Model.tsx, src/study/StudyModel.tsx, src/model/HistoryModel.tsx.
  • HIGH – Hub modules – src/model/Model.tsx and src/study/StudyModel.tsx have the highest inbound import counts.
  • HIGH – Deep nesting – Up to 14‑level indentation in src/view/entityActionView/EntityNodeComponent.tsx and related files.
  • MED – High branching density – 47 branches across 144 lines in src/model/TextUtils.tsx, src/model/SlateUtils.tsx, src/view/locationView/LocationsEditor.tsx.
  • MED – Duplicated code – Repeated 6‑line block in src/study/BaselineInterface.tsx and src/view/TextEditor.tsx.
  • MED – Oversized files – src/study/data/TextF.tsx and src/study/data/TextG.tsx each contain >650 lines.

Health audit findings

  • HIGH – Pin third‑party GitHub Actions to a commit SHA (.github/workflows/deploy.yml).
  • HIGH – No test suite; 60 source files lack any test files.
  • MED – Declare least‑privilege GITHUB_TOKEN permissions (.github/workflows/deploy.yml).
  • MED – Enable Dependabot or Renovate for dependency updates.
  • MED – Add a dependency‑vulnerability scan step in CI.
  • MED – Move large video assets (public/videos/*.mp4) to Git LFS or external storage.
  • LOW – Set explicit timeout-minutes on workflow jobs.
  • LOW – Add conventional files (.editorconfig, .gitattributes, formatter config).

The Bottom Line

The project delivers a functional, GPT‑augmented visual story editor with a clear UI‑to‑model flow, but the core model is a large, highly coupled hub surrounded by import cycles and deep nesting, which raises maintenance risk. Adding automated tests, breaking the hub into smaller services, and addressing the listed CI and repository hygiene issues would make it safer for production or research use. Engineers comfortable with React, TypeScript, and prompt engineering will find the codebase usable after these improvements.