LearnFlow is an AI-powered adaptive learning platform that helps students master their subjects through intelligent question generation, personalized study plans, and exam preparation tools.
- Upload lecture notes (text or PDF) and automatically generate high-quality MCQ questions
- Questions include difficulty levels (0.2-0.9), explanations, and topic tagging
- Powered by Google's Gemini 2.0 Flash AI model
- Topic Mastery Tracking: ML-based algorithm tracks mastery levels (0-1 scale) for each topic
- Weakness Detection: Identifies weak topics based on answer correctness and time taken
- Adaptive Question Selection: Selects questions based on:
- User's weak topics (50% of questions)
- Target difficulty matching user's accuracy
- Avoids recently answered questions
- Real-time progress tracking (accuracy, total questions, correct answers)
- Topic-wise weakness scores with time-based analysis
- User streaks (global and per-topic)
- Quiz attempt history with performance metrics
- AI-generated study plans based on:
- Identified weak topics
- User's learning history
- Recommended resources (articles, videos, explanations)
- Practice and revision schedules
- Syllabus Upload: Upload exam syllabi (text or PDF)
- Previous Paper Analysis: Upload previous question papers for pattern recognition
- AI Question Generation: Generate exam questions with:
- Custom mark distribution (e.g., 2 marks: 5 questions, 5 marks: 3 questions)
- Priority-based ordering (most important topics first)
- Pattern-based questions from previous papers
- "Secure Centum Mode" for comprehensive coverage
- Exam Strategy Generator: Creates day-by-day study schedules based on:
- Days remaining until exam
- Hours available per day
- Prioritized topics from pattern analysis
- Generate flashcards from lecture notes for quick revision
- AI-powered content summarization
- Automatically summarize lengthy lecture notes
- Extract key concepts and important points
- JWT-based authentication with access and refresh tokens
- Google OAuth 2.0 integration for social login
- User profile management with avatars and bio
- Real-time notifications for:
- Question generation completion
- Quiz completion with performance feedback
- Study milestones and achievements
- Mark as read/unread functionality
- Bulk notification management
- Automatically detects "Scanned" vs "Digital" PDFs
- advanced "Exam-Ready" noise filter removes:
- Headers, Footers, Page numbers
- Conversational filler & decorative text
- Hyphenated line breaks
- Uses Tesseract OCR for image-based documents
- Generate "Podcast-style" video scripts with two distinct speakers (Host & Expert)
- Parallel asset generation for near-zero latency
- Cinematic slides with glassmorphism overlays and AI-generated imagery
- Interactive Features (Quiz, Planner): Powered by Mistral 7B (~3s latency)
- Creative Features (Video, Flashcards): Powered by Llama 3 70B (High Intelligence)
- Framework: Django 5.2.8
- API: Django REST Framework with JWT authentication
- Database: SQLite (development) - easily switchable to PostgreSQL/MySQL
- AI Integration: Hybrid Engine (Google Gemini 2.0 Flash + Mistral 7B + Llama 3)
- PDF Processing: Hybrid OCR Pipeline (Tesseract + Poppler + pdfplumber)
- Authentication:
rest_framework_simplejwtfor JWT tokensdjango-allauthfor Google OAuth
- Framework: React 19.2.0
- UI Library: Material-UI (MUI) 7.3.5
- Styling: TailwindCSS 4.1.17 + Emotion
- Routing: React Router DOM 7.9.6
- HTTP Client: Axios 1.13.2
- Animations: Framer Motion 12.23.24
- Charts: Recharts 3.4.1
- Markdown Rendering: react-markdown 10.1.0
- Diagrams: Mermaid 11.12.1
- File Upload: react-dropzone 14.3.8
- Python: 3.8 or higher
- Node.js: 14.x or higher
- npm: 6.x or higher
- Tesseract-OCR: v5.0+ (Required for Scanned PDFs)
- Poppler: (Required for PDF-to-Image conversion)
- Google Gemini API Key: Get it here
- Google OAuth Credentials (optional): For social login
git clone https://github.com/yourusername/LearnFlow.git
cd LearnFlowpython -m venv venv
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activatepip install django djangorestframework django-cors-headers djangorestframework-simplejwt google-generativeai pdfplumber python-dotenv django-allauthCreate a .env file in the root directory:
GEMINI_API_KEY=your_gemini_api_key_herepython manage.py makemigrations
python manage.py migratepython manage.py createsuperuserpython manage.py runserverBackend will run at http://localhost:8000
cd frontendnpm installnpm startFrontend will run at http://localhost:3000
Follow the detailed guide in GOOGLE_OAUTH_SETUP.md
Quick Steps:
- Create OAuth credentials in Google Cloud Console
- Add redirect URI:
http://localhost:8000/accounts/google/login/callback/ - Configure in Django Admin (
/admin) under Social applications - Add Client ID and Secret
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register/ |
Register new user |
| POST | /api/auth/login/ |
Login (returns JWT tokens) |
| POST | /api/auth/refresh/ |
Refresh access token |
| GET | /api/auth/me/ |
Get current user details |
| GET | /accounts/google/login/ |
Google OAuth login |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/upload-note/ |
Upload lecture note (text/PDF) |
| GET | /api/lectures/ |
List all lecture notes |
| GET | /api/lectures/{id}/ |
Get specific lecture note |
| GET | /api/note-details/{note_id}/ |
Get note details |
| POST | /api/upload-pdf/ |
Upload PDF (Supports Digital & Scanned via OCR) |
| POST | /api/lectures/{note_id}/summarize/ |
Summarize lecture note |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/generate-questions/{note_id}/ |
Generate 5 MCQ questions |
| POST | /api/generate-mcqs/ |
Generate MCQs (batch) |
| GET | /api/quiz/{note_id}/ |
Get quiz questions (default 20) |
| POST | /api/submit-mcq/ |
Submit MCQ answer |
| POST | /api/adaptive/quiz/start/ |
Start adaptive quiz |
| POST | /api/quiz-completed/ |
Mark quiz as completed |
| PUT | /api/questions/{question_id}/update/ |
Update question |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/weak-topics/ |
Get weak topics for a note |
| GET | /api/progress/ |
Get overall progress |
| GET | /api/analytics/{note_id}/ |
Get analytics for specific note |
| GET | /api/recent-weak-topics/ |
Get recent weak topics |
| GET | /api/next-actions/ |
Get recommended next actions |
| GET | /api/ai-insights/{note_id}/ |
Get AI-powered insights |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/study-plan/ |
Generate personalized study plan |
| GET | /api/study-plan/{note_id}/ |
Get study plan for note |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/flashcards/generate/ |
Generate flashcards |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/exam/syllabi/ |
List all exam syllabi |
| POST | /api/exam/syllabus/upload/ |
Upload exam syllabus |
| POST | /api/exam/syllabus/{syllabus_id}/papers/ |
Upload previous papers |
| POST | /api/exam/syllabus/{syllabus_id}/generate/ |
Generate exam questions |
| GET | /api/exam/syllabus/{syllabus_id}/questions/ |
Get exam questions |
| POST | /api/exam/syllabus/{syllabus_id}/strategy/ |
Generate exam strategy |
| PUT | /api/exam/question/{question_id}/update/ |
Update exam question |
| DELETE | /api/exam/question/{question_id}/delete/ |
Delete exam question |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/notifications/ |
List all notifications |
| POST | /api/notifications/{id}/mark-read/ |
Mark notification as read |
| POST | /api/notifications/mark-all-read/ |
Mark all as read |
| DELETE | /api/notifications/{id}/delete/ |
Delete notification |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/video/generate/ |
Generate video script, audio, and slides |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/profile/ |
Get user profile |
| PUT | /api/profile/ |
Update user profile |
user(ForeignKey): Owner of the notetitle(CharField): Note titlefile(FileField): Uploaded PDF filecontent(TextField): Extracted/input text contentcreated_at(DateTimeField): Creation timestamp
lecture_note(ForeignKey): Associated lecture notetopic(CharField): Question topicquestion_text(TextField): Question contentoption_a,option_b,option_c,option_d(TextField): MCQ optionscorrect_option(CharField): Correct answer (A/B/C/D)explanation(TextField): Answer explanationdifficulty(FloatField): Difficulty level (0.2-0.9)
user(ForeignKey): User who answeredquestion(ForeignKey): Question answereduser_answer(TextField): User's selected optionis_correct(BooleanField): Correctness flagtime_taken(IntegerField): Time in secondsanswered_at(DateTimeField): Timestamp
lecture_note(ForeignKey): Associated noteuser(ForeignKey): Usertopic(CharField): Topic nameweakness_score(FloatField): Weakness score (0.0-2.0)
user(ForeignKey): Userlecture_note(ForeignKey): Associated notetopic(CharField): Topic namemastery(FloatField): Mastery level (0.0-1.0)last_updated(DateTimeField): Last update timestamp
user(ForeignKey): Usertopic(CharField): Topic (null for global streak)streak(IntegerField): Current streak countlast_updated(DateTimeField): Last update timestamp
user(ForeignKey): Userlecture_note(ForeignKey): Associated notescore(IntegerField): Score achievedtotal_questions(IntegerField): Total questionscompleted_at(DateTimeField): Completion timestamp
user(ForeignKey): Username(CharField): Badge namedescription(TextField): Badge descriptionicon(CharField): Badge icon/emojiearned_at(DateTimeField): Earned timestamp
user(ForeignKey): Ownertitle(CharField): Syllabus titlecontent(TextField): Syllabus contentfile(FileField): Uploaded PDFcreated_at,updated_at(DateTimeField): Timestamps
exam_syllabus(ForeignKey): Associated syllabusfile(FileField): Uploaded PDFcontent(TextField): Extracted textuploaded_at(DateTimeField): Upload timestamp
exam_syllabus(ForeignKey): Associated syllabusquestion_text(TextField): Questionanswer(TextField): Detailed answermarks(IntegerField): Mark weightagepriority(IntegerField): Priority (1 = highest)topic(CharField): Topicis_from_pattern(BooleanField): Based on previous papers
exam_syllabus(ForeignKey): Associated syllabustotal_marks(IntegerField): Total marksnum_questions(IntegerField): Number of questionsmark_distribution(JSONField): Mark distribution configsecure_centum_mode(BooleanField): Secure centum flag
graph TD
A[Upload Lecture Note] --> B[AI Generates Questions]
B --> C[Take Adaptive Quiz]
C --> D[System Tracks Performance]
D --> E{Weak Topics Detected?}
E -->|Yes| F[Generate Study Plan]
E -->|No| G[Continue Learning]
F --> H[Practice Weak Topics]
H --> C
G --> A
Steps:
- Upload Note: POST
/api/upload-note/with title and content - Generate Questions: POST
/api/generate-questions/{note_id}/ - Start Quiz: GET
/api/quiz/{note_id}/?n=20 - Submit Answers: POST
/api/submit-mcq/for each question - View Analytics: GET
/api/analytics/{note_id}/ - Get Study Plan: POST
/api/study-plan/
graph TD
A[Upload Exam Syllabus] --> B[Upload Previous Papers]
B --> C[AI Analyzes Patterns]
C --> D[Generate Exam Questions]
D --> E[Review & Edit Questions]
E --> F[Generate Study Strategy]
F --> G[Follow Day-by-Day Plan]
G --> H[Practice Generated Questions]
Steps:
- Upload Syllabus: POST
/api/exam/syllabus/upload/with PDF/text - Upload Papers: POST
/api/exam/syllabus/{id}/papers/with PDF files - Generate Questions: POST
/api/exam/syllabus/{id}/generate/with config:{ "total_marks": 100, "num_questions": 10, "mark_distribution": {"2": 5, "5": 3, "10": 2}, "secure_centum_mode": false } - Get Questions: GET
/api/exam/syllabus/{id}/questions/ - Generate Strategy: POST
/api/exam/syllabus/{id}/strategy/with:{ "days_remaining": 5, "hours_per_day": 4 }
Weakness Scoring:
- Wrong Answer:
weakness_score += 0.15 + (difficulty * 0.15) - Correct but Slow:
weakness_score += 0.03-0.08 * difficulty - Correct and Fast:
weakness_score -= 0.1-0.15 * mastery_gain
Mastery Calculation:
- Learning Rate: 0.05-0.12 based on difficulty
- Correct:
mastery += lr * (1.0 - current_mastery) - Wrong:
mastery -= lr * 0.6 * current_mastery - Clamped: 0.0 to 1.0
Question Selection:
- 50% from weak topics (easier questions first)
- 50% matching target difficulty based on accuracy
- Avoids last 100 answered questions
# Run all tests
python manage.py test
# Test specific app
python manage.py test core
# Verify models
python check_models.py
python list_models.pycd frontend
npm testcheck_django_key.py: Verify Django settings and Gemini API keytest_gemini.py: Test Gemini API connectivitytest_api_key.py: Validate Gemini API keyverify_quiz_count.py: Verify quiz question countsreproduce_study_plan.py: Test study plan generation
# JWT Token Lifetimes
SIMPLE_JWT = {
'ACCESS_TOKEN_LIFETIME': timedelta(minutes=60),
'REFRESH_TOKEN_LIFETIME': timedelta(days=1),
}
# CORS Configuration
CORS_ALLOW_ALL_ORIGINS = True # Change in production
# Gemini API
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")Update src/config.js (if exists) or use environment variables:
const API_BASE_URL = 'http://localhost:8000/api';1. Gemini API 429 Rate Limit
- The system has built-in retry logic with exponential backoff
- Wait a few seconds and try again
2. PDF Extraction Fails
- The system now supports SCANNED PDFs via Tesseract OCR.
- Ensure
Tesseract-OCRis installed on the server. - Ensure
poppler-utils(orpdftoppm) is in the System PATH.
3. Questions Not Generating
- Check Gemini API key in
.env - Verify API key with
python test_gemini.py - Check backend logs for detailed errors
4. Google OAuth Not Working
- Verify redirect URI matches exactly
- Check Site configuration in Django admin
- Ensure Social Application is configured
5. CORS Errors
- Verify
CORS_ALLOW_ALL_ORIGINS = Truein settings - Check frontend is running on port 3000
- Use database indexing on frequently queried fields
- Implement caching for analytics endpoints
- Use pagination for large question lists
- Lazy load components with React.lazy()
- Memoize expensive calculations
- Use virtual scrolling for long lists
Happy Learning! π