How xiaoran132/story-editor works
Story Editor is an AI-powered interactive-fiction platform with two implemented user journeys: authors generate and refine a story before publishing; players stream generated turns, make choices, and revisit branches. Go is the business and persistence boundary, while the Python Agent generates narrative output using per-request LLM settings supplied by Go. The README documents the main capabilities and service boundaries; some internal wiring is inferred only where that documentation is explicit, since most handler and graph source was not sampled.
Main entry points: main.go HTTP routes · story_graph.py Generation pipeline · repository Repositories · play.go Play service
Components 19
Web experience
- Next.js application
frontend/src/app - Story editor
frontend/src/components/editor/StoryEditor.tsx - Play interface
frontend/src/components/play - Login state
frontend/src/store/authStore.ts - API client
frontend/src/lib/api.ts
Go application
- HTTP routes
backend/main.go - JWT middleware
backend/internal/middleware/auth.go - Story service
backend/internal/service/story.go - Play service
backend/internal/service/play.go - LLM settings and billing
backend/internal/service/llm.go - Agent client
backend/internal/service/agent_client.go - Repositories
backend/internal/repository
AI generation
- Generation pipeline
agent/app/graph/story_graph.py - Streaming writer
agent/app/graph/story_graph.py - Turn structurer
agent/app/graph/story_graph.py - Optional review
agent/app/graph/story_graph.py
Data and models
- PostgreSQL
- OpenAI-compatible LLM
Other components
- Author or player
Connections 23
- Author or player → Next.js application: uses
- Next.js application → Login state: manages login
- Story editor → API client: requests authoring
- Play interface → API client: requests turns
- API client → HTTP routes: calls API
- HTTP routes → JWT middleware: protects routes
- HTTP routes → Story service: dispatches story
- HTTP routes → Play service: dispatches play
- HTTP routes → LLM settings and billing: dispatches LLM settings
- Story service → Repositories: reads and writes
- Play service → Repositories: reads and writes
- LLM settings and billing → Repositories: reads and writes
- Repositories → PostgreSQL: persists data
- Play service → Agent client: requests generation
- Agent client → Generation pipeline: sends requests
- Generation pipeline → Streaming writer: streams prose
- Generation pipeline → Turn structurer: generates turn data
- Generation pipeline → Optional review: may invoke
- Streaming writer → OpenAI-compatible LLM: generates text
- Turn structurer → OpenAI-compatible LLM: generates metadata
- Optional review → OpenAI-compatible LLM: checks output
- LLM settings and billing → OpenAI-compatible LLM: tests and probes
- Agent client → Play interface: streams SSE