Skip to content
 
 

Repository files navigation

DocChat

DocChat is an AI-powered document assistant that solves a common problem: once PDFs are uploaded, finding exact information quickly is hard. This project lets users upload documents and ask natural-language questions, with answers generated from retrieved relevant chunks.

Problem Solved

  • Manual PDF searching is slow and error-prone.
  • Important information is often buried across long documents.
  • Teams need fast Q&A over their own files without rewriting content manually.

DocChat addresses this through a RAG pipeline backed by Pinecone and Gemini-based response generation.

What This Project Includes

  1. Frontend (React + Vite) for upload and chat UI
  2. Backend (FastAPI) with /upload and /chat endpoints
  3. RAG pipeline for ingestion, retrieval, and answer generation

Live Demo

Architecture

User -> React Frontend -> FastAPI Backend -> RAG Pipeline -> Pinecone / Gemini
                       \-> PDF Upload -> Ingestion -> Embeddings

How It Works

Backend API (fastApi/api.py)

  • POST /upload: receives PDFs, stores/processes them via src/ingestion.py
  • POST /chat: receives question, runs retrieval+generation flow from src/graph.py

Frontend (frontend/src/)

  • FileUpload.jsx: handles PDF uploads to backend
  • ChatInterface.jsx: handles user questions and responses
  • App.jsx: overall page layout and orchestration

RAG Pipeline (src/)

  • config.py: environment and model/vector settings
  • ingestion.py: PDF -> text chunks -> embeddings -> Pinecone
  • retrieval.py: similarity retrieval from Pinecone
  • graph.py: LangGraph flow for answer generation

Setup

1) Clone and install backend dependencies

git clone https://github.com/Rahul-Ganesan/DocChat.git
cd DocChat
pip install -r requirements.txt

2) Configure environment

cp .env.example .env

Set required values in .env:

GOOGLE_API_KEY=your_google_api_key_here
PINECONE_API_KEY=your_pinecone_api_key_here
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json

3) Install and run frontend

cd frontend
npm install
npm run dev

Frontend runs on http://localhost:5173.

4) Run backend

From repo root:

uvicorn fastApi.api:app --host 0.0.0.0 --port 8000 --reload

Backend runs on http://localhost:8000.

API Endpoints

  • POST /upload - Upload and process PDF
  • POST /chat - Ask question over indexed document content

Deployment Notes

  • Frontend is suitable for Vercel deployment (frontend as root directory).
  • Backend can run on a VM/container with port 8000 exposed.
  • Set frontend VITE_API_URL to your backend HTTPS URL in production.
  • Ensure backend CORS allows the deployed frontend domain.

Troubleshooting

  • Backend not starting: run from repo root and confirm Python dependencies installed.
  • Frontend not connecting: verify VITE_API_URL and backend URL/port.
  • Upload failing: confirm backend is running and accepts multipart uploads.
  • Chat empty/poor results: verify document was ingested and API keys are valid.

Project Structure

DocChat/
├── fastApi/
│   ├── api.py
│   └── api_vm_update.py
├── frontend/
│   ├── src/
│   │   ├── components/
│   │   │   ├── FileUpload.jsx
│   │   │   └── ChatInterface.jsx
│   │   ├── App.jsx
│   │   └── index.css
│   ├── package.json
│   └── README.md
├── src/
│   ├── config.py
│   ├── ingestion.py
│   ├── retrieval.py
│   └── graph.py
├── .env.example
├── main.py
└── requirements.txt

Future Improvements

  • Add source citations and page references in answers

About

Lost something in your notes? We'll dig through the chaos so you don't have to. (Currently going through a big transformation) release: Jan 28

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages