Skip to content
tkdyun.xyz

Penrira

AI-assisted planning and manuscript editing for long-form fiction

Generative AI

Year
2026
Role
Web & Desktop Development
Stack
Next.js · TypeScript · Zustand · PostgreSQL · Drizzle ORM · Electron

Overview

Penrira is a web and desktop application for planning and writing long-form fiction. It connects worldbuilding, character relationships, plot events, and episode manuscripts in a single workspace, reducing the repeated work of checking earlier chapters and scattered notes.

Writers can outline scenes, draft manuscripts, and track episode progress without connecting an AI provider. Optional AI tools support scene planning, drafting, and revision using context drawn from the current project. The writer reviews proposed changes and remains responsible for story decisions.

Preview

Penrira manuscript editor with episode text on the left and scene plans and AI drafting tools on the right.

The manuscript workspace, captured with a sample story. Scene plans remain visible alongside the draft.

Pipeline — technical architecture

Planning and Manuscript Workflow

Worldbuilding entries, characters, relationships, and events form the project’s reference material. Writers connect events to episodes, define each episode’s goal, and arrange scenes before moving into the manuscript editor.

  1. Project planning: Organize the setting, character motivations, relationships, and causal links between events.
  2. Episode design: Define the episode goal, scene order, plot connections, and planning notes.
  3. Manuscript editing: Write with Markdown editing, preview, automatic saving, and optional scene-level AI drafts.
  4. Review and revision: Inspect suggestions, compare changes, and apply selected revisions.

Planning completeness is evaluated across premise, world, character, conflict, causality, and ending. These checks describe the coverage of the planning inputs, rather than the literary quality of the manuscript.

Episode planning screen showing scene order, locations, summaries, and pacing controls.

Episode planning: writers define scenes and their sequence before drafting the manuscript. Select the image to view the full-resolution original.

Context Construction for AI Drafting

Sending an entire story bible and every previous chapter with each request makes the input grow as the story develops. The drafting pipeline instead assembles context around the current episode: relevant characters and relationships, world rules, previous events, and the scene plan.

Context sections carry priorities. When the estimated token budget is exceeded, optional material is removed first. Essential continuity information is retained, with a warning if the required sections alone exceed the budget. Unspecified details are also passed as constraints so that the model does not silently turn an undecided setting into an established fact.

Poster diagram mapping project information, world rules, characters, relationships, and prior episodes into drafting context.

Context selection: episode-relevant material is assembled into a shared reference. Original Korean poster artwork. Select the image to view the full-resolution original.

Scene-by-Scene Generation

Each scene request reuses the shared story context and adds the text written so far together with instructions for the next scene. Keeping the shared prefix stable allows prompt caching where supported, while the growing draft provides continuity between scenes.

Three scene requests reuse a common context prefix while appending earlier scenes and the next scene instruction.

Scene generation: a reusable context prefix is combined with accumulated prose and scene-specific instructions. Original Korean poster artwork. Select the image to view the full-resolution original.

Manuscript Retrieval and Source References

Project chat searches manuscripts and reference material in the browser before sending selected passages to the model. The retrieval layer extracts query terms, removes common expressions and Korean particles, and ranks short passages from drafts, character profiles, events, episode plans, and notes.

Five-step retrieval diagram: question, query terms, overlapping passages, ranking, and answers with source references.

Retrieval pipeline: the browser searches story material and sends selected passages to the model. The example story in the poster is illustrative. Select the image to view the full-resolution original.

This is lexical retrieval, with limited partial matching for longer Korean words. It does not use embedding-based semantic search. The selection limits repeated and overlapping passages so that a single source does not dominate the context.

Retrieved passages receive reference identifiers that connect answers to the original text. Search coverage and read failures are included in the context, helping distinguish missing search results from evidence that something does not exist in the story.

Illustrative answer with R1 and R2 citations linking claims to manuscript and worldbuilding passages.

Grounded answers: source references let the writer check a claim against the original passage. This poster is an illustrative example, not an application screenshot. Select the image to view the full-resolution original.

Revision Safety and Storage

AI revisions are presented for comparison before they replace a manuscript. If the source text changes after a request begins, the stale result cannot be applied. The application retains the previous draft for recovery and supports reverting an applied revision when subsequent edits have not changed it.

A storage adapter separates browser storage from cloud persistence. PostgreSQL stores project settings as a JSONB bundle and episode manuscripts as separate text records, allowing project metadata to be loaded without fetching every full draft.

Cloud editing uses a per-project lease to prevent competing devices from overwriting the same bundle. Other devices open the project in read-only mode until the writer explicitly takes over editing. Heartbeats renew the lease, which expires after 90 seconds without a signal. Acquisition, renewal, and takeover decisions are isolated in pure functions for verification.

Core Components

  • Next.js, React, and TypeScript: Application routes, interface, and shared domain contracts.
  • Zustand and CodeMirror: Editor state and manuscript editing.
  • React Flow: Character relationship visualization.
  • PostgreSQL, Drizzle ORM, and Auth.js: Cloud persistence and authentication.
  • Anthropic and OpenAI SDKs: Optional AI assistance with task-specific context.
  • Electron: Desktop packaging with a bundled Next.js standalone server and local storage mode.

Implementation Tradeoffs

Lexical retrieval can miss synonyms and indirect references, while context size is estimated rather than measured with a model-specific tokenizer. The interface therefore keeps source passages and revision comparisons available for the writer to inspect. Desktop builds use a local mode and check that server environment values are not included in the installation package.

Search the site

Choose a destination, or type to search.