Skip to content

Sumitpal321/RAG-Based-Teaching-Assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ“ AI Guru β€” RAG-Based AI Teaching Assistant

AI Guru Banner FastAPI React Pinecone Supabase

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 Demo

πŸ”— Live App: RAG-Based Teaching Assistant

πŸ“Ή Video Demo: (Add your screen recording link here β€” Loom, YouTube, etc.)


πŸ“Œ Project Summary

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.


πŸ› οΈ Tech Stack

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

✨ Features

πŸ‘©β€πŸ« Teacher Features

  • πŸ“€ 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

πŸ§‘β€πŸŽ“ Student Features

  • πŸ’¬ 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

πŸ” General Features

  • Role-based access (Student / Teacher)
  • Secure password hashing with Bcrypt
  • Persistent chat and quiz history in Supabase
  • Responsive, colorful educational UI

πŸ” The Process

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

πŸ“– What I Learned

  • 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

πŸš€ How It Can Be Improved

  • πŸ”‘ 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

πŸƒ How to Run the Project Locally

Prerequisites

  • Python 3.12+
  • Node.js 18+
  • Accounts on: Supabase, Pinecone, Google AI Studio, Groq

1. Clone the Repository

git clone https://github.com/Sumitpal321/RAG-Based-Teaching-Assistant.git
cd RAG-Based-Teaching-Assistant

2. Backend Setup

cd server
pip install -r requirements.txt

Create 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_key

Run the backend:

uvicorn main:app --reload

Backend runs on: http://localhost:8000

3. Frontend Setup

cd client/tutor-rag
npm install

Create a .env file in client/tutor-rag:

REACT_APP_API_URL=http://localhost:8000

Run the frontend:

npm start

Frontend runs on: http://localhost:3000

4. Database Setup (Supabase)

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
);

πŸ“ Project Structure

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

πŸ‘¨β€πŸ’» Author

Sumit Pal


πŸ“„ License

This project is open source and available under the MIT License.


Built with ❀️ using FastAPI, React, LangChain, Pinecone, Supabase, and Groq

About

πŸŽ“ AI-powered RAG Teaching Assistant with chat, quiz generation, and document upload. Built with FastAPI, React, Pinecone, Supabase, and Groq LLM.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors