An AI-powered system for automatically generating structured educational courses on any topic. This application uses a multi-agent architecture to research, structure, generate content, and validate educational courses.
The Educational Course Generator is an API-based service that allows users to:
- Generate complete educational courses on any topic
- Specify desired depth (beginner, intermediate, advanced)
- Set target audience and course duration
- Refine course content with additional instructions
- Download generated courses as structured JSON
The system employs multiple specialized agents working together to create comprehensive, well-structured educational content.
- CoordinatorAgent: Orchestrates the workflow between all other agents
- ResearchAgent: Gathers information on the topic from web and academic sources
- StructureAgent: Creates a logical course structure with modules and lessons
- ContentGenerationAgent: Produces detailed content for each lesson
- ValidationAgent: Ensures quality and suggests improvements
- Python 3.8+
- Flask
- LangChain
- OpenAI API key
- Tavily API key (for research component)
-
Clone the repository:
git clone https://github.com/yourusername/educational-course-generator.git cd educational-course-generator
-
Create and activate a virtual environment:
conda env create -f course-agent.yaml
-
Install dependencies:
pip install -r requirements.txt
-
Create an
.env
file with required API keys and configuration:OPENAI_API_KEY=your_openai_api_key TAVILY_API_KEY=your_tavily_api_key PORT=5000 UI_PORT=5001
Change the Model type in config.py
The system consists of two components:
- API Server: Handles course generation and processing
- Web Interface: Provides a user-friendly frontend
# Start the API server
python /api/main.py
# Start the web interface
python app.py
The API server will start on http://localhost:5000
by default.
The web interface will be available at http://localhost:5001
.
The web interface provides a user-friendly way to interact with the course generation system:
- Home Page: Overview and quick access to recent courses
- Course Creation: Form to specify topic, depth, audience, and duration
- Course List: View all generated courses
- Course View: Detailed view of a specific course with its content
- Course Download: Download the complete course as JSON
- Course Refinement: Submit additional instructions to improve the course
-
POST /api/courses/: Create a new course
{ "topic": "Machine Learning", "depth": "intermediate", "target_audience": "Computer Science students", "course_duration": "6 weeks" }
-
GET /api/courses/{task_id}: Check course generation status
-
GET /api/courses/{task_id}/download: Download the complete course
-
Start both the API server and web interface:
# Terminal 1 python main.py # Terminal 2 python app.py
-
Open your browser and navigate to
http://localhost:5001
-
Use the "Create Course" form to generate a new course:
- Enter a topic (e.g., "Introduction to Python Programming")
- Select depth (beginner, intermediate, advanced)
- Specify target audience and course duration
- Click "Generate Course"
-
Track the course generation progress and view/download when complete
import requests
import json
import time
# Create a new course
response = requests.post(
"http://localhost:5001/api/courses/",
json={
"topic": "Introduction to Python Programming",
"depth": "beginner",
"target_audience": "High school students",
"course_duration": "4 weeks"
}
)
task_id = response.json()["task_id"]
print(f"Course generation started. Task ID: {task_id}")
# Poll until complete
while True:
status_response = requests.get(f"http://localhost:5001/api/courses/{task_id}")
status = status_response.json()["status"]
print(f"Status: {status}")
if status in ["completed", "failed"]:
break
time.sleep(5) # Wait 5 seconds before checking again
# Download the complete course
if status == "completed":
course_response = requests.get(f"http://localhost:5001/api/courses/{task_id}/download")
course_data = course_response.json()
# Save to file
with open("my_python_course.json", "w") as f:
json.dump(course_data, f, indent=2)
print("Course downloaded successfully!")
educational-course-generator/
├── agents/
│ ├── __init__.py
│ ├── base_agent.py # Abstract base class for all agents
│ ├── coordinator.py # Orchestrates the workflow
│ ├── researcher.py # Gathers information
│ ├── structurer.py # Creates course structure
│ ├── content_generator.py # Generates detailed content
│ └── validator.py # Validates and improves content
├── services/
│ ├── __init__.py
│ ├── llm_service.py # LLM interaction service
│ └── research_service.py # External research API client
├── utils/
│ ├── __init__.py
│ ├── json_cleaner.py # Fixes JSON formatting issues
│ ├── content_formatter.py # Formats course output
│ └── logging_config.py # Configures logging
├── templates/
│ ├── base.html # Base template with layout
│ ├── index.html # Home page
│ ├── partials/
│ │ ├── header.html # Navigation header
│ │ ├── footer.html # Page footer
│ │ └── course_card.html # Reusable course component
│ └── courses/
│ ├── create.html # Course creation form
│ ├── list.html # List of all courses
│ ├── view.html # Single course view
│ ├── lookup.html # Task ID lookup
│ └── generation_started.html # Success page
├── static/
│ ├── css/ # Stylesheets
│ ├── js/ # JavaScript files
├── main.py # API server entry point
├── app.py # Web interface entry point
├── config.py # Configuration settings
├── requirements.txt # Dependencies
└── README.md # This file
Generated courses follow this structure:
{
"title": "Introduction to Python Programming",
"description": "A beginner course designed for high school students...",
"topic": "Python Programming",
"depth": "beginner",
"target_audience": "High school students",
"course_duration": "4 weeks",
"modules": [
{
"title": "Getting Started with Python",
"description": "Basic concepts and setup",
"duration": "1 week",
"lessons": [
{
"title": "Installing Python and First Steps",
"content": "Detailed lesson content...",
"resources": [
"Python.org documentation",
"Intro to Programming with Python (e-book)"
]
}
]
}
],
"references": [
"Python Documentation, Python Software Foundation, 2023",
"..."
]
}
- This project uses LangChain for LLM orchestration
- The research component is powered by Tavily API and arXiv.
- The content generation is handled by OpenAI models