Inspiration
Every child deserves a personalized bedtime story. We were inspired by the idea of combining Google's Gemini AI with interactive storytelling to create magical, one-of-a-kind stories for children — complete with AI-generated illustrations that bring each tale to life in real time.
Traditional storybooks are static, but what if a child could choose their own characters, settings, and themes, and watch a brand-new story unfold before their eyes? That's what StoryWeaver does.
What it does
StoryWeaver is an AI-powered interactive storybook that generates personalized children's stories with:
- Real-time narrative generation using Gemini 2.0 Flash
- AI-generated illustrations interleaved with the story text using native multimodal output
- Customizable themes — dragons, space, ocean, fairy tales, robots, pirates, dinosaurs, and more
- Age-adaptive content — stories adjust complexity for ages 2–12
- Live streaming — story chunks stream over WebSocket for an engaging, page-turning experience
- Optional narration via Google Cloud Text-to-Speech
How we built it
Backend: Python FastAPI server running on Cloud Run, using the google-genai SDK to call Gemini 2.0 Flash with interleaved TEXT + IMAGE output modalities. Story chunks stream to the frontend via WebSocket in real time.
Frontend: React + TypeScript with Vite. A split-panel UI with story controls on the left and a rich story player on the right that renders text, images, audio, and status updates as they arrive.
AI Pipeline: We use a two-strategy approach:
- Native interleaved output — Gemini generates text and images in a single response
- Fallback pipeline — Text-only generation with
[IMAGE: ...]tags, followed by Imagen 3 illustration generation
Infrastructure: Dockerized for Cloud Run deployment, with Cloud Storage for generated assets.
Challenges we ran into
- Interleaved output parsing — Handling mixed text and inline image data from Gemini's multimodal response required careful part-by-part processing
- Streaming UX — Making the story feel like a "page-turning" experience with smooth animations while chunks arrive asynchronously
- Age-appropriate content — Crafting system prompts that consistently produce safe, engaging content across different age ranges
- Rate limiting — Managing API quotas during development, which led us to build a robust demo mode
Accomplishments that we're proud of
- Seamless real-time story streaming with interleaved illustrations
- A beautiful, premium dark-themed UI that feels magical and child-friendly
- The two-strategy fallback system ensuring stories always generate successfully
What we learned
- How to use Gemini's native multimodal output for interleaved text + image generation
- WebSocket streaming patterns for real-time content delivery
- Building robust fallback pipelines for AI-powered features
What's next for StoryWeaver
- Voice narration with character-specific voices
- Story continuation — let children guide the plot with choices
- Engagement detection via webcam to adapt pacing
- Story library — save and revisit favorite stories with Firestore
- Multi-language support for global accessibility
Built With
- docker
- fastapi
- google-cloud-run
- google-gemini
- imagen-3
- python
- react
- typescript
- vite
- websocket
Log in or sign up for Devpost to join the conversation.