An AI-powered interactive storytelling platform that generates dynamic Choose Your Own Adventure narratives featuring Yorkshire Terriers Pawel and Pawleen on their forest farm adventures.
- Dynamic Story Generation: AI-powered narrative creation using OpenAI's GPT models
- Character-Driven Adventures: Stories featuring beloved farm characters with unique personalities
- Interactive Choices: Meaningful decision points that shape story direction
- Branching Narratives: Multiple story paths with diverse outcomes
- Rich Character Database: Pre-analyzed character images with traits and roles
- Character Selection: Choose protagonists from available farm residents
- Personality-Driven Stories: Character traits influence narrative direction and available choices
- Visual Character Cards: Beautiful character displays with trait indicators
- Image Analysis: AI-powered character and scene analysis using computer vision
- Story Persistence: Save and continue adventures across sessions
- Unity Game Integration: API endpoints for external game client support
- Debug Tools: Comprehensive management interface for content creators
- Backend: Flask web framework with PostgreSQL database
- AI Integration: OpenAI GPT models for story generation and image analysis
- Frontend: Bootstrap 5 with custom CSS and vanilla JavaScript
- Database: PostgreSQL with SQLAlchemy ORM
- Deployment: Replit with automatic scaling
- Python 3.11+
- PostgreSQL database
- OpenAI API key
- Clone the repository:
git clone https://github.com/yourusername/uncle-marks-storybook.git
cd uncle-marks-storybook- Install dependencies:
pip install -r requirements.txt- Set up environment variables:
export DATABASE_URL="your_postgresql_url"
export OPENAI_API_KEY="your_openai_api_key"
export SESSION_SECRET="your_session_secret"- Initialize the database:
python -c "from app import app, db; app.app_context().db.create_all()"- Run the application:
python main.pyThe app will be available at http://localhost:5000
- Pawel (Male Yorkshire Terrier): Fearless, clever, and impulsive leader
- Pawleen (Female Yorkshire Terrier): Fearless, clever, and thoughtful strategist
- Big Red: The well-meaning but not-so-bright rooster
- The Clever Hens: Birdadette, Henrietta, Birderella, Birdatha, and Birdgit
- White Turkeys: Large, friendly, but prone to getting into predicaments
- Various Farm Animals: Each with unique personalities and story roles
- Evil Squirrel Gangs: Arrogant bullies who steal food and harass other animals
- The Rat Wizard: Forest-dwelling villain who steals eggs and enchants rodents
- Enchanted Minions: Mice and moles forced to help with villainous schemes
- Select a Character: Choose one protagonist from the character gallery
- Set Story Parameters: Pick conflict type, setting, narrative style, and mood
- Generate Adventure: Let AI create your personalized story
- Make Choices: Navigate through decision points to shape the narrative
- Conflicts: Mystery, rescue, adventure, friendship, rivalry, survival, discovery, protection
- Settings: Forest, farm, pasture, chicken coop, creek, barn, garden, meadow
- Styles: Playful, mysterious, heroic, cozy, adventurous, educational, humorous, dramatic
- Moods: Cheerful, suspenseful, peaceful, energetic, mysterious, heartwarming, comedic, inspiring
The platform provides REST API endpoints for Unity game integration:
GET /api/unity/story_node/{node_id}- Retrieve story node with choicesPOST /api/unity/choice/{choice_id}- Process choice selectionGET /api/unity/user_progress/{user_id}- Get user's current progress
GET /api/unity/characters- List all available charactersGET /api/unity/story_branch/{node_id}- Get complete story branch
POST /api/unity/save_game_state- Save comprehensive game stateGET /api/unity/load_game_state/{user_id}- Load saved game stateGET /api/unity/achievements/{user_id}- Get user achievements
โโโ app.py # Main Flask application
โโโ main.py # Application entry point
โโโ models.py # Database models
โโโ database.py # Database configuration
โโโ services/
โ โโโ openai_service.py # AI integration service
โ โโโ story_maker.py # Story generation logic
โโโ api/
โ โโโ unity_routes.py # Unity API endpoints
โโโ templates/ # HTML templates
โโโ static/ # CSS, JavaScript, assets
โโโ migrations/ # Database migrations
- ImageAnalysis: Character and scene data with AI analysis
- StoryGeneration: Generated story content and metadata
- StoryNode: Individual story segments in branching narratives
- StoryChoice: Decision points connecting story nodes
- UserProgress: Player progress tracking
- Achievement: Story achievement system
- Use the debug interface at
/debug - Analyze character images with AI
- Review and edit character traits
- Save to database for story integration
Access the debug interface at /debug for:
- Image Analysis: Process new character and scene images
- Database Management: View, edit, and manage stored content
- Story Browser: Review generated stories and choices
- Health Monitoring: Database connectivity and system status
DATABASE_URL: PostgreSQL connection stringOPENAI_API_KEY: OpenAI API key for AI featuresSESSION_SECRET: Flask session encryption keyREPLIT_DEPLOYMENT: Deployment mode indicator
- Story Generation: GPT-4 Turbo for creative writing
- Image Analysis: GPT-4 Vision for character/scene analysis
- Response Format: JSON structured responses for consistent parsing
The application is optimized for Replit deployment with:
- Automatic dependency management
- Environment variable configuration
- Database initialization
- Horizontal scaling support
- Import project to Replit
- Configure secrets in Replit environment
- Run the application
- Access via generated Replit domain
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
- Follow PEP 8 Python style guidelines
- Add tests for new features
- Update documentation for API changes
- Ensure database migrations are included
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for powerful AI models enabling dynamic storytelling
- Bootstrap team for responsive UI framework
- Flask community for excellent web framework
- PostgreSQL for reliable data storage
For issues, questions, or contributions:
- Create an issue on GitHub
- Check existing documentation
- Review debug tools for troubleshooting
Created with โค๏ธ for interactive storytelling adventures