AI Course Generator is a full-stack learning assistant that turns a topic into a structured course, suggests related YouTube videos, and lets users download the generated course as a PDF.
The project includes:
- a Spring Boot backend for course generation, persistence, PDF export, and YouTube recommendations
- a React frontend with a chat-style interface for generating and viewing courses
- Generates a course from a single topic prompt
- Structures the result into modules and lessons
- Stores generated courses in MongoDB
- Returns YouTube recommendations alongside the course response
- Exports a generated course as a PDF
- Provides a frontend interface for interacting with the APIs
- Java 21
- Spring Boot
- Spring Security
- Spring Data MongoDB
- Maven
- Gemini API
- YouTube Data API
- iText PDF
- React
- Vite
- JavaScript
.
├── frontend/ # React frontend
├── src/ # Spring Boot backend source
│ ├── main/
│ └── test/
├── .mvn/ # Maven wrapper files
├── mvnw
├── mvnw.cmd
├── pom.xml
└── README.md
POST /v1/api/course/generate
Content-Type: application/jsonRequest:
{
"topic": "Java Basics"
}Sample response shape:
{
"id": "course-id",
"title": "Java Basics",
"description": "A beginner-friendly introduction to Java.",
"modules": [
{
"id": "module-id",
"title": "Introduction to Java",
"lessons": [
{
"id": "lesson-id",
"title": "What is Java?"
}
]
}
],
"youtubeRecommendations": [
{
"videoId": "abc123",
"title": "Java Full Course",
"description": "Video description",
"thumbnailUrl": "https://...",
"videoUrl": "https://www.youtube.com/watch?v=abc123",
"channelTitle": "Channel Name"
}
]
}GET /v1/api/course/{id}GET /v1/api/course/youtube-recommendations?courseName=Java%20Basics&maxResults=5GET /v1/api/course/{id}/youtube-recommendations?maxResults=5GET /courses/{id}/pdf- A user enters a learning topic in the frontend or calls the backend API directly.
- The backend sends a prompt to Gemini to generate a structured course.
- The generated content is parsed into course, module, and lesson objects.
- The course is saved in MongoDB.
- Related YouTube videos are fetched using the generated course title.
- The final course response is returned with optional video recommendations.
- The user can download the saved course as a PDF.
The project is set up so secrets do not need to be committed to Git.
The backend reads its main configuration from:
For local development, secrets can be placed in:
src/main/resources/application-secrets.properties
That file is ignored by Git.
You can also provide values through environment variables:
export GEMINI_API_KEY="your_gemini_api_key"
export YOUTUBE_API_KEY="your_youtube_api_key"
export GOOGLE_CLIENT_ID="your_google_client_id"
export JWT_SECRET="your_jwt_secret"
export MONGODB_URI="mongodb://localhost:27017/lesson"For MongoDB Atlas or cloud deployment, use a full connection string instead of localhost. Example:
export MONGODB_URI="mongodb+srv://username:password@cluster0.virueoi.mongodb.net/lesson?retryWrites=true&w=majority&appName=Cluster0"If your URI does not include a database name, also set:
export MONGODB_DATABASE="lesson"Supported MongoDB environment variable names are:
SPRING_DATA_MONGODB_URIMONGODB_URIMONGO_URLMONGO_URISPRING_DATA_MONGODB_DATABASEMONGODB_DATABASE
For frontend deployments, allow your production frontend origin in the backend with one of:
export FRONTEND_URL="https://your-frontend-domain.vercel.app"or
export APP_CORS_ALLOWED_ORIGINS="https://your-frontend-domain.vercel.app,https://your-custom-domain.com"Create a local frontend env file from:
cp frontend/.env.example frontend/.envSet:
VITE_API_BASE_URL=http://localhost:8080Example with Docker:
docker run -d -p 27017:27017 --name mongo mongoFrom the project root:
./mvnw spring-boot:runThe backend runs on:
http://localhost:8080
From the frontend directory:
npm install
npm run devThe frontend usually runs on:
http://localhost:5173
To run backend tests:
./mvnw testTo build the frontend:
cd frontend
npm run build- Keep backend and frontend deployments separate unless you intentionally bundle them behind one server.
- Set production environment variables instead of hardcoding secrets.
- Update the frontend API base URL to point to the deployed backend.
- Make sure MongoDB is reachable from the deployed backend.
- Configure CORS in the backend for your deployed frontend domain if needed.
The repository currently contains:
- Spring Boot backend APIs for course generation, YouTube recommendations, and PDF export
- React frontend with a chat-style course generation flow
- local-only secrets support through an ignored config file