An end-to-end AI-powered teaching assistant that lets teachers upload study materials and students ask questions, generate quizzes, and track their learning progress β all powered by RAG (Retrieval-Augmented Generation).
π Live App: RAG-Based Teaching Assistant
πΉ Video Demo: (Add your screen recording link here β Loom, YouTube, etc.)
AI Guru is a full-stack, role-based AI teaching assistant built with a RAG (Retrieval-Augmented Generation) pipeline. Teachers upload PDF study materials which are chunked, embedded, and stored in a vector database. Students can then ask questions about those materials and receive AI-generated answers grounded in the actual documents β not hallucinated responses.
The system also features an AI quiz generator that creates multiple-choice questions from the uploaded content, allows students to submit answers, and tracks their performance history over time.
| Layer | Technology |
|---|---|
| Frontend | React.js, React Router, Axios, React Hot Toast |
| Backend | FastAPI, Python 3.12, Uvicorn |
| Authentication | HTTP Basic Auth, Bcrypt password hashing |
| Database | Supabase (PostgreSQL) |
| Vector Database | Pinecone |
| Embeddings | Google Gemini Embedding API (gemini-embedding-001, 3072 dimensions) |
| LLM | Groq API (LLaMA 3.3 70B) |
| RAG Framework | LangChain |
| PDF Processing | PyPDF, LangChain Document Loaders |
| Frontend Deployment | Vercel |
| Backend Deployment | Railway |
| Styling | Custom CSS with Fredoka One + Nunito fonts |
- π€ Upload PDF documents with drag & drop interface
- π·οΈ Grade-based access control β assign documents to specific grades
- π Automatic chunking & indexing β PDFs are split, embedded and stored in Pinecone + Supabase
- π¬ AI Chat β Ask questions about uploaded study materials
- π Source citations β Every answer shows which document it came from
- π§ Quiz Generator β Generate AI-powered MCQ quizzes on any topic
- β Quiz Checker β Submit answers and get instant scores with feedback
- π Quiz History β Track all past attempts with scores and progress bars
- Role-based access (Student / Teacher)
- Secure password hashing with Bcrypt
- Persistent chat and quiz history in Supabase
- Responsive, colorful educational UI
Here's how the system works end to end:
π Teacher uploads PDF
β
π¦ PDF is chunked (2000 chars, 50 overlap)
β
π’ Google Gemini generates 3072-dim embeddings
β
π Embeddings stored in Pinecone (with grade/role metadata)
πΎ Chunks stored in Supabase text table
β
π§βπ Student asks a question
β
π’ Question is embedded with same model
β
π Pinecone finds top-5 similar chunks (filtered by grade)
β
π Supabase fetches the actual text for those chunks
β
π€ Groq LLaMA generates answer using retrieved context
β
π¬ Answer + sources returned to student
- RAG Architecture β How to build a full retrieval-augmented generation pipeline from scratch, including chunking strategies, embedding models, and vector similarity search
- Vector Databases β How Pinecone stores and retrieves embeddings using cosine similarity and metadata filtering
- FastAPI β Building production-ready REST APIs with dependency injection, middleware, and async endpoints
- LangChain β Using prompt templates, chains, and document loaders to orchestrate LLM pipelines
- Full-Stack Development β Connecting a React frontend to a Python backend with proper CORS, authentication, and error handling
- Deployment β Deploying a full-stack app across multiple platforms (Vercel + Railway + Supabase + Pinecone)
- Debugging β Tracing issues across the entire stack from frontend β API β vector DB β LLM
- π JWT Authentication β Replace Basic Auth with proper JWT tokens for better security
- π§ Email verification β Add email OTP for account creation
- π Google OAuth β Sign in with Google for easier onboarding
- π Chat history per session β Maintain conversation context across multiple turns
- π― Reranking β Add a reranker model to improve retrieval quality
- π Teacher dashboard β Analytics showing which topics students struggle with
- π Notifications β Alert teachers when students complete quizzes
- π± Mobile app β React Native version for mobile learning
- π Multi-language support β Support regional languages for wider reach
- β‘ Streaming responses β Stream LLM responses token by token for better UX
- Python 3.12+
- Node.js 18+
- Accounts on: Supabase, Pinecone, Google AI Studio, Groq
git clone https://github.com/Sumitpal321/RAG-Based-Teaching-Assistant.git
cd RAG-Based-Teaching-Assistantcd server
pip install -r requirements.txtCreate a .env file in the server folder:
GOOGLE_API_KEY=your_google_api_key
GROQ_API_KEY=your_groq_api_key
PINECONE_API_KEY=your_pinecone_api_key
PINECONE_INDEX_NAME=tutor-rag
PINECONE_ENV=us-east-1
SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_keyRun the backend:
uvicorn main:app --reloadBackend runs on: http://localhost:8000
cd client/tutor-rag
npm installCreate a .env file in client/tutor-rag:
REACT_APP_API_URL=http://localhost:8000Run the frontend:
npm startFrontend runs on: http://localhost:3000
Run these SQL queries in your Supabase SQL Editor:
-- Users table
CREATE TABLE users (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
username TEXT UNIQUE NOT NULL,
password TEXT NOT NULL,
fullname TEXT,
email TEXT,
role TEXT NOT NULL,
grade TEXT,
college TEXT,
major TEXT
);
-- Text chunks table
CREATE TABLE text (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
chunk_id TEXT NOT NULL,
doc_id TEXT NOT NULL,
text TEXT NOT NULL,
source TEXT,
page INTEGER,
grade INTEGER,
role TEXT
);
-- Chat history table
CREATE TABLE chat_history (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
chat_id TEXT,
username TEXT NOT NULL,
question TEXT NOT NULL,
response TEXT NOT NULL,
sources JSONB,
timestamp TIMESTAMPTZ NOT NULL
);
-- Quiz table
CREATE TABLE quiz (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
username TEXT NOT NULL,
topic TEXT NOT NULL,
quiz_data TEXT NOT NULL,
sources JSONB,
timestamp TIMESTAMPTZ NOT NULL
);
-- Quiz history table
CREATE TABLE quiz_history (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
username TEXT NOT NULL,
quiz_id TEXT,
topic TEXT,
score INTEGER,
total_questions INTEGER,
results JSONB,
quiz_content TEXT,
timestamp TIMESTAMPTZ NOT NULL
);RAG-Based-Teaching-Assistant/
βββ client/
β βββ tutor-rag/ # React frontend
β βββ src/
β β βββ pages/ # Login, Register, Chat, Quiz, History, Upload
β β βββ components/ # Navbar
β β βββ context/ # AuthContext
β β βββ services/ # API calls
β βββ public/
βββ server/ # FastAPI backend
β βββ auth/ # Authentication routes
β βββ chat/ # Chat & quiz routes
β βββ docs/ # Document upload & vectorstore
β βββ config/ # Database config
β βββ main.py # App entry point
βββ README.md
Sumit Pal
- GitHub: @Sumitpal321
This project is open source and available under the MIT License.
Built with β€οΈ using FastAPI, React, LangChain, Pinecone, Supabase, and Groq