Inspiration
The inspiration for StoryWeaver came from a universal frustration known to every creative writer: Writer's Block combined with Context Amnesia.
We realized that most existing AI writing tools suffer from a fatal flaw: they forget. After a few thousand words, standard chatbots lose the thread of the plot, forgetting the protagonist's name or a crucial clue dropped in Chapter 1. We didn't want a tool that writes for you; we wanted a co-pilot that understands the entire story—every character arc, every subtle foreshadowing—and uses that deep context to nudge you forward when you get stuck.
What it does
StoryWeaver AI is a "Hybrid" storytelling platform that combines a professional rich-text editor with an intelligent context-aware AI.
The "Unstuck" Engine: A dedicated suite of AI tools that reads your entire story context before offering advice.
Plot Twist Generator: Suggests surprising turns based on current events.
Sensory Describer: Takes a flat sentence and rewrites it with vivid sights, sounds, and smells.
Character Chat: Allows authors to interview their own characters to discover their motivations.
Genesis Mode: Jumpstarts new projects by generating a 500-word seed story based on a simple genre and prompt.
Secure Cloud Sync: Automatically saves progress to the cloud, ensuring your work is never lost, protected by JWT authentication.
How we built it
We architected a scalable full-stack application using the MERN Stack (MongoDB, Express, React, Node.js) and Google Gemini.
Frontend: Built with React and Tailwind CSS for a distraction-free UI. We integrated react-quill for the writing interface, creating a seamless bridge between user input and the application state.
Backend: A robust Node.js/Express REST API following the MVC (Model-View-Controller) pattern.
AI Engine: We leveraged Google's Gemini 1.5 Flash. Its massive context window allows us to feed the entire manuscript into the prompt, mathematically ensuring the AI never "hallucinates" or forgets previous chapters.
Data Pipeline: We built a custom sanitation pipeline. While the database stores rich HTML (to preserve bolding/italics), our backend strips these tags in real-time before sending data to the AI, optimizing token usage and logical processing.
Challenges we ran into
The SDK Version Trap: We faced persistent 404 Not Found errors when trying to access the latest gemini-1.5-flash model. We discovered the older @google/generative-ai SDK wasn't routing correctly. We had to migrate the entire service layer to the newer @google/genai library and rewrite our prompt structures to match the new API schema.
HTML vs. Plain Text: The editor saves content as HTML (e.g.,
Hello
). Sending this raw code to the AI confused the model. We had to write a robust regex utility to "clean" the story for the AI's "brain" while keeping the formatted version safe in the database.Authentication State: Managing the user's session securely was tricky. We had to ensure that when a user refreshed the page, their JWT token in localStorage automatically re-authenticated them without forcing a login every time.
Accomplishments that we're proud of
Zero-Hallucination Context: We successfully implemented a system where the AI actually "remembers" details from the beginning of the text, thanks to the 1M token window of Gemini 1.5 Flash.
Scalable Architecture: The backend isn't just a hackathon script; it's a fully structured API with routers, controllers, and middleware that is production-ready.
The "Unstuck" Logic: Instead of a generic "Help me" button, we engineered specific prompt directives (Scene vs. Plot vs. Chat) that provide genuinely useful, specific advice rather than generic filler.
What we learned
Prompt Engineering is Coding: We learned that natural language prompts need to be treated like code. Instructing the AI to "answer in the first person" or "keep it under 3 sentences" was just as critical as the JavaScript code handling the request.
State Separation: We gained a deep appreciation for separating the "UI State" (what the user sees) from the "Server State" (what is saved).
Security First: implementing JWT middleware taught us how vital it is to protect routes at the server level, not just hide buttons on the client side.
What's next for StoryWeaver
Multiplayer Mode: Implementing WebSockets (Socket.io) to allow two authors to write in the same document simultaneously.
World Bible: A feature where the AI automatically extracts and maintains a list of characters and locations on a sidebar as you write.
Voice-to-Text Integration: Allowing authors to dictate scenes while pacing around the room.
Built With
- api
- bcrypt.js
- express.js
- gemini
- javascript
- jwt
- mongodb
- node.js
- react
- react-quill
- rest
- rest-api
Log in or sign up for Devpost to join the conversation.