Personal
Novel Engine
A system for writing long-form fiction with AI, which I plan to open-source. It stores the story's world as structured data (what is true, when it became true, on which draft, and which characters know it) and uses that to give models the right context for each scene.
01
Problem
AI is good at producing prose and bad at remembering. Over a long novel, details drift: a character knows something they shouldn't yet, a scar moves to the other arm, a subplot quietly disappears. I wanted a system that treats the story's world as data it can reason about.
02
How it's designed
- Canon lives in Neo4j as facts with a time range and a branch, so the system can answer what was true at a given point in the story, and in which draft.
- Characters' beliefs are stored separately from objective facts. That makes point-of-view writing, and catching a secret that leaks into the wrong scene, a query rather than a guess.
- Prose, summaries and style examples are embedded in PostgreSQL with pgvector for semantic search, always filtered by project, branch and visibility.
- Images, audio and video are treated as references in their own right, linked to characters, places and scenes, with captions and transcripts as a fallback when a model can't take the original.
- Every generated scene keeps a record of exactly what context went in and why each piece was chosen, so any output can be explained and replayed.
03
AI proposes, the author decides
The model never writes to canon directly. Drafting a scene produces a set of proposed changes, such as new events, updated facts and shifted beliefs, and the author accepts, edits or rejects each one. How much the AI can do on its own is up to the author, but destructive and costly actions always need a person to approve them.
04
Where it is now
Early. The prototype has been stabilised: deterministic tests that run without API keys or databases, explicit migrations for both stores, and structured logs that redact secrets and manuscript text. The current work is identity and tenancy: invite-only workspaces, roles, and isolation across the graph, vector store and exports, so it can run as an invite-only app here as well as self-hosted. The writing interface hasn't been built yet.
05
Stack
Python 3.13, FastAPI, Neo4j, PostgreSQL with pgvector, Alembic and Docker Compose. Models run through OpenRouter or any OpenAI-compatible local server, with authors bringing their own keys. There's no subscription and no platform credits. React front end to come.