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.
- 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
| 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) |
- Python 3.11+
- Node.js 18+
- Either an OpenAI API key with billing/credits or Ollama for free local AI
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 8000API docs: http://localhost:8000/docs
cd frontend
npm install
cp .env.local.example .env.local # optional, defaults to localhost:8000
npm run devIf you hit 429 insufficient_quota or don't want to pay for OpenAI:
- Install Ollama and start it
- Pull the models:
ollama pull llama3.2 ollama pull nomic-embed-text
- In
backend/.env, switch provider:LLM_PROVIDER=ollama OLLAMA_MODEL=llama3.2 OLLAMA_EMBEDDING_MODEL=nomic-embed-text
- Restart the backend and upload again
| 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 |
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.
| 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 |
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
"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."
MIT