https://eduventure-game.vercel.app/
A modern educational choose-your-own-adventure game built with Next.js and lots of AI, featuring AI-generated stories powered by OpenAI with integrated learning experiences.
- 🎓 Educational Focus: Interactive learning through adventure with subject-based questions
- 🎮 Interactive Gameplay: Rich storytelling with multiple branching paths
- 🎯 Smart Choice System: Mix of adventure and educational choices with consequences
- 📊 Health System: Strategic gameplay with heart-based health management
- 🤖 AI Story Generation: Create unlimited adventures using OpenAI prompts
- 🎨 Beautiful UI: Modern gradient design with responsive layout
- 📱 Mobile-Friendly: Optimized for both desktop and mobile devices
- 🖼️ AI Image Generation: Optional DALL-E powered images for story steps
- Node.js 18+ installed on your system
- OpenAI API key (for AI story generation)
- Clone the repository:
git clone [email protected]:sethjeffery/eduventure-game.git
cd eduventure-game- Install dependencies:
npm install- Set up your OpenAI API key by creating a
.env.localfile:
# Create .env.local file in the root directory
OPENAI_API_KEY=your_openai_api_key_here
# Feature Flags
# Set to "true" to enable AI image generation for story steps (expensive!)
# Set to "false" or remove to disable image generation (recommended for cost control)
NEXT_PUBLIC_ENABLE_IMAGE_GENERATION=false
ENABLE_IMAGE_GENERATION=false- Run the development server:
npm run dev- Open http://localhost:3000 in your browser
- Get your API key from OpenAI Platform
- Create a
.env.localfile in the root directory with the environment variables shown above
The app supports AI-generated images for story steps using DALL-E 3, but this feature is disabled by default due to cost considerations:
- Cost: Each image costs approximately $0.04-0.08 via OpenAI API
- Performance: Images take 10-30 seconds to generate
- Storage: Images are served directly from OpenAI (temporary URLs)
To enable image generation:
- Set both environment variables to
"true"in your.env.localfile - Deploy/restart your application
- Images will automatically generate for story steps with sufficient content
-
Choose Educational Subject:
- Select from Mathematics, Science, History, Geography, or English
- Each subject provides context for educational questions during the adventure
-
Select Difficulty Level:
- Easy: 7 story steps, simpler concepts
- Medium: 10 story steps, moderate complexity
- Hard: 15 story steps, advanced challenges
-
Create Your Adventure:
- Enter a creative prompt (e.g., "A space station mystery")
- Click "Generate Adventure"
- Wait for AI to create your unique educational story
-
Gameplay:
- Read the generated story content
- Make choices to progress (mix of story and educational decisions)
- Manage your health (hearts) - wrong answers cost hearts
- Discover multiple endings based on your performance
- Adventure Engine (
useStreamingAdventure): Manages game state, streaming, and logic - Story Renderer (
StreamingStoryStep): Displays rich text content with markdown and streaming - Choice System (
ChoiceButton): Interactive decision-making interface - Game Status (
GameStatus): Health, stats, and progress tracking - AI Generator (
AdventureGenerator): Multi-step setup and OpenAI-powered story creation
- Streaming Content: Real-time story generation with progressive loading
- Educational Integration: Subject-specific questions mixed with adventure choices
- Smart Difficulty: Adaptive story length and complexity based on selected level
- Health System: Strategic consequences for incorrect educational answers
- Image Generation: Optional AI-generated visuals for immersive storytelling
Adventures use a dynamic streaming format with:
- Steps: Generated story segments with content and choices
- Choices: Player decisions with correctness indicators (
correct: true/false) - Effects: Automatic state changes (heart loss for wrong answers)
- Context: Educational subject and difficulty level integration
The app uses Tailwind CSS v4 with a custom gradient theme. Modify styles in component files or customize the gradient system in the UI components.
Add new subjects to src/constants/index.ts:
export const EDUCATIONAL_SUBJECTS = [
// existing subjects...
{
id: "new-subject",
name: "New Subject",
description: "Description of the subject",
},
];Update the adventure suggestions in src/constants/subjects.ts:
export const ADVENTURE_PROMPTS = [
// Add your custom adventure prompts here
"Your custom adventure prompt",
];For best results when generating adventures:
- Be specific about setting and theme
- Include character roles or objectives
- Mention desired complexity level
- Consider how educational elements can be naturally integrated
Example prompts:
- "A detective solving supernatural crimes in Victorian London"
- "A time traveler trying to prevent a historical disaster"
- "A cyberpunk hacker uncovering a corporate conspiracy"
- "An underwater explorer discovering an ancient civilization"
- Push your code to a Git repository
- Connect to Vercel
- Add your
OPENAI_API_KEYenvironment variable - Optionally add
NEXT_PUBLIC_ENABLE_IMAGE_GENERATION=truefor image generation - Deploy!
The app can be deployed to any platform supporting Next.js, including:
- Netlify
- Railway
- DigitalOcean App Platform
- AWS Amplify
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is open source. Feel free to use and modify as needed.
If you encounter issues:
- Check that your OpenAI API key is properly configured
- Ensure you have sufficient OpenAI credits
- Review the browser console for error messages
- Open an issue on GitHub with details
- The app uses streaming responses for real-time story generation
- Educational questions are dynamically integrated into adventure stories
- Image generation is optional and disabled by default for cost control
- The game uses a heart system where wrong educational answers cost health
Built with ❤️ using Next.js, TypeScript, Tailwind CSS, and OpenAI