An AI-powered learning platform that leverages AI to help students study and prepare better for their examinations.
- Problem Statement
- Solution Overview
- Architecture
- Tech Stack
- Repository Structure
- Features
- Getting Started
- API Documentation
- Development
- License
- Contributing
Students and learners often struggle with:
- Information Overload: Difficulty organizing and managing large amounts of study material
- Retrieval Inefficiency: Spending excessive time searching through notes to find relevant information
- Lack of Personalization: Generic study tools that don't adapt to individual learning needs
- Limited Intelligence: Simple search functionality without understanding context and relevance
- Assessment Challenges: Creating relevant question papers and mock tests tailored to their study materials
ClarifAI solves these problems by providing an intelligent, context-aware learning assistant that:
- Organizes learning materials by topics
- Uses vector embeddings to understand semantic meaning
- Performs intelligent question-answering with Retrieval-Augmented Generation (RAG)
- Falls back to pure LLM capabilities when no relevant materials exist
- Generates assessment papers and practice questions from study materials
- Tracks learning progress through assessments
ClarifAI is a Comprehensive Intelligent Learning Platform that combines:
-
Retrieval-Augmented Generation (RAG): When users have uploaded learning materials
- Searches through user's knowledge base using vector similarity
- Provides answers grounded in user's study materials
- Ensures accuracy and relevance
-
Generative AI Fallback: When no relevant materials exist
- Leverages Google Gemini Pro's knowledge
- Provides comprehensive answers without context
- Seamless transition between modes
-
Intelligent Assessment Generation: Creates personalized test papers and assessments
- Generates questions based on user's study materials and topics
- Creates mock tests for exam preparation
- Provides topic-specific practice assessments
- Helps identify knowledge gaps through assessment results
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β HTTP/REST API
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Backend (Django Framework) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Accounts β Topic β Knowledge β Query β Assessment β
β ββββββββ β ββββββ β ββββββββββ β ββββββ β ββββββββββ β
β β’ Register β β’ Submit β β’ Embeddings β β’ QA β β’ Quiz Paper Generation β
β β’ OTP β β’ Notes β β β’ RAG β β
β β’ Auth β β β β’ LLM β β
ββββββ¬ββββββββββββββ¬βββββββββββββββ¬βββββββββββββ¬ββββββββββββββ¬ββββββββββββββββββββ
β β β β β
βΌ βΌ βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βSQLite ββJWT ββPinecone ββGoogle AI ββAssessment Gen β
β ββTokens ββVectors ββGemini ββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
User sends question
β
βΌ
ββββββββββββββββββββββ
β Verify User Token β
ββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββ
β Verify Topic Ownership
ββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββ
β Generate Embedding β (Sentence Transformers)
β for Question β
ββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββ
β Search Vector DB β (Pinecone)
β for Similar Notes β
ββββββββββββββββββββββ
β
ββββ Found Relevant Materials βββββ
β β
βΌ βΌ
RAG Mode LLM-Only Mode
βββββββββ βββββββββββββ
Context + Q Q Only
β β
ββββββββββββββββ¬ββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββ
β Generate Answer β
β (Google Gemini) β
ββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββ
β Return Response β
β β
ββββββββββββββββββββββ
| Component | Technology | Purpose |
|---|---|---|
| Framework | Django 6.0.2 | Web framework |
| API | Django REST Framework 3.15.2 | RESTful API |
| Authentication | djangorestframework-simplejwt 5.3.1 | JWT tokens |
| Embeddings | sentence-transformers 3.0.1 | Text embeddings |
| Vector DB | Pinecone 5.0.0 | Vector search |
| LLM | google-generativeai 0.8.3 | Gemini AI |
| Database | SQLite 3 | Local storage |
| Django SMTP | OTP delivery | |
| CORS | django-cors-headers 4.6.0 | Cross-origin support |
- Dependencies: See requirements.txt
- Python Version: 3.8+
- Virtual Environment: venv
backend/
βββ core/ # Django project settings
β βββ settings.py # Configuration
β βββ urls.py # URL routing
β βββ wsgi.py # WSGI app
β βββ asgi.py # ASGI app
β
βββ accounts/ # User authentication & registration
β βββ models.py # EmailOTP model
β βββ views.py # Auth endpoints
β βββ serializers.py # Request/response serializers
β βββ urls.py # Auth routes
β βββ migrations/ # Database migrations
β
βββ topic/ # Topic management
β βββ models.py # Topic model
β βββ views.py # Topic endpoints
β βββ serializers.py # Serializers
β βββ urls.py # Routes
β βββ migrations/
β
βββ knowledge/ # Knowledge base management
β βββ models.py # KnowledgeNote model
β βββ views.py # CRUD endpoints
β βββ serializers.py # Serializers
β βββ vector_utils.py # Vector embeddings & search
β βββ urls.py # Routes
β βββ migrations/
β
βββ query/ # Question-answering system
β βββ models.py # Query models
β βββ views.py # QA endpoints
β βββ serializers.py # Serializers
β βββ urls.py # Routes
β
βββ assessment/ # Assessment module
β βββ models.py # Assessment models
β βββ views.py # Assessment endpoints
β βββ urls.py # Routes
β βββ migrations/
β
βββ manage.py # Django management
βββ db.sqlite3 # SQLite database
βββ requirements.txt # Dependencies
βββ .env # Environment variables (gitignored)
βββ .env.example # Example environment file
β
βββ README.md # This file
- Email Verification: OTP-based email verification
- Secure Password: Password validation with strength requirements
- JWT Authentication: Token-based authentication
- Account Management: Secure logout
- Topic-Based Organization: Organize notes by topics
- Rich Text Storage: Store detailed study materials
- Vector Embeddings: Automatic semantic embedding generation
- User Privacy: Each user's notes are isolated and secure
- Hybrid Approach: RAG when materials exist, pure LLM otherwise
- Context Aware: Grounds answers in user's study materials
- Fallback Support: Seamless fallback to LLM when no materials match
- Transparency: Response includes
used_ragflag
- Question Paper Generation: AI-powered generation of questions based on study materials
- Mock Tests: Create full-length mock exams for practice
- Topic-Specific Assessments: Generate quizzes targeting specific topics
- Difficulty Levels: Customize assessment difficulty based on learning progress
- Progress Tracking: Monitor learning progress through assessment scores
- Performance Analytics: Identify strengths and knowledge gaps
- Python 3.8 or higher
- pip or conda
- Git
git clone https://github.com/yourusername/ClarifAI.git
cd ClarifAI/backendpython -m venv .venv
source .venv/bin/activate pip install -r requirements.txtCopy .env.example to .env and fill in your credentials:
cp .env.example .env Edit .env with your settings:
GOOGLE_API_KEY=your_google_gemini_api_key_here
SECRET_KEY='your_django_secret_key_here'
PINECONE_API_KEY=your_pinecone_api_key_here
PINECONE_ENV=gcp-starter
PINECONE_INDEX_NAME=knowledge-notes
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USE_TLS=True
EMAIL_HOST_USER=your-email@gmail.com
EMAIL_HOST_PASSWORD=your-app-password
DEFAULT_FROM_EMAIL=your-email@gmail.compython manage.py makemigrations
python manage.py migratepython manage.py createsuperuserpython manage.py runserverThe API will be available at http://localhost:8000/api/
POST /api/accounts/register/send-otp/
Content-Type: application/json
{
"email": "user@example.com"
}
Response: 200 OK
{
"message": "OTP sent to email."
}POST /api/accounts/register/verify-otp/
Content-Type: application/json
{
"email": "user@example.com",
"username": "john_doe",
"password": "SecurePassword123!",
"password2": "SecurePassword123!",
"otp": "123456"
}
Response: 201 Created
{
"message": "Registration successful.",
"user": {
"id": 1,
"username": "john_doe",
"email": "user@example.com"
},
"access": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGc..."
}POST /api/accounts/login/
Content-Type: application/json
{
"username": "john_doe",
"password": "SecurePassword123!"
}
Response: 200 OK
{
"access": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGc..."
}GET /api/accounts/me/
Authorization: Bearer <access_token>
Response: 200 OK
{
"id": 1,
"username": "john_doe",
"email": "user@example.com"
}POST /api/accounts/logout/
Authorization: Bearer <access_token>
Content-Type: application/json
{
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGc..."
}
Response: 205 Reset ContentPOST /api/query/
Authorization: Bearer <access_token>
Content-Type: application/json
{
"question": "What is photosynthesis?",
"topic": "550e8400-e29b-41d4-a716-446655440000"
}
Response: 200 OK
{
"answer": "Photosynthesis is the process by which plants...",
"context": [
"Notes about photosynthesis from your materials...",
"More detailed information..."
],
"used_rag": true
}Note: used_rag will be false if no relevant materials were found.
- App-Based Architecture: Each Django app handles a specific domain
- Separation of Concerns: Models, views, and serializers are separate
- Clean Code: Clear naming, proper error handling, type hints where appropriate
- Security: Hashed passwords, token blacklisting, email verification
python manage.py startapp app_namepython manage.py makemigrationspython manage.py migratepython manage.py shellpython manage.py createsuperuserNavigate to http://localhost:8000/admin/
| Variable | Purpose | Example |
|---|---|---|
SECRET_KEY |
Django secret key | your-secret-key |
DEBUG |
Debug mode | True (development only) |
ALLOWED_HOSTS |
Allowed domains | localhost,127.0.0.1 |
EMAIL_HOST |
SMTP server | smtp.gmail.com |
EMAIL_PORT |
SMTP port | 587 |
EMAIL_USE_TLS |
Enable TLS | True |
EMAIL_HOST_USER |
Email account | your-email@gmail.com |
EMAIL_HOST_PASSWORD |
App password | your-app-password |
DEFAULT_FROM_EMAIL |
Sender email | your-email@gmail.com |
GOOGLE_API_KEY |
Gemini API key | your-api-key |
PINECONE_API_KEY |
Pinecone API key | your-pinecone-key |
PINECONE_ENV |
Pinecone environment | gcp-starter |
PINECONE_INDEX_NAME |
Pinecone index | knowledge-notes |
- Go to Google AI Studio
- Create a new API key
- Add to
.envasGOOGLE_API_KEY
- Sign up at Pinecone
- Create a new index with dimension 384 (for sentence-transformers)
- Get environment and API key
- Add to
.env
- Enable 2-Factor Authentication on Google Account
- Generate App Password at https://myaccount.google.com/apppasswords
- Use App Password in
.env
- Check email credentials in
.env - Verify SMTP port is not blocked (587 for Gmail)
- Check email logs:
python manage.py shellβfrom django.core.mail import send_mail
- Ensure Pinecone API key is valid
- Check network connectivity
- Verify index name matches
PINECONE_INDEX_NAME
- Validate
GOOGLE_API_KEY - Check API quotas in Google Cloud Console
- Ensure API is enabled for your project
python manage.py migrate accounts zero
python manage.py migrate
python manage.py makemigrations --empty accounts --name fix_whatever- Database Indexing: Important fields are indexed
- Vector Caching: Pinecone handles caching
- Query Optimization: Use
.select_related()and.prefetch_related() - Pagination: Implement pagination for large result sets
- Rate Limiting: Add rate limiting in production
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Commit with clear messages (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PEP 8 guidelines
- Use meaningful variable names
- Add docstrings to functions and classes
- Write clean, professional code
This project is licensed under the MIT License - see the LICENSE file for details.
You are free to:
- β Use the software commercially
- β Modify the source code
- β Distribute copies of the software
- β Use it privately
You must:
- βΉοΈ Include the original license notice
- βΉοΈ Provide a copy of the license
The software is provided "AS IS" without warranty.
MIT License
Copyright (c) 2026 Divyansh
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
For questions, issues, or suggestions:
- GitHub Issues: Create an issue
- Email: your-email@example.com
- Documentation: See EMAIL_OTP_DOCUMENTATION.md
- Django Documentation
- Django REST Framework
- Pinecone Documentation
- Sentence Transformers
- Google Gemini API
- Built with Django
- Embeddings powered by Sentence Transformers
- Vector search by Pinecone
- AI capabilities from Google Gemini
Last Updated: March 9, 2026
Version: 1.0.0
ClarifAI - Making Learning Intelligent