An intelligent lesson generation system that creates professional, dynamic educational content with AI-generated images. Built with Flask, React, Google Gemini AI, and Imagen (Nano Banana).
- AI Lesson Generation: Create comprehensive lessons on any topic using Gemini AI
- Dynamic Image Generation: Automatically generate contextual images using Imagen (Nano Banana)
- Chat-Based Editing: Modify lessons using natural language commands
- Modern UI: Beautiful, responsive interface built with React and TailwindCSS
- Agentic Architecture: Three specialized AI agents working together:
- Lesson Generator Agent: Creates structured educational content
- Image Generator Agent: Produces relevant educational images
- Lesson Editor Agent: Processes natural language edit requests
- RESTful API with Flask
- Three AI agents powered by Google Gemini
- In-memory lesson storage (easily extendable to database)
- Image generation with Imagen API
- Modern, responsive UI with TailwindCSS
- Real-time lesson preview
- Interactive chat interface for editing
- Dynamic image loading and display
- Python 3.8+
- Node.js 16+
- Google Gemini API Key (provided in .env)
- Navigate to the backend directory:
cd backend- Create and activate virtual environment (already done):
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies (already done):
pip install -r requirements.txt-
The API key is already configured in
.envfile -
Start the Flask server:
python app.pyThe backend will run on http://localhost:5000
- Open a new terminal and navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Start the React development server:
npm startThe frontend will run on http://localhost:3000
- Open
http://localhost:3000in your browser - Enter a topic (e.g., "Photosynthesis", "Machine Learning", "Ancient Rome")
- Click "Generate Lesson"
- Wait for the AI to create the lesson structure and generate images
- View your professional, image-rich lesson!
Use the chat interface on the right side to make edits:
Text Modifications:
- "Make the first paragraph shorter"
- "Add more examples to the key concepts"
- "Make the title more engaging"
- "Simplify the introduction"
Image Modifications:
- "Replace the activities image with a cartoon style"
- "Change the introduction image to be more realistic"
- "Make the key concept images minimalist"
Content Changes:
- "Add another key concept about [topic]"
- "Include more practice activities"
- "Expand the summary section"
Generate a new lesson on a given topic
{
"topic": "Photosynthesis"
}Generate images for a lesson
Retrieve a lesson by ID
Edit a lesson using natural language
{
"request": "Make the first paragraph shorter"
}List all generated lessons
Edit backend/agents/image_generator.py and add new styles to the style_prefixes dictionary:
style_prefixes = {
"educational": "Professional educational illustration...",
"cartoon": "Colorful cartoon style...",
"your_style": "Your custom prompt prefix...",
}Edit backend/agents/lesson_generator.py to change the lesson template structure in the generate_lesson method.
Modify frontend/tailwind.config.js to change colors, fonts, and styling:
theme: {
extend: {
colors: {
primary: { /* your colors */ }
}
}
}User Input (Topic)
↓
Lesson Generator Agent (Gemini)
↓
Structured Lesson JSON
↓
Image Generator Agent (Imagen)
↓
Complete Lesson with Images
User Edit Request
↓
Lesson Editor Agent (Gemini)
↓
Analyzes Current Lesson + Request
↓
Generates Modification Instructions
↓
Applies Changes to Lesson
↓
Regenerates Images (if needed)
↓
Updated Lesson
Backend:
- Flask 3.0.0
- Google GenAI SDK (google-genai)
- Gemini 2.5 Flash Lite (lesson generation & editing)
- Gemini 2.5 Flash Image / Nano Banana (image generation)
- Python 3.10+
Frontend:
- React 18.2
- TailwindCSS 3.3
- Lucide React (icons)
- Axios (API calls)
- Science: Photosynthesis, Quantum Physics, Climate Change
- History: Ancient Egypt, World War II, Renaissance
- Technology: Machine Learning, Blockchain, Web Development
- Mathematics: Calculus Basics, Statistics, Geometry
- Languages: Spanish Grammar, English Literature, Creative Writing
- The API key is currently in
.envfor development - In production, use environment variables and secure key management
- Implement authentication for the API endpoints
- Add rate limiting to prevent abuse
- Firebase Authentication - Google Sign-In integration
- Resource Management - Save, edit, and delete lessons
- Library System - Browse saved resources by type
- Student Management - Add and manage students
- Assignment System - Assign resources to students
- Modular Architecture - Easy to add new resource types
See SETUP_GUIDE.md for detailed Firebase setup instructions.
- Export lessons to PDF/HTML
- Multiple language support
- Collaborative editing
- Lesson templates library
- Advanced image editing options
- Voice narration for lessons
- Quiz generation from lesson content
- Worksheet generator
- Presentation creator
- Progress tracking for students
This project is for educational and demonstration purposes.
Feel free to fork, modify, and enhance this project!
For issues or questions, please check the console logs in both backend and frontend for debugging information.