Skip to content
code-martinPublic
forked from ilrein/openwrite

About

Open-source AI-powered writing platform for novelists, screenwriters, and creative writers.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

OpenWrite

Open-source, AI-powered writing platform for novelists, screenwriters, and creative writers. ✨📝

OpenWrite helps you plan, organize, and write long-form fiction — with an AI assistant that runs on your own API keys. No subscription, no markup on tokens, no lock-in. Your manuscript lives in your database (or ours, or one you self-host).

Try it: openwrite.iliareingold.com

One sentence becomes a connected story map: a premise node expands into acts, acts into chapters, and a chapter is promoted straight into the manuscript

One sentence in → a connected story map out. Expand any node with AI, then promote chapters straight into your manuscript.

What works today

  • 🗺️ Story map (node-based AI generation) — describe your story in one sentence, then expand it level by level: premise → acts → chapters → scenes, each generated as connected nodes on a visual canvas with auto-layout. Chapter nodes promote directly into your manuscript
  • ✍️ Rich text editor with auto-save — a distraction-light Tiptap editor that persists your manuscript as you type, with live word counts and per-project progress tracking
  • 📖 Chapter management — create, rename, reorder, and write per-chapter, with safe concurrent-edit detection
  • 🤖 AI writing assistant (bring your own key) — chat with an assistant that knows your project's title, genre, and characters, then insert its suggestions straight into your manuscript. Supported providers:
    • OpenRouter (one key, hundreds of models — easiest start)
    • OpenAI, Anthropic, Groq, Gemini, Cohere
    • Ollama (fully local models, fully private)
  • 📚 Codex — structured world-building: characters, locations, lore entries, and plot points, organized per project
  • 📤 Markdown export — download your full manuscript as Markdown
  • 🗂️ Projects — novels, trilogies, series, short story collections, screenplays; genre, status, and target word count tracking
  • 🔐 Auth & workspaces — email/password accounts with personal workspaces; API keys are encrypted at rest (AES-GCM)

In progress

Feature Status
Streaming AI responses Planned next
Character auto-linking in story-map expansion Planned next
Manuscript export (DOCX / EPUB) Planned
Real-time collaboration Designed, not built

Found a bug or want to influence what gets built? Open an issue.

Why OpenWrite

  • Your keys, your costs. Tools like Sudowrite resell AI tokens at a markup. OpenWrite talks to providers directly with your key — you pay provider rates, or nothing at all with local Ollama models.
  • Your words, your data. AGPL-3.0 licensed and self-hostable on Cloudflare's free tier. No training on your manuscript, no vendor holding your novel hostage.
  • Built for fiction. Characters, lore, and plot structure are first-class concepts, not folders of notes.

Tech stack

TypeScript end to end: React 19 + TanStack Router + TailwindCSS/shadcn-ui on the front, Hono on Cloudflare Workers with D1 (SQLite) + Drizzle ORM on the back, Better Auth for authentication. Bun workspaces with mprocs for dev orchestration and Vitest for tests.

Getting started

bun install

Database setup

This project uses Cloudflare D1 (SQLite) with Drizzle ORM. Local development runs against a local D1 instance managed by wrangler dev.

  1. Copy the example environment file and fill in the values (any random strings work locally):
cp apps/server/.dev.vars.example apps/server/.dev.vars

apps/server/.dev.vars needs BETTER_AUTH_SECRET, BETTER_AUTH_URL, CORS_ORIGIN, and ENCRYPTION_KEY (a base64-encoded 32-byte key, e.g. openssl rand -base64 32).

  1. Apply the schema:
bun db:push

Run it

bun dev

Open http://localhost:3001 for the web app. The API runs at http://localhost:3000.

Self-hosting

OpenWrite deploys as a single Cloudflare Worker (API + static frontend) backed by a D1 database — comfortably within Cloudflare's free tier for personal use:

wrangler d1 create your-database        # then update apps/server/wrangler.jsonc
wrangler secret put BETTER_AUTH_SECRET  # plus BETTER_AUTH_URL, CORS_ORIGIN, ENCRYPTION_KEY
bun run deploy

Project structure

openwrite/
├── apps/
│   ├── web/         # Frontend (React + TanStack Router)
│   ├── server/      # Hono REST API on Cloudflare Workers
│   └── docs/        # VitePress documentation

Available scripts

  • bun dev — start web + server in an mprocs TUI (db-studio and docs available as extra panes)
  • bun build — build all applications
  • bun dev:web / bun dev:server — start a single app
  • bun test — run the Vitest suites (web + server)
  • bun quality — type checking + linting (run before committing)
  • bun db:push — push schema changes to the database
  • bun db:studio — open the Drizzle Studio database UI
  • bun run deploy — build and deploy to Cloudflare

Contributing

Issues and PRs are welcome — the roadmap above is a good place to start, and the codebase is small enough to learn in an afternoon. Run bun quality before submitting.

License

AGPL-3.0

About

Open-source AI-powered writing platform for novelists, screenwriters, and creative writers.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages