DEV Community

Utkarsh Mandilwar
Utkarsh Mandilwar

Posted on

StudyBuddy Local: Your Private AI Study Partner. Your Notes Stay Yours.

Hacktoberfest Weekend Challenge: Build for a Friend Submission 🤝

Built for a friend studying for exams

StudyBuddy Local is a private study partner I built for a friend preparing for university exams. It turns their own lecture notes into grounded study chat, practice quizzes, and revision summaries without sending their documents to a cloud AI service.

Demo video: https://drive.google.com/file/d/1wsB4fANFHZcqfXb8IdpfdVV80fLq5LMT/view

Code: https://github.com/utmandilwar/studybuddy-local

What it does

  • Extracts text and page metadata from PDFs and text files, then splits it into overlapping, sentence-aware chunks.
  • Creates embeddings on-device and stores them in a local ChromaDB collection.
  • Retrieves passages from the student's notes to ground chat answers and display source citations.
  • Generates validated multiple-choice quizzes, summaries, and revision notes using a local Ollama model (Qwen2.5 3B by default).
  • Keeps the interface bound to localhost, disables Streamlit usage statistics, and has no cloud fallback. Uploaded documents and the vector database are excluded from Git.

Why local and open matters

Course notes can contain personal annotations, unpublished assignments, or other material students do not want to upload. Running the embedding and language models locally gives the student control over where those files are processed, avoids per-request API fees, and makes an offline study workflow possible after the models have been downloaded. The models can also be swapped for compatible local alternatives.

The pipeline is intentionally straightforward:

PDF / TXT -> extraction and chunking -> local embeddings -> ChromaDB
                                               |                  |
Student question -> retrieval of relevant notes -----------------+
                                               |
                                               v
                                 Ollama + local Qwen model
                                               |
                                               v
                            grounded answer with source citations
Enter fullscreen mode Exit fullscreen mode

No partner prize category is claimed: the project does not currently use a challenge sponsor's technology.

What I learned (and what still needs work)

Keeping data local is only part of making a trustworthy study tool: answers should remain tied to retrieved passages, and students need visible citations so they can check them. The app includes retrieval, prompt-injection handling for uploaded material, and tests for the main document, retrieval, chat, and quiz flows.

There are honest limits. Scanned PDFs need OCR, small local models can misread complex tables, and the default model and embedding weights must be downloaded before offline use. Community discussion of local RAG also surfaced an important reliability trap: a successful ingestion log does not prove vectors were persisted where retrieval will read them. Explicit read-after-write verification of the actual collection is a worthwhile next hardening step.

Related experiences: Building a Privacy-First AI Companion with Next.js, FastAPI and Ollama explores the local-model trade-off; I Built a Local RAG Assistant with Ollama, ChromaDB and LangChain. Here's What I Learned and its discussion emphasize checking persisted data rather than trusting a successful write log.

How this was built

StudyBuddy Local uses a local retrieval-augmented generation (RAG) pipeline so course material stays on the student's device:

  1. Load and chunk: PyMuPDF extracts PDF text and page metadata (plain-text files are also supported). The chunker splits content along sentence-aware boundaries and keeps overlap to preserve context.
  2. Embed and index locally: Sentence Transformers creates embeddings on-device, and ChromaDB persists them in a local collection.
  3. Retrieve evidence: A student's question is matched against the indexed chunks; the most relevant passages and their document/page metadata are used as context for the answer.
  4. Generate locally: The retrieved context is sent to Ollama running Qwen2.5 3B by default. The app presents the response with source citations rather than sending notes to a hosted AI API.
  5. Support revision: The same local model powers summaries and structured multiple-choice quizzes; Pydantic validates quiz output, and pytest covers document processing, retrieval, chat, and quiz behavior.

Streamlit serves the interface on 127.0.0.1, telemetry is disabled, and there is no cloud fallback. Model weights need to be downloaded before going offline; after setup, the study workflow can run locally.

PDF / TXT -> PyMuPDF -> sentence-aware chunks -> local embeddings -> ChromaDB
                                                               |
Question -> retrieve relevant chunks --------------------------+
                   |
                   v
          Ollama + Qwen2.5 3B -> grounded answer with citations
Enter fullscreen mode Exit fullscreen mode

Top comments (0)