
DreamForge
DreamForge isn't just another chatbot. It's a structured AI system that generates **complete adventures** from simple text prompts: - A cinematic title - A detailed world setting - A protagonist with stats (health, energy) - A narrative story with context - 3 meaningful choices - Remix functionality to transform genres - Journey log tracking every decision Users can choose between four modes: **Story**, **World**, **Game**, and **Chaos** — each producing a fundamentally different creative experience.
DreamForge: Build an AI-Powered Creative Adventure Generator in a Weekend
How I Built a Full-Stack AI App with Next.js, FastAPI, and Amazon Bedrock for the AWS Weekend Challenge
The Challenge
What if you could type "A lonely robot wakes up alone on Mars" and instantly get a complete interactive adventure — with a title, world, characters, choices, and branching narratives?
That's what I set out to build for the AWS Weekend Challenge: DreamForge, an AI-powered creative adventure generator that turns any idea into an immersive, interactive experience.
In this article, I'll walk through the architecture, key decisions, and lessons learned building this full-stack application.
The Vision
DreamForge isn't just another chatbot. It's a structured AI system that generates complete adventures from simple text prompts:
- A cinematic title
- A detailed world setting
- A protagonist with stats (health, energy)
- A narrative story with context
- 3 meaningful choices
- Remix functionality to transform genres
- Journey log tracking every decision
Users can choose between four modes: Story, World, Game, and Chaos — each producing a fundamentally different creative experience.
Architecture Overview
┌─────────────────────────────────────────────────┐│ Frontend ││ Next.js 15 + React 19 ││ Tailwind CSS v4 + Framer Motion ││ Zustand + localStorage Persistence │└───────────────────────┬─────────────────────────┘ │ HTTP ▼┌─────────────────────────────────────────────────┐│ Backend ││ FastAPI (Python) ││ AI Provider Abstraction Layer ││ ┌─────────┬──────────┬──────────────┐ ││ │OpenRouter│ Gemini │ Bedrock │ ││ └─────────┴──────────┴──────────────┘ │└─────────────────────────────────────────────────┘The key design decision was a provider-agnostic AI abstraction layer. This lets me switch between OpenRouter (for free development), Google Gemini (for prototyping), and Amazon Bedrock (for production deployment) — all with a single environment variable.
Tech Stack Choices
Frontend: Next.js 15 + Tailwind CSS v4
Next.js 15 with the App Router gave me server-side rendering out of the box, perfect for the initial landing page. Tailwind CSS v4's new CSS-first configuration made the glass-morphism effects clean and maintainable.
The UI features:
- Canvas-based particle animations
- Glassmorphism cards with backdrop blur
- Gradient effects and animated transitions
- Responsive grid layouts
- Smooth page transitions with Framer Motion
Backend: FastAPI + Python
FastAPI's async support was critical. The adventure generation flow involves multiple AI calls — generating the initial story, processing choices, remixing genres — and async I/O keeps the entire experience fast.
State Management: Zustand + localStorage
Adventure persistence was solved with Zustand's localStorage middleware. Every generated adventure is stored locally, giving users instant access to their recent creations without requiring authentication.
The AI Prompt Engineering Challenge
The hardest part wasn't the code — it was getting reliable JSON output from the AI models.
LLMs are notoriously bad at producing structured output. Early iterations would:
- Truncate JSON responses (incomplete objects)
- Include markdown code blocks around JSON
- Occasionally produce invalid syntax
Solutions that worked:
- Reserved token budget: Setting
MAX_OUTPUT_TOKENS=4096instead of 2048 gave enough space for complete JSON responses
- Multiple JSON extraction patterns: Regular expressions that handle JSON with/without markdown code blocks
- Graceful fallbacks: If JSON parsing fails, return a reasonable default adventure with the original prompt as context
- Structured prompts: Explicit JSON schemas in the prompt itself, with clear field descriptions and examples
prompt = f"""Generate a creative adventure in JSON format.
Required JSON structure:{{ "title": "Cinematic title", "mode": "story|world|game|chaos", "setting": "Detailed world description", "protagonist": {{ "name": "Character name", "role": "Their role", "health": 100, "energy": 100 }}, "story": "Opening narrative (2-3 paragraphs)", "choices": [ {{"text": "Choice description", "consequence": "What happens"}} ], "context": "Background information"}}
User's request: {prompt}"""
Provider Switching in Practice
During development, I learned that each AI provider has unique behaviors:
OpenRouter (Free Models)
- Free tier available with models like Llama 3.3 70B and Gemma 3
- Excellent for development and testing
- Slightly higher latency but zero cost
AI_PROVIDER=openrouterOPENROUTER_API_KEY=sk-or-v1-xxxxxOPENROUTER_MODEL=meta-llama/llama-3.3-70b-instruct:freeGoogle Gemini
- Free tier with 1 million tokens per day
- Very fast response times
- Requires Google AI SDK integration
AI_PROVIDER=geminiGEMINI_API_KEY=your-keyGEMINI_MODEL=gemini-2.0-flashAmazon Bedrock
- Pay-per-use pricing with no upfront costs
- Enterprise-grade security and compliance
- Ideal for production deployment
AI_PROVIDER=bedrockBEDROCK_MODEL_ID=amazon.nova-lite-v1:0BEDROCK_REGION=us-east-1The abstraction layer in
ai_provider.py handles all provider-specific logic:class AIProvider: """Unified interface for AI providers""" async def generate_adventure(self, prompt, mode): if self.provider == "openrouter": return await self._openrouter_generate(prompt, mode) elif self.provider == "gemini": return await self._gemini_generate(prompt, mode) elif self.provider == "bedrock": return await self._bedrock_generate(prompt, mode)
The Landing Page Experience
The landing page was designed to feel like a premium AI product, not a generic tech demo:
- Hero section: Cinematic title with gradient effects, input form with glow effect
- Mode selector: Four distinct adventure types with visual feedback
- How it works: Three-step process explanation
- Recent adventures: Persistent history of generated adventures
The particle animation canvas adds subtle visual depth without being distracting. The glassmorphism effects on cards create a modern, sophisticated feel.
Key Features
Adventure Generation
- Type any idea and get a complete interactive experience
- Four distinct modes (Story, World, Game, Chaos)
- Rich narrative with characters, settings, and choices
Continue System
- Click any choice to continue the adventure
- New story developments with fresh choices
- Health and energy management in Game mode
Remix Feature
- Transform any adventure into a different genre
- Convert a story into a game
- Turn a fantasy into sci-fi
- Preserve core narrative while changing style
Persistence
- Adventures saved to localStorage
- Browse recent creations
- No account required
Challenges and Lessons Learned
1. JSON Reliability
Getting consistent JSON from LLMs was the biggest challenge. The solution: explicit schemas in prompts, multiple extraction patterns, and graceful fallbacks.
2. Token Limits
2048 output tokens wasn't enough for complete adventures. Increasing to 4096 resolved truncation issues.
3. Provider Differences
Each AI provider has unique quirks — different SDK versions, authentication methods, and response formats. The abstraction layer was essential.
4. UI Composition
Balancing visual polish with performance required careful attention to animation timing, backdrop blur performance, and responsive breakpoints.
5. Error Handling
Graceful degradation was critical. When the AI fails, the app still provides a usable experience with default content.
What I'd Build Next
If I had more time, I'd add:
- User authentication with AWS Cognito
- Cloud persistence with DynamoDB
- Image generation for adventure scenes
- Multiplayer mode for shared adventures
- Voice narration using Amazon Polly
- WebSocket streaming for real-time story generation
Deploying to AWS
For production deployment:
- Frontend → AWS Amplify Hosting
- Automatic deployments from Git
- Built-in CI/CD
- Global CDN
- Backend → AWS Lambda + API Gateway
- Serverless scaling
- No infrastructure management
- Pay per request
- AI → Amazon Bedrock
- No API keys to manage
- Enterprise security
- Fine-tuning capabilities
- Storage → Amazon DynamoDB
- Persistent adventure history
- Global tables
- Auto-scaling
Cost Analysis
Component | Development | Production |
|---|---|---|
AI Provider | $0 (OpenRouter free tier) | ~$0.05-0.10/session (Bedrock) |
Hosting | $0 (local) | $0-20/month (Amplify) |
Storage | $0 (localStorage) | ~$1-5/month (DynamoDB) |
The free tier of OpenRouter and Gemini makes development completely free. AWS services scale costs with usage, making it affordable even for side projects.
Conclusion
DreamForge demonstrates that building sophisticated AI applications is more accessible than ever. With free AI models, modern web frameworks, and serverless AWS services, a single developer can create experiences that would have required a team just a few years ago.
The key takeaways:
- Provider abstraction future-proofs your AI integration
- Structured prompts dramatically improve output quality
- Graceful fallbacks handle inevitable AI failures
- localStorage persistence provides instant gratification without infrastructure
The full source code is available on GitHub. Try it out and let me know what adventures you create.
Resources
- OpenRouter API
- Google Gemini
- Amazon Bedrock
- Next.js
- FastAPI
Built for the AWS Weekend Challenge. Powered by AI.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article