How malcolmkhong/novara works
Novara is an AI novel-writing studio: authors create and structure a novel, direct a role-based agent run, review gated chapter changes, and finalize work into canon and searchable memory before exporting. The workbench also supports direct drafting, document browsing, import/export, and usage visibility. The README documents the principal run lifecycle and finalization guarantees; several route and UI internals are represented at their exact tree paths because their source was not sampled.
Main entry points: runtime.ts Agent runtime · db.ts Novel database · workbench-shell.tsx Writer workbench · route.ts Direct drafting
Components 25
Writer workbench
- Studio shell
src/components/novara/novara-app.tsx - Writer workbench
src/components/novara/writer/workbench-shell.tsx - Run conversation
src/components/novara/writer/conversation-pane.tsx - Document tree
src/lib/novara/doc-tree.ts - Chapter editor
src/components/novara/writer/chapter-editor.tsx
Agent and AI
- Run API
src/app/api/agent/runs/route.ts - Agent runtime
src/lib/agent/runtime.ts - Agent tools
src/lib/agent/tool-protocol.ts - AI router
src/lib/ai/router.ts - Provider adapters
src/lib/ai/providers/registry.ts - Direct drafting
src/app/api/ai/draft/route.ts
Novel canon
- Novel API
src/app/api/novels/[id]/route.ts - Chapter API
src/app/api/chapters/[id]/route.ts - Canon lifecycle
src/lib/novara/lifecycle.ts - Memory projection
src/lib/novara/sediment.ts - Review and QC
src/lib/novara/review.ts - Import and export
src/app/api/import/route.ts
Identity and data
- Novel database
src/lib/db.ts - Google sign-in
src/lib/firebase/client.ts - Request identity
src/middleware.ts
Usage and billing
- Credit charging
src/lib/credits/charge.ts - Usage records
src/lib/usage/usage-store.ts
Other components
- Author
- AI providers
- Neon Postgres
Connections 29
- Author → Studio shell: opens
- Studio shell → Writer workbench: renders
- Writer workbench → Run conversation: presents
- Writer workbench → Document tree: browses
- Writer workbench → Chapter editor: edits chapters
- Run conversation → Run API: starts runs
- Run API → Agent runtime: dispatches
- Agent runtime → Agent tools: executes tools
- Agent runtime → AI router: requests completions
- AI router → Provider adapters: resolves adapter
src/lib/ai/router.ts - Provider adapters → AI providers: calls
- Author → Direct drafting: requests draft
src/app/api/ai/draft/route.ts - Direct drafting → Novel database: reads chapter
src/app/api/ai/draft/route.ts - Direct drafting → Memory projection: retrieves memory
src/app/api/ai/draft/route.ts - Direct drafting → AI router: requests completion
- Author → Novel API: manages novel
src/app/api/novels/[id]/route.ts - Author → Chapter API: updates chapter
src/app/api/chapters/[id]/route.ts - Chapter API → Canon lifecycle: moves canon state
src/app/api/chapters/[id]/route.ts - Canon lifecycle → Memory projection: writes projection
src/lib/novara/lifecycle.ts - Canon lifecycle → Novel database: commits transaction
src/lib/novara/lifecycle.ts - Agent runtime → Review and QC: reviews chapters
- Agent runtime → Canon lifecycle: finalizes chapters
- Import and export → Novel database: restores records
src/app/api/import/route.ts - Request identity → Novel database: provides identity
src/lib/db.ts - Google sign-in → Author: authenticates
- Agent runtime → Credit charging: checks balance
- Credit charging → Usage records: records usage
src/lib/credits/charge.ts - Usage records → Novel database: persists usage
src/lib/usage/usage-store.ts - Novel database → Neon Postgres: stores records