nyxcore-systems
5 min read

From Brainstorm to Beat: Crafting nyxBook's AI-Powered Idea Pipeline

We just rolled out nyxBook's new Idea Pipeline, a game-changer for writers. Discover how AI helps turn fleeting thoughts into structured story beats, from schema to a seamless UI.

AIFullstack DevelopmentNext.jstRPCPrismaLLMWriting ToolsProductivity

Every writer knows the feeling: a brilliant idea sparks, a fleeting thought for a character twist, a vivid image for a scene. But how do you capture it? More importantly, how do you integrate it into the sprawling tapestry of your novel without losing it to the ether of loose notes?

At nyxBook, our mission is to empower writers, making the complex process of novel creation more intuitive and less daunting. Our latest major feature tackles this head-on: the AI-Powered Idea Pipeline. It's designed to transform those ephemeral sparks into actionable story elements, guiding them from a raw thought to a fully incorporated beat within your narrative.

The Vision: Bridging the Gap Between Inspiration and Structure

Imagine a system where you jot down a quick idea – "A detective haunted by a past case finds a clue in a forgotten jazz club" – and your writing assistant immediately suggests where it might fit: Chapter 3, Beat 5, because it introduces the protagonist's internal conflict and sets up the noir atmosphere. Then, with a click, you accept the suggestion, and that idea is now a tangible part of your story's framework.

That's the core of nyxBook's new Idea Pipeline. It's not just a place to store ideas; it's an intelligent assistant that helps you weave them into your story's fabric. Beyond individual idea placement, we're also building capabilities for AI-powered beat refactoring, where the system analyzes your entire story — characters, motifs, world progression — and suggests structural improvements.

Under the Hood: Building a Smart Story Assistant

Bringing this vision to life required a full-stack effort, touching every layer of our application.

The Foundation: Evolving the Data Model with Prisma

At the heart of the new system is the BookIdea model. We introduced it to our prisma/schema.prisma to meticulously track each idea's journey:

prisma
// prisma/schema.prisma
model BookIdea {
  id               String   @id @default(uuid())
  bookId           String
  book             Book     @relation(fields: [bookId], references: [id])
  content          String
  tags             String[]
  status           IdeaStatus @default(LOOSE) // LOOSE, SUGGESTED, ASSIGNED, INCORPORATED

  // AI Suggestion fields
  suggestedBeatId  String?
  suggestedBeat    BookBeat? @relation("SuggestedIdeas", fields: [suggestedBeatId], references: [id])
  suggestedChapterNum Int?
  suggestedReason  String?

  // User Assignment fields
  assignedBeatId   String?
  assignedBeat     BookBeat? @relation("AssignedIdeas", fields: [assignedBeatId], references: [id])
  assignedChapterNum Int?

  createdAt        DateTime @default(now())
  updatedAt        DateTime @updatedAt
}

enum IdeaStatus {
  LOOSE
  SUGGESTED
  ASSIGNED
  INCORPORATED
}

This model allows us to track an idea from its initial LOOSE state, through SUGGESTED placement by the AI, to being ASSIGNED by the writer, and finally INCORPORATED into the actual manuscript content. We also added relations to the Book and Tenant models, ensuring ideas are correctly scoped and organized.

The Brain: Integrating LLMs for Intelligent Suggestions

This is where the magic happens. Our new nyxbook-idea-suggest.ts service acts as the bridge to large language models (LLMs), providing two core functionalities:

  1. suggestIdeaPlacement(): This function takes a raw idea and, via an LLM call, returns a suggested beatId, chapterNum, reason, and even refined tags. It's like having a co-writer who understands your story's structure.
  2. suggestBeatRefactoring(): A more advanced feature, this analyzes your existing beats, characters, and ideas to propose structural changes like adding, reordering, merging, splitting, or modifying beats.

Crucially, both services leverage our existing BYOK (Bring Your Own Key) pattern, giving users control over their LLM usage and API costs. We've also built in graceful error handling, so if an LLM response can't be parsed, the idea simply reverts to a "loose" state, ensuring a robust user experience.

The API: A Seamless tRPC Experience

To expose these new capabilities, we extended our tRPC router (src/server/trpc/routers/nyxbook.ts) with a dedicated ideas nested router. This provides a comprehensive set of procedures:

  • list: Filter ideas by book and status.
  • create: The exciting one! Create an idea, and it automatically triggers an LLM suggestion, updating the idea's status to SUGGESTED.
  • update: For editing content or tags.
  • assign: Accept an AI suggestion or manually assign an idea to a specific beat/chapter.
  • incorporate: Mark an idea as fully woven into the story.
  • remove: Delete an idea.
  • suggest: Re-run the AI placement on an existing idea if you want fresh suggestions.

We also added a beats.refactor endpoint for the structural suggestions and updated existing procedures to include idea counts and data, ensuring a holistic view of your book's progress.

The Interface: Bringing Ideas to Life in the UI

No feature is complete without a user-friendly interface. We've introduced a new "Ideas" tab to the sidebar, prominently marked with a lightbulb icon.

The IdeasTab component is a central hub:

  • Quick-add input: Just type your idea and hit Enter for instant creation and auto-suggestion.
  • Status filter tabs: Easily navigate between All, Loose, Suggested, Assigned, and Incorporated ideas.
  • Idea cards: Each card beautifully displays the idea's content, tags, the AI's suggestion (beat, chapter, and reason), and crucial action buttons: Accept, Reassign, Re-suggest, Done (incorporate), and Delete.

Furthermore, we've integrated ideas directly into the BeatBoard. Each beat card now sports a lightbulb icon with an idea count, and expanding a beat reveals all its assigned or suggested ideas, visually linking inspiration to structure.

Smooth Sailing: A Testament to Good Design

One of the most satisfying aspects of this development sprint was the remarkable lack of major issues. Typecheck and lint passed clean on the first try, a testament to our robust tooling and clear architectural guidance. The Prisma nested create pattern, specifically using connect syntax for linking new ideas to existing beats, performed exactly as expected, validating our CLAUDE.md design principles. Even LLM integration, often a source of unpredictability, handled parse failures gracefully, ensuring a resilient user experience.

What's Next: Evolving the Storytelling Assistant

With the Idea Pipeline in place, our immediate focus shifts to enhancing the Beat Board. Our next steps include:

  1. Redesigning the Beat Board: Moving from a flat grid to a more intuitive chapter-grouped timeline view. This will provide a clearer narrative flow.
  2. Progression Markers: Adding rich chapter dividers that track character arcs, motif development, and world state changes throughout the book. This will be a game-changer for understanding story progression.
  3. Smarter Refactoring: Enhancing the suggestBeatRefactoring() prompt to explicitly leverage these new progression markers, offering even more insightful structural advice.

We're also streamlining the sidebar to create a more logical grouping of features, separating "Book" specific tools from "World" building elements like Characters, Motifs, and Inspirations.

The journey to build the ultimate writing assistant is ongoing, and with each new feature, nyxBook gets closer to truly empowering authors to bring their most ambitious stories to life. Stay tuned for more updates!