Skip to content

About

AI study assistant that answers questions from your lecture notes only. Built with RAG — Next.js, FastAPI, LangChain, FAISS. Supports OpenAI or free local Ollama.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Study Buddy — AI-Powered Study Assistant (RAG)

Upload lecture notes → ask questions → get answers from your notes only.

Built to demonstrate Retrieval-Augmented Generation (RAG) done properly: grounded answers, not hallucination chatbots.

Features

  • Upload notes — PDF, DOCX, TXT, or Markdown
  • Ask questions — answers cite relevant passages from your material
  • Source transparency — expandable snippets show where answers came from

Stack

Layer Tech
Frontend Next.js 15, React, Tailwind CSS
Backend Python, FastAPI
RAG LangChain
Vector DB FAISS (local, persistent)
LLM / Embeddings OpenAI (gpt-4o-mini, text-embedding-3-small)

Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • Either an OpenAI API key with billing/credits or Ollama for free local AI

1. Backend

cd backend
python -m venv venv
source venv/bin/activate   # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
# Put your real key in .env (NOT .env.example):
#   OPENAI_API_KEY=sk-...

uvicorn app.main:app --reload --port 8000

API docs: http://localhost:8000/docs

2. Frontend

cd frontend
npm install
cp .env.local.example .env.local   # optional, defaults to localhost:8000
npm run dev

Open http://localhost:3000

Using Ollama (free, no OpenAI billing)

If you hit 429 insufficient_quota or don't want to pay for OpenAI:

  1. Install Ollama and start it
  2. Pull the models:
    ollama pull llama3.2
    ollama pull nomic-embed-text
  3. In backend/.env, switch provider:
    LLM_PROVIDER=ollama
    OLLAMA_MODEL=llama3.2
    OLLAMA_EMBEDDING_MODEL=nomic-embed-text
  4. Restart the backend and upload again

Troubleshooting

Error Cause Fix
429 insufficient_quota OpenAI key works but account has no credits Add billing at platform.openai.com or switch to Ollama
OpenAI API key not configured Key missing or in wrong file Put key in backend/.env, not .env.example
Connection refused :11434 Ollama not running Start Ollama app, pull models listed above

How RAG Works

Upload notes → Split into chunks → Embed → Store in FAISS
                                              ↓
User question → Embed query → Similarity search → Top-k chunks
                                              ↓
                              LLM + retrieved context → Grounded answer

The LLM is instructed to answer only from retrieved context. If the answer isn't in your notes, it says so.

API Endpoints

Method Path Description
GET /health Health check + LLM config status
POST /upload Upload and index a document
POST /query Ask a question (requires session_id)
POST /summarize Generate 5 exam-revision bullet points
GET /sessions List indexed sessions
DELETE /sessions/{id} Remove a session

Project Structure

Study_buddy/
├── backend/
│   ├── app/
│   │   ├── main.py              # FastAPI routes
│   │   ├── config.py            # Settings
│   │   ├── models/schemas.py    # Pydantic models
│   │   └── services/
│   │       ├── rag_service.py   # LangChain + FAISS pipeline
│   │       └── document_parser.py
│   └── requirements.txt
├── frontend/
│   ├── app/                     # Next.js App Router
│   ├── components/              # Upload, Chat, Summary UI
│   └── lib/api.ts               # Backend client
└── README.md

Demo Story (for presentations)

"I uploaded my Biology 101 lecture on cell division. I asked 'What happens during metaphase?' — Study Buddy answered using only my professor's slides, and showed me the exact passage it used. One click gave me 5 bullet points for exam revision."

License

MIT

About

AI study assistant that answers questions from your lecture notes only. Built with RAG — Next.js, FastAPI, LangChain, FAISS. Supports OpenAI or free local Ollama.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages