How ilrein/openwrite works
OpenWrite is a web platform for planning and writing long-form fiction. A writer creates a project, develops a story map, expands story elements with AI, promotes chapter nodes into the manuscript, and edits chapters with autosave; Codex entries provide structured world-building alongside that workflow. The web client talks to a Hono API backed by D1, with authentication and encrypted user-supplied AI credentials. The README documents product capabilities; sampled source confirms key server wiring and graph-generation calls, while several UI and API-client connections are based on product documentation rather than inspected call sites.
Main entry points: routers/index.ts Application routes · graph.ts Story graph · db/index.ts D1 database · projects.tsx Project workspace
Components 20
Writing workspace
- Web application
apps/web/src/main.tsx - Project workspace
apps/web/src/routes/dashboard/projects.tsx - Story map
apps/web/src/routes/projects/$projectId/canvas.tsx - World codex
apps/web/src/routes/projects/$projectId/codex/$type.tsx - Manuscript editor
apps/web/src/routes/projects/$projectId/write.tsx - API clients
apps/web/src/lib/api/index.ts
Application API
- Worker API
apps/server/src/index.ts - Auth and workspace
apps/server/src/lib/auth.ts - Application routes
apps/server/src/routers/index.ts - Chapters and content
apps/server/src/routers/content.ts - Story graph
apps/server/src/routers/graph.ts - AI completion
apps/server/src/routers/ai.ts - AI key management
apps/server/src/routers/ai-providers.ts - Story expansion
apps/server/src/lib/story-expansion.ts
Persistence and identity
- D1 database
apps/server/src/db/index.ts - Domain schema
apps/server/src/db/schema/project.ts - Access middleware
apps/server/src/middleware/auth.ts
External services
- AI providers
- Email delivery
Other components
- Writer
Connections 25
- Writer → Web application: uses
README.md - Web application → Project workspace: routes to
- Project workspace → Story map: opens story map
README.md - Project workspace → World codex: opens codex
README.md - Project workspace → Manuscript editor: opens manuscript
README.md - Web application → API clients: requests data
- API clients → Worker API: calls API
- Worker API → Application routes: mounts
apps/server/src/index.ts - Worker API → Auth and workspace: forwards auth
apps/server/src/index.ts - Application routes → Chapters and content: mounts
apps/server/src/routers/index.ts - Application routes → Story graph: mounts
apps/server/src/routers/index.ts - Application routes → AI completion: mounts
apps/server/src/routers/index.ts - Application routes → AI key management: mounts
apps/server/src/routers/index.ts - Story graph → Story expansion: parses expansion
apps/server/src/routers/graph.ts - Story graph → AI completion: requests completion
apps/server/src/routers/graph.ts - Story graph → Chapters and content: promotes chapter
apps/server/src/routers/graph.ts - Chapters and content → D1 database: reads and writes
apps/server/src/routers/content.ts - Story graph → D1 database: reads and writes
apps/server/src/routers/graph.ts - Access middleware → Auth and workspace: checks session
apps/server/src/middleware/auth.ts - Access middleware → D1 database: checks membership
apps/server/src/middleware/auth.ts - Auth and workspace → D1 database: stores identity
apps/server/src/lib/auth.ts - Auth and workspace → Email delivery: sends actions
apps/server/src/lib/auth.ts - AI completion → AI providers: calls provider
README.md - AI key management → AI providers: configures keys
README.md - D1 database → Domain schema: uses schema