Retrieval Augmented Generation (RAG) platform for modern education — powered by Gemini AI & Supabase
- User Authentication — Users register/login with institution ID and password. JWT tokens are issued for secure access.
- PDF Upload & Indexing — Teachers/Admins upload PDFs. Text and images are extracted, chunked, and embedded using Gemini AI. All data is stored in Supabase.
- RAG Search — Students/Teachers/Admins can ask questions. The system finds relevant chunks using vector similarity and generates an answer with source citations using Gemini.
- Feedback & Analytics — Teachers submit feedback to admins. Analytics dashboards show usage, trending topics, and engagement.
See docs/SETUP.md for local setup and docs/API.md for API reference.
EduRag is an intelligent educational platform that uses Retrieval Augmented Generation (RAG) powered by Google Gemini AI to let students and teachers search, query, and get AI-generated answers from uploaded PDFs.
- 100% Supabase — all data (users, PDFs, embeddings, analytics) stored in Supabase PostgreSQL + Storage. Zero local storage.
- Fully Serverless — deployed on Vercel (React static + FastAPI serverless function). No separate backend server needed.
- Gemini Multimodal RAG — semantic search with vector embeddings, AI-generated answers with source citations.
- Adaptive Study Plan Generator — Turn any topic into a practical 7-day learning plan with daily goals, revision prompts, and common mistakes to avoid.
- Hinglish-Aware Learning Experience — Supports English, Hindi, and Hinglish responses with auto-detection for mixed-language student queries.
- Peer Discovery (Buddies) — Students can discover classmates and learning peers, making collaboration easier beyond search.
- RAG Search — ask questions in natural language, get AI-generated answers with source citations
- Adaptive Study Plan — generate a 7-day AI-guided study schedule for a topic
- Smart Recommendations — personalized topic suggestions based on search behavior
- PDF Upload — upload and organize study materials
- Peer Discovery — view and connect with classmates (Buddies)
- Anonymous Feedback — share thoughts with teachers anonymously
- Profile Management — customize name and avatar
- Content Upload & Indexing — upload PDFs and index them for RAG search
- AI Document Summary — produce concise revision summaries from indexed materials
- Student Analysis — monitor trending topics students are searching for
- Feedback Dashboard — receive and respond to student feedback
- Analytics Overview — class engagement and performance metrics
- RAG Search — search across all uploaded materials
- User Management — manage all users, change roles (student/teacher/admin)
- System Analytics — platform-wide usage statistics
- PDF Management — upload, index, and manage all PDFs
- RAG Search — system-wide search across all content
- Feedback Review — review all teacher feedback
| Layer | Technology |
|---|---|
| Frontend | React 18, React Router v6, Axios, CSS3 |
| Backend | FastAPI (Python), Pydantic, Python-JOSE (JWT), Passlib (bcrypt) |
| Database | Supabase PostgreSQL (8 tables + RLS policies) |
| Storage | Supabase Storage (private pdfs bucket) |
| AI/ML | Google Gemini AI — gemini-embedding-001 (embeddings), gemini-3-flash-preview (generation) |
| Deployment | Vercel (React static + Python serverless function) |
+------------------+ +-------------------+ +------------------+
| React SPA | | FastAPI | | Supabase |
| (Vercel CDN) |<------>| (Vercel Serverless|<------>| PostgreSQL + |
| | HTTPS | Python Function) | SQL | Storage |
+------------------+ +-------------------+ +------------------+
|
v
+-------------------+
| Google Gemini AI |
| Embeddings + |
| Generation |
+-------------------+
flowchart LR
U[User Browser] --> FE[React Frontend]
FE --> API[FastAPI Backend]
API --> AUTH[JWT Auth + RBAC]
API --> DB[(Supabase Postgres)]
API --> ST[(Supabase Storage)]
API --> AI[Gemini Models]
DB --> A[Analytics]
ST --> R[RAG Indexing]
R --> DB
routers/— HTTP transport and request/response mappingcore/— cross-cutting framework concerns (RBAC dependencies)services/— reusable business logic (chat operations, websocket manager)models.py— schema validation contractsdatabase.py— Supabase connectivity
flowchart TB
Client[React Client] --> Router[FastAPI Routers]
Router --> Core[Core Layer: RBAC Dependencies]
Router --> Service[Service Layer: Chat + Realtime]
Router --> Model[Models Layer: Pydantic Schemas]
Service --> DB[(Supabase)]
Router --> DB
flowchart LR
Req[Incoming Request] --> JWT[Decode JWT]
JWT --> Role[Extract User Role]
Role --> Guard{Role Allowed?}
Guard -->|Yes| Handler[Run Route Handler]
Guard -->|No| Forbidden[HTTP 403]
sequenceDiagram
participant C as Client
participant WS as /api/ws/chat
participant M as ConnectionManager
C->>WS: Connect with token query param
WS->>WS: Validate JWT token
WS->>M: Register connection
C->>WS: Send chat/update payload
WS->>M: Broadcast payload
M-->>C: Push update to subscribers
- Authentication — Custom JWT (bcrypt + python-jose) → Role-based access (student/teacher/admin)
- PDF Upload — Supabase Storage → Extract text (PyPDF) → Chunk → Embed with Gemini → Store vectors in Supabase
- RAG Search — Query embedding → Cosine similarity (threshold >= 0.65) → Top results → Gemini generates answer with source citations
- Analytics — Event tracking → Supabase aggregation → Dashboard visualization
| Control | Status | File |
|---|---|---|
| Password Hashing | bcrypt via passlib | backend/routers/auth.py |
| Authentication | JWT Bearer tokens | backend/routers/auth.py |
| Authorization/RBAC | Role guards | backend/core/rbac.py |
| Rate Limiting | SlowAPI + middleware | backend/core/rate_limit.py |
| CORS | CORSMiddleware | backend/main.py |
| Security Headers | Custom middleware | backend/main.py |
| Input Validation | bleach + validators | backend/models.py |
| SQL Injection | ORM (SQLAlchemy) parameterized queries | backend/database.py |
| XSS Prevention | bleach sanitization | backend/models.py |
| Trusted Hosts | TrustedHostMiddleware | backend/main.py |
The entire app deploys as one Vercel project — React frontend as static files, FastAPI backend as a Python serverless function.
- Push to GitHub
git add -A && git commit -m "deploy" && git push origin main-
Import in Vercel — Go to vercel.com/new and import
KAVYA-29-ai/EDU-RAG -
Add Environment Variables in Vercel dashboard:
| Variable | Description |
|---|---|
SUPABASE_URL |
Supabase project URL |
SUPABASE_KEY |
Supabase anon/public key |
SUPABASE_SERVICE_ROLE_KEY |
Supabase service role key |
GEMINI_API_KEY |
Google Gemini API key |
JWT_SECRET |
Secret key for JWT tokens |
JWT_ALGORITHM |
HS256 |
ACCESS_TOKEN_EXPIRE_MINUTES |
60 |
- Deploy — click Deploy and you're live!
- Node.js 16+ and npm
- Python 3.11+
- Supabase account (create tables using
backend/supabase_schema.sql) - Google Gemini API key
# Clone
git clone https://github.com/KAVYA-29-ai/EDU-RAG.git
cd EDU-RAG
# Frontend
npm install
# Backend
cd backend
pip install -r requirements.txt
cp .env.example .env
cd ..
# Run both
npm start
cd backend && uvicorn main:app --reload --port 8000pytest -vnpm run test:cipytest tests/ -v --cov=backend --cov-report=xmlNote: the repository uses pytest.ini at root with testpaths = tests and python_files = test_*.py.
EDU-RAG/
+-- api/
| +-- index.py # Vercel serverless entry point
+-- backend/
| +-- main.py # FastAPI app + CORS + SPA serving
| +-- database.py # Supabase client initialization
| +-- models.py # Pydantic request/response models
| +-- core/
| | +-- rbac.py # Reusable role-based access dependencies
| +-- services/
| | +-- chat_service.py # Chat business logic
| | +-- realtime.py # WebSocket connection manager
| +-- supabase_schema.sql # All 8 tables + RLS + storage bucket
| +-- requirements.txt # Python dependencies
| +-- .env.example # Environment variable template
| +-- routers/
| +-- auth.py # Register, Login, JWT, /me
| +-- users.py # User CRUD, role management
| +-- rag.py # RAG search, PDF upload/index/delete
| +-- feedback.py # Teacher <-> Admin feedback
| +-- analytics.py # Usage stats & student insights
+-- src/
| +-- pages/
| | +-- HomePage.js
| | +-- LoginRegister.js
| | +-- StudentDashboard.js
| | +-- TeacherDashboard.js
| | +-- AdminDashboard.js
| +-- components/
| | +-- AnimatedBackground.js
| +-- services/
| | +-- api.js
| +-- App.js
| +-- index.js
+-- vercel.json
+-- package.json
+-- requirements.txt
| Table | Purpose |
|---|---|
users |
User accounts (institute_id, name, password_hash, role, avatar) |
search_history |
RAG search logs per user |
feedback |
Teacher to Admin feedback with responses |
student_feedback |
Student to Teacher anonymous feedback |
analytics_events |
Usage tracking events |
pdfs |
Uploaded PDF metadata |
pdf_chunks |
Extracted text chunks from PDFs |
rag_embeddings |
Gemini vector embeddings for each chunk |
Storage: Private pdfs bucket in Supabase Storage.
FastAPI auto-generated docs available at /docs (Swagger UI) and /redoc (ReDoc).
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Register new user |
| POST | /api/auth/login |
Login, get JWT token |
| POST | /api/auth/forgot-password |
Request password reset link |
| POST | /api/auth/reset-password |
Reset password using reset token |
| PATCH | /api/auth/change-password |
Change password for logged-in user |
| GET | /api/auth/me |
Get current user profile |
| POST | /api/auth/logout |
Logout |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/rag/search |
Semantic RAG search with AI answer |
| POST | /api/rag/upload-pdf |
Upload PDF (teacher/admin) |
| POST | /api/rag/pdfs/{id}/index |
Index PDF for search |
| GET | /api/rag/pdfs |
List all PDFs |
| DELETE | /api/rag/pdfs/{id} |
Delete PDF (teacher/admin) |
| GET | /api/rag/pdfs/{id}/summary |
AI study summary for indexed PDF |
| GET | /api/rag/search-history |
User's search history |
| GET | /api/rag/trending |
Trending search topics |
| GET | /api/rag/recommendations |
Personalized topic recommendations |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/users/ |
List all users (admin) |
| GET | /api/users/students |
List students |
| GET | /api/users/teachers |
List teachers |
| PATCH | /api/users/{id}/role |
Change user role (admin) |
| DELETE | /api/users/{id} |
Delete user (admin) |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/feedback/ |
Submit feedback |
| GET | /api/feedback/ |
Get all feedback (admin) |
| GET | /api/analytics/summary |
System analytics (admin) |
| GET | /api/analytics/student-insights |
Student trends (teacher) |
- React SPA with role-based dashboards (Student, Teacher, Admin)
- Custom JWT authentication (register, login, role management)
- 100% Supabase migration (8 tables + storage bucket, zero local DB)
- PDF upload to Supabase Storage
- PDF indexing — text extraction → chunking → Gemini embedding → store vectors
- RAG semantic search with cosine similarity (threshold >= 0.65)
- AI-generated answers using Gemini with source citations
- Language-aware answer generation (English, Hindi, Hinglish)
- AI study summaries for indexed PDFs
- Personalized topic recommendations from search behavior
- Keyword fallback search when semantic search has no results
- Search history tracking
- Trending topics analytics
- Teacher/Admin feedback system
- Student anonymous feedback
- User management (CRUD, role changes)
- System analytics dashboard
- Forgot password + reset token flow
- Animated UI with gradient backgrounds
- Vercel serverless deployment configuration
- CORS configured for Vercel + Codespaces + localhost
- Rate limiting (SlowAPI + in-memory middleware)
- Security headers middleware (HSTS, CSP, XFO)
- Input sanitization (bleach + Pydantic validators)
- CI pipeline (Backend Tests + Frontend Tests + Lint)
- Password reset with OTP and branded email templates
- Google OAuth integration
- Mobile-responsive optimization
- Real-time collaboration features
- Advanced analytics with charts and export
- Video content support
- Batch document processing
- Improved Hindi/Hinglish language support
Create backend/.env (see backend/.env.example):
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
JWT_SECRET=your-secret-key
JWT_ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=60
GEMINI_API_KEY=your-gemini-api-key
REQUIRE_EMAIL_VERIFICATION=false
EMAIL_VERIFICATION_EXPIRE_HOURS=24
PASSWORD_RESET_EXPIRE_MINUTES=30
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-app-password
FROM_EMAIL=your-email@gmail.com
EXPOSE_RESET_LINK=trueNever commit .env files to version control.
Team Leader — Khushi Saraswat — github.com/khushisara1
Contributors
- Kavya Rajput — github.com/KAVYA-29-ai
- Harshita Shakya — github.com/HarshitaShakya
Repository — github.com/KAVYA-29-ai/EDU-RAG
