An interactive storytelling application powered by AI, where users can create and guide immersive narrative adventures. Built with React.js frontend and Node.js/Express backend, featuring AI story generation using Google's Gemini API.
- Multiple Scenarios: Choose from Space Colony, Post-Apocalyptic, Fantasy, Historical, and Cyberpunk settings
- Character Creation: Customize your protagonist with name and role
- Interactive Narrative: Two interaction modes:
- Continue Story: Let the AI advance the narrative
- Custom Actions: Describe specific actions to influence the story
- Story Management: Save, load, and manage multiple ongoing adventures
- Rich Story Display: Specially designed UI for immersive storytelling
- User authentication (signup/login)
- Session-based story management
- User preferences and avatar customization
- Dark/light theme support
- Responsive design for all devices
- React 18 with Hooks
- Vite for fast development
- Tailwind CSS for styling
- React Router DOM for navigation
- Axios for API communication
- Node.js with Express.js
- MongoDB with Mongoose ODM
- JWT Authentication
- Google Gemini API for story generation
- bcrypt for secure password hashing
- Node.js (v16 or higher)
- MongoDB (local or cloud instance)
- Google Gemini API key
Create a .env file in the server directory:
MONGODB_URI=mongodb://localhost:27017/ai-storytelling-app
JWT_SECRET=your_super_secret_jwt_key_here
GEMINI_API_KEY=your_gemini_api_key_here
PORT=5000
NODE_ENV=development# Clone the repository
git clone <repository-url>
cd ai-chat-app
# Install all dependencies
npm run install:all
# Seed the database with story scenarios
npm run seed# Start both server and client
npm run devThe application will be available at http://localhost:5173
- Story-focused API endpoints (
/api/stories/*) - Scenario system with 5 predefined scenarios
- Enhanced Session model with story-specific fields:
title: Adventure namescenario: Selected story themecharacter: Protagonist details (name, role)history: Message history with input types
- Gemini API integration with storytelling-optimized prompts
- Dual interaction support: Continue vs Custom Action modes
- Story CRUD operations: Create, read, update, delete stories
- StoryPage (evolved from ChatPage) with storytelling UI
- ScenarioSelector component for adventure creation
- Enhanced MessageInput with dual-mode support:
- Continue Story button
- Custom action text input
- Story-themed MessageBubble components:
- Narrative-style AI responses
- Action/Continue user inputs with different styling
- Updated SessionSidebar for story management
- SessionContext updated to use stories API
- Responsive storytelling UI with ambient styling
- Scenario model with predefined story templates
- Seeding script with 5 complete scenarios:
- Space Colony
- Post-Apocalyptic
- Fantasy Kingdom
- Historical Adventure
- Cyberpunk
- Enhanced story persistence with full context
GET /api/stories/scenarios- Get all available scenariosGET /api/stories- Get all user storiesPOST /api/stories- Create a new storyGET /api/stories/:id- Get specific storyPOST /api/stories/:id/action- Submit action to storyPUT /api/stories/:id/title- Rename a storyDELETE /api/stories/:id- Delete story
POST /api/auth/register- User registrationPOST /api/auth/login- User loginPOST /api/auth/logout- User logoutGET /api/auth/profile- Get user profile
PUT /api/users/:id/preferences- Update user preferences
- Sign up/Login to your account
- Click "New Adventure" in the sidebar
- Choose a scenario from the available options
- Customize your character with a name and role
- Start your story and begin your adventure!
- Continue Story: Click the purple "Continue Story" button to let the AI advance the narrative
- Custom Actions: Type specific actions in the text box and click "Act" to influence the story direction
- Story Management: View, rename, or delete your adventures from the sidebar
ai-storytelling-app/
โโโ client/ # React frontend
โ โโโ src/
โ โ โโโ components/ # React components
โ โ โ โโโ MessageBubble.jsx # Story-themed message display
โ โ โ โโโ MessageInput.jsx # Dual-mode input component
โ โ โ โโโ MessageList.jsx # Story-aware message list
โ โ โ โโโ ScenarioSelector.jsx # Adventure creation modal
โ โ โ โโโ SessionSidebar.jsx # Story management sidebar
โ โ โโโ contexts/ # React contexts
โ โ โ โโโ SessionContext.jsx # Updated for stories API
โ โ โโโ pages/ # Page components
โ โ โ โโโ ChatPage.jsx # Renamed to StoryPage internally
โ โ โโโ assets/ # Static assets
โ โโโ package.json
โโโ server/ # Express backend
โ โโโ src/
โ โ โโโ controllers/ # Route controllers
โ โ โ โโโ session.js # Story management logic
โ โ โโโ models/ # MongoDB models
โ โ โ โโโ Session.js # Enhanced for storytelling
โ โ โ โโโ Scenario.js # Story scenario templates
โ โ โโโ routes/ # API routes
โ โ โ โโโ stories.js # Story-focused endpoints
โ โ โโโ seed/ # Database seeding
โ โ โ โโโ scenarios.js # Scenario data and seeding
โ โ โโโ utils/ # Utility functions
โ โ โ โโโ gemini.js # AI story generation
โ โ โโโ ...
โ โโโ package.json
โโโ package.json # Root package configuration
โโโ start.sh # Development startup script
โโโ README.md
- Storytelling-focused interface with narrative-style message bubbles
- Ambient color scheme using purple/amber themes for immersion
- Scenario-based customization with thematic elements
- Responsive design that works on desktop, tablet, and mobile
- Dark/light mode support for comfortable reading
- Visual themes per scenario (background images, color schemes)
- Character portraits and visual customization
- Story branching with choice-based narratives
- Export functionality for completed adventures
- Community features for sharing stories
- Advanced AI parameters for different writing styles
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
๐ญ Ready to embark on your storytelling adventure? Start your journey today!