The system follows a RAG (Retrieval-Augmented Generation) approach:
- Users upload a PDF document
- The backend extracts and chunks text
- Each chunk is converted into embeddings
- Embeddings are stored in a vector database
- User questions are embedded and matched against stored chunks
- Relevant context is sent to the LLM
- The LLM answers only using retrieved context
This ensures accuracy, traceability, and minimal hallucination.
| Tool | Purpose | Reason |
|---|---|---|
| FastAPI | Backend API | Fast, async, production-ready |
| React (Vite) | Frontend | Lightweight, modern UI |
| ChromaDB | Vector database | Local, persistent, ideal for RAG |
| LangChain | RAG utilities | Clean abstraction for loaders & chunking |
| Sentence Transformers | Embeddings | Efficient semantic representation |
| OpenAI | LLM | High-quality text generation |
Design Decisions:
- Used RAG to prevent hallucinations
- Chose ChromaDB for simplicity and local persistence
- Used environment variables for API key security
- Clean separation between retrieval and generation
- Minimal but elegant frontend for clarity and usability
pdf-qa/
├── backend/
│ ├── main.py
│ ├── rag.py
│ ├── requirements.txt
│ └── .env
│
├── frontend/
│ ├── src/
│ │ ├── App.jsx
│ │ ├── App.css
│ │ └── index.css
│ └── package.json
│
├── screenshots/
│ ├── home.png
│ └── answer.png
│
├── .gitignore
└── README.md
git clone https://github.com/pabitrajana007/pdf-qa.git
cd pdf-qacd backend
python -m venv venv
source venv/Scripts/activate # Windows (Git Bash)- Install dependencies:
pip install -r requirements.txt- Create .env file:
OPENAI_API_KEY=your_openai_api_key_here- Run backend:
python -m uvicorn main:app --reloadcd frontend
npm install
npm run dev
