A full-stack application that generates beautiful, illustrated children's stories using AI. Built with Next.js frontend and FastAPI backend, powered by Google's Gemini API.
- π¨ AI Story Generation: Creates engaging, age-appropriate stories using Gemini 2.5 Flash with structured output
- πΌοΈ AI Image Generation: Generates beautiful illustrations for each story part with enhanced prompts
- π Interactive Story Reader: Beautiful book-like interface with page turning animations
- π Markdown Rendering: Support for headers (##) and bold text (**) in stories
- π Magical UI: Animated, child-friendly interface with sparkles and floating elements
- π± Responsive Design: Works perfectly on desktop, tablet, and mobile devices
- β‘ Optimized Performance: Exactly 8 story parts, max 15 API calls, better error handling
bootcamp_project/
βββ frontend/ # Next.js React frontend
β βββ src/
β β βββ app/
β β βββ components/ui/ # Reusable UI components
β β βββ lib/ # Utility functions
β βββ package.json
βββ backend/ # FastAPI backend
β βββ main.py # Main API server
β βββ start.py # Startup script with checks
β βββ requirements.txt
β βββ .env # Environment variables
βββ README.md
- Node.js 18+ and npm
- Python 3.8+
- Google Gemini API key (Get one here)
# Navigate to backend directory
cd backend
# Install Python dependencies
pip install -r requirements.txt
# Create environment file
cp .env.example .env
# Edit .env and add your Gemini API key
# GEMINI_API_KEY=your_actual_api_key_here
# Start the backend server
python start.pyThe backend will start on http://localhost:8000
# Navigate to frontend directory (in a new terminal)
cd frontend
# Install dependencies
npm install
# Start the development server
npm run devThe frontend will start on http://localhost:3001 (or 3000 if available)
- Open the application in your browser at
http://localhost:3001 - Enter a story prompt like "A brave princess who saves dragons"
- Click "Generate My Story!" and wait for the magic to happen
- Enjoy your story with beautiful AI-generated illustrations
- Navigate through pages using the arrow buttons or page indicators
Generates a complete story with images based on a prompt.
Request:
{
"prompt": "A magical adventure in space"
}Response:
{
"title": "The Cosmic Adventure",
"parts": [
{
"text": "Once upon a time...",
"image": "data:image/png;base64,..."
}
]
}The frontend includes custom UI components:
- Button: Multiple variants with animations
- Input: Styled input fields with focus states
- Card: Container components with backdrop effects
All components are built with TypeScript and Tailwind CSS for consistency and maintainability.
cd frontend
npm run dev # Start development server
npm run build # Build for production
npm run lint # Run lintingcd backend
python start.py # Start with checks
# OR
python main.py # Direct start
# OR
uvicorn main:app --reload # With auto-reloadWhen the backend is running, visit http://localhost:8000/docs for interactive API documentation.
- User Input: User provides a creative prompt
- Structured Generation: Gemini AI creates a magical children's story with exactly 8 parts using JSON structured output
- Content Formatting: Each part includes markdown formatting for headers and bold text
- Image Generation: Each part gets a beautiful AI-generated illustration with enhanced prompts
- Story Presentation: Interactive book interface displays the complete story with proper formatting
The frontend features magical animations:
- β¨ Sparkle animations on icons
- π Floating effects for decorative elements
- π Page turning animations
- π Magical entrance animations
- π« Hover effects on interactive elements
GEMINI_API_KEY=your_gemini_api_key_here- "GEMINI_API_KEY not set": Make sure you've created a
.envfile with your API key - "Module not found": Run
pip install -r requirements.txt - API errors: Check your Gemini API key is valid and has sufficient quota
- Build errors: Make sure all dependencies are installed with
npm install - API connection errors: Ensure the backend is running on
http://localhost:8000 - TypeScript errors: Try deleting
.nextfolder and rebuilding
- Next.js 15 - React framework
- TypeScript - Type safety
- Tailwind CSS - Styling
- Lucide React - Icons
- Custom UI Components - Reusable components
- FastAPI - Python web framework
- Google Gemini API - AI text and image generation
- Pydantic - Data validation
- Uvicorn - ASGI server
- Structured Output: Exactly 8 parts per story using JSON schema
- Markdown Support: Headers (##) and bold text (**) for better formatting
- Child-appropriate content with positive themes
- Consistent structure with clear beginning, middle, and end
- Vivid descriptions perfect for illustration
- Educational and inspiring themes
- Enhanced prompts for more relevant illustrations
- Colorful placeholders when image generation fails
- Child-friendly art style with magical themes
- Optimized display with proper aspect ratios
- Lazy loading for better performance
- Intuitive, magical interface
- Responsive design for all devices
- Smooth animations and transitions
- Error handling with helpful messages
- Loading states with progress indication
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source and available under the MIT License.
Happy storytelling! β¨ππ