A mobile‑first web app and workflow toolkit that turns your big, nested outline into a polished manuscript. It combines Next.js + Tailwind for the UI, n8n for orchestration, Supabase for the data layer, and Fly.io for hosting. It leverages an advanced LLM like GPT-4.1 (or similar models with large context windows, e.g., 1 million tokens) for its intelligence, offering a blend of power, cost-effectiveness, and smart content generation.
| Phase | Purpose | Key Workflow |
|---|---|---|
| 1. World‑Building | Capture facts about characters, lore, timelines. Extract triples & store them for semantic recall. | /webhook/world-builder |
| 2. Multi‑Level Outlining | Nest writing‑formula steps (Hero's Journey, etc.) 3–4 layers deep. | /webhook/outline-generator |
| 3. Draft Writing | Generate, iterate, and commit prose for each section. | /webhook/draft-generator |
Each phase is a standalone n8n workflow with its own webhook, so you can toggle between them in the mobile UI.
Mobile PWA (Next.js) <-----> Supabase Edge Functions <-----> Supabase Postgres
| | (pgvector, ltree)
| |
+---------------------+
| n8n (Fly.io) |
| – World Builder |
| – Outliner |
| – Draft Writer |
+---------------------+
|
|
LLM (GPT-4.1)
- Next.js / React – routes & API proxies.
- Tailwind CSS – utility‑first, mobile‑first.
- Headless UI + react‑swipeable – swipe drawers for TOC & settings.
- React Query – caching & realtime updates.
- n8n – three modular workflows (one per phase) exposed via webhooks.
- Supabase Postgres – single source‑of‑truth with pgvector + ltree.
- Realtime – push section updates to the UI.
- Auth – row‑level security.
- Fly.io – Dockerized deployments for both Next.js and n8n.
| Table | Purpose | Highlight Columns |
|---|---|---|
sections |
Outline & manuscript tree | id, parent_id, position (ltree), title, is_title (bool), content_type (outline|draft|final), formula_layer, text, outline_notes |
formulas |
Writing‑cycle templates | id, name, mood_id, template, default_length, default_temp |
moods |
Voice & style snippets | id, label, prompt_snippet |
entities |
Characters / objects / places | id, type, name, attributes (jsonb), biography |
facts |
RDF‑style triples | id, subject_id, predicate, object, started_at, ended_at, context_section |
embeddings |
Semantic search | id, section_id, vector (pgvector) |
ltreeonsections.position– fast subtree queries.- Full‑text index on
sections.text. pgvectoronembeddings.vectorfor similarity search.- JSONB GIN on
entities.attributes.
- Webhook → Function (normalize) → Airtable/Supabase upsert
entities - HTTP Request to LLM → extract triples & attributes
- SplitInBatches → insert into
facts - Respond with JSON form for UI pre‑fill
- Fetch current context (parent section)
- For each formula step: HTTP → LLM to get sub‑outline (requires very detailed prompts).
- Merge & write into
sections(content_type=outline) - Return updated outline JSON
- Build prompt from
sections,moods,formulas(requires very detailed prompts). - HTTP → LLM generate prose.
- Engage in an iterative refinement process with the user, allowing for multiple rounds of feedback and LLM-driven revisions (individual revisions are not stored).
- Commit final text (
content_type=final) + Git mirror (optional). - Slack/email notification
- Node >= 18
- Docker & Fly CLI
- Supabase account (free tier OK)
- n8n cloud or self‑host
# /.env
SUPABASE_URL=…
SUPABASE_ANON_KEY=…
N8N_WEBHOOK_URL=https://<flyapp>.fly.dev/webhook/
OPENAI_API_KEY=…yarn install
supabase start # spin up local Postgres
npx supabase db push # apply schema
npx supabase gen types typescript --local
yarn dev # next dev on http://localhost:3000fly launch # generates fly.toml
fly deploy # pushes Next.js
fly scale vm shared-cpu-1xFor n8n, either:
- Use n8n Cloud → set
N8N_WEBHOOK_URLaccordingly, or fly launcha second app with the n8n Docker image.
- Cursor AI: prompt it to scaffold React components & API routes.
- Detailed Prompts: Crafting highly detailed and specific prompts for the LLM is crucial for achieving desired outputs in all phases.
- Branch‑per‑chapter workflow: use Supabase RLS + Git history to prevent merge pain.
- Error Handling: every AI call in n8n gets an error branch → Slack.
- Testing: Thoroughly test workflows, potentially using mock LLM responses for consistency and focusing on data integrity within Supabase.
- Visual timeline Gantt chart for facts & events
- Embedding‑powered "similar scene" suggestions
MIT © Jeff Steele