A Retrieval-Augmented Generation (RAG) chatbot that lets you search and query documents (web pages, PDFs, etc.) using a Natural Language interface — built with FastAPI + LangChain (backend) and React + TypeScript (frontend).
AI_Document_Search_RAG_Chatbot/
│
├── rag_chatbot/ # Backend (FastAPI + LangChain + Chroma)
│ ├── config/ # Configuration & env variables
│ ├── preprocessing/ # Chunking, embeddings, vector store creation
│ ├── utilities/ # Document loaders & retrievers
│ ├── main.py # FastAPI app entrypoint
│ ├── requirements.txt
│ ├── README.md (optional backend-specific)
│
├── rag-chatbot-frontend/ # Frontend (React + TypeScript)
│ ├── src/api/ # API client
│ ├── src/components/ # UI Components (Chat UI)
│ ├── public/
│ ├── package.json
│ ├── tsconfig.json
│ ├── README.md (optional frontend-specific)
│
└── .env.example # Template env file
- Document Loading: Load from URLs or PDF files.
- Preprocessing: Text chunking & token-aware splitting.
- Vector Search: Embed & store in Chroma vector DB.
- LLM Integration: Works with Perplexity.ai API (Sonar model) or OpenAI.
- Frontend UI: Simple chat interface to query your document.
- MLOps Ready: Modular structure,
.envconfig, API-key safety, vector DB persistence.
git clone https://github.com/sagarmandiya/AI_Document_Search_RAG_Chatbot.git
cd "AI_Document_Search_RAG_Chatbot"
- Python 3.10+ and
pip virtualenv(optional but recommended)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
Create a .env in rag_chatbot/:
# Document source to index
DOC_SOURCE_URL=https://lilianweng.github.io/posts/2023-06-23-agent/
# Vector DB location
VECTOR_DB_DIR=./vector_store
# Models
EMBED_MODEL=all-MiniLM-L6-v2
LLM_MODEL=sonar
# LangChain API tracing (optional)
LANGCHAIN_TRACING_V2=true
LANGCHAIN_ENDPOINT=https://api.smith.langchain.com
LANGCHAIN_API_KEY=your-langchain-api-key
# Perplexity API Key
PPLX_API_KEY=your-perplexity-api-key
⚠️ Do NOT commit.envto GitHub — keep it in.gitignore.
uvicorn main:app --reload
Server runs at: http://127.0.0.1:8000
cd ../rag-chatbot-frontend
npm install
Edit src/api/chatbot.ts to point to your backend URL:
const API_BASE_URL = "http://127.0.0.1:8000";
If backend runs locally, you can also add in package.json:
"proxy": "http://127.0.0.1:8000"
npm start
Frontend runs at: http://localhost:3000
Once both frontend and backend are running:
- Open http://localhost:3000 in your browser
- Type:
What is Task Decomposition? - Bot responds with context‑aware answer from the indexed document(s)
- Persistence: Vector DB stored locally in
vector_store/. Deploy to cloud storage for production. - Keys: Store API keys in environment variables — never commit to GitHub.
- Monitoring: Integrate logging / tracing via LangChain's tracing API.
- Scaling: Deploy backend to services like Render, AWS Lambda, Azure Functions and frontend to Netlify/Vercel.
- Testing: Add
pytestfor backend and React Testing Library/Jest for frontend.
langchain
langchain-community
langchain-core
bs4
pypdf
sentence-transformers
chromadb
fastapi
uvicorn
python-dotenv
"dependencies": {
"axios": "^latest",
"react": "^18.x",
"react-dom": "^18.x",
"typescript": "^5.x",
"@types/react": "^18.x",
"@types/react-dom": "^18.x"
}
This project is licensed under the MIT License — see the LICENSE file for details.