DocQuiz generates quizzes directly from uploaded PDF documents.
It combines:
- Retrieval-Augmented Generation (RAG) for document-grounded context
- Local vector search with Chroma
- Local LLM inference with Ollama (
llama3) - A Flask API backend and Next.js frontend
Teachers and students often have long study material (slides, notes, books) but limited time to create practice questions manually.
DocQuiz solves this by:
- ingesting a PDF,
- indexing it as embeddings,
- retrieving relevant chunks for a query/topic,
- generating structured quiz questions in JSON format.
Supported quiz types:
- Open-ended
- Multiple-choice (MCQs)
- True/False
-
Upload PDF
- Endpoint:
POST /upload-pdf - File is stored in
uploads/ - PDF text is loaded and chunked
- Chunks are embedded with
BAAI/bge-small-en - Stored in Chroma under a unique
doc_idcollection
- Endpoint:
-
Retrieve Context
- For quiz requests (
/open-ended,/mcqs,/true-false), backend runs similarity search on thatdoc_idcollection. - Top chunks are joined as context.
- For quiz requests (
-
Generate Quiz
- Backend builds a strict JSON prompt.
- Calls Ollama (
llama3) with context + user query. - Parses model output into valid JSON response.
-
Render in UI
- Frontend (
quiz-generator/) uploads PDF, storesdoc_id, requests quiz questions, and renders quiz flow + results.
- Frontend (
| Path | Purpose |
|---|---|
server.py |
Flask backend API, retrieval, prompt construction, quiz generation |
vectorization.py |
Optional one-time script to pre-index sample PDFs from data/ |
quiz-generator/ |
Next.js frontend (App Router) |
database/ |
Local Chroma storage (gitignored runtime data) |
uploads/ |
Uploaded PDFs (gitignored runtime data) |
data/ |
Sample local PDFs for experimentation |
- Python + Flask
- LangChain + Chroma
- HuggingFace BGE embeddings (
BAAI/bge-small-en) - Ollama (
llama3) - Next.js 15 + React + Tailwind CSS
- Python 3.11+ (3.13 also works in this setup)
- Node.js 18+
- Ollama installed and running locally
- Ollama model pulled:
ollama pull llama3git clone https://github.com/Raditya0902/rag-project.git
cd rag-project
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txtpython server.pyBackend runs at: http://127.0.0.1:5000
Open a second terminal:
cd quiz-generator
npm install
npm run devFrontend runs at: http://localhost:3000
- Open
http://localhost:3000 - Upload a PDF
- Choose quiz type and number of questions
- Start quiz
curl -s -F "file=@/absolute/path/to/your.pdf" http://127.0.0.1:5000/upload-pdfImportant: @ must be present in curl form upload.
curl -s -X POST http://127.0.0.1:5000/mcqs \
-H "Content-Type: application/json" \
-d '{"query":"neural networks","qs":3,"doc_id":"<DOC_ID_FROM_UPLOAD>"}'python vectorization.pyThis indexes files from data/ into default Chroma storage.
Primary flow remains: upload with /upload-pdf and use returned doc_id.
database/anduploads/are runtime artifacts and should not be committed.quiz-generator/.nextandquiz-generator/node_modulesare build/dependency outputs and are gitignored.- Use only PDFs you are authorized to use/distribute.