Skip to content

satvikmishra44/PanScienceRAG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ PanScience Context-Aware RAG AI

License: MIT Python 3.12 FastAPI React Docker

A production-ready, full-stack Retrieval-Augmented Generation (RAG) system with context-aware conversations. Upload documents (PDF/DOCX/TXT) and chat with an AI that remembers your conversation history.

๐Ÿ“‹ Table of Contents

โœจ Features

  • ๐Ÿ“„ Multi-Format Support: PDF, DOCX, TXT, MD files
  • ๐Ÿง  Context-Aware AI: Remembers last 6 conversation exchanges
  • ๐Ÿ” Vector Search: ChromaDB-powered semantic retrieval
  • ๐ŸŽฏ Intelligent Chunking: 1500-char chunks with 200-char overlap
  • ๐Ÿ“Š Document Management: Track indexed documents
  • ๐Ÿ”’ Production Ready: Health checks, rate limiting, error handling
  • ๐Ÿณ Fully Dockerized: One-command deployment
  • ๐ŸŒ Cloud Ready: AWS/GCP/Azure deployment configurations

๐Ÿ—๏ธ Architecture

         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚        Frontend          โ”‚
         โ”‚  React + Tailwind (Vite) โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚
                       โ–ผ
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚        FastAPI API       โ”‚
         โ”‚  (Document & Chat APIs)  โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ–ผ              โ–ผ              โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  MongoDB     โ”‚  โ”‚  ChromaDB     โ”‚  โ”‚  Gemini/OpenAIโ”‚
โ”‚  (metadata)  โ”‚  โ”‚  (embeddings) โ”‚  โ”‚  (generation) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Quick Start In Just 2 Steps

Prerequisites

  • Docker & Docker Compose (recommended)
  • OR Python 3.12+ & Node.js 20+
  • Google Gemini API Key (Get one here)

1๏ธโƒฃ Clone Repository

git clone https://github.com/satvikmishra44/PanScienceRAG.git
cd PanScienceRAG

2๏ธโƒฃ Build & Start Containers

docker-compose up --build

This launches:

Service Description URL
๐Ÿง  Backend (FastAPI) Core API http://localhost:8000
๐Ÿ’ฌ Frontend (React) UI Dashboard http://localhost:5173

Just Go To Frontend localhost port by clicking here (after running the docker command) and use the application yourself. As Simple As That

3๏ธโƒฃ Stop Containers

docker-compose down

4๏ธโƒฃ Verify Setup

Check API health:

curl http://localhost:8000/ping

Expected response:

{"status": "ok", "service": "RAG-pipeline"}

๐Ÿ”— API Usage Guide

๐Ÿงฉ Base URL

http://localhost:8000

๐Ÿ“„ 1. Upload Document

Endpoint: /ingest
Method: POST

๐Ÿ“ Description

Uploads and indexes a document for retrieval and querying.

๐Ÿ’ก Example (cURL)

curl -X POST "http://localhost:8000/ingest" \
  -F "file=@research_paper.pdf"

โœ… Response

{
  "status": "success",
  "doc_id": "66e432f78df123abc",
  "chunks": 98
}

๐Ÿ” 2. Query Documents

Endpoint: /query
Method: POST

๐Ÿ“ Description

Ask questions based on the indexed documents.
Supports chat history for contextual and conversational responses.

๐Ÿ’ก Example (JSON Body)

{
  "query": "What are the applications of quantum entanglement?",
  "top_k": 4,
  "history": [
    {"role": "user", "text": "Tell me about quantum mechanics"},
    {"role": "ai", "text": "Quantum mechanics studies the behavior of matter and energy..."}
  ]
}

โœ… Response

{
  "status": "success",
  "answer": "Quantum entanglement enables applications in quantum computing, teleportation, and cryptography...",
  "sources": [
    {
      "text": "Quantum entanglement is a phenomenon...",
      "meta": {"source_filename": "quantum_intro.pdf"},
      "distance": 0.12
    }
  ]
}

๐Ÿ“š 3. Get Document List

Endpoint: /documents
Method: GET

๐Ÿ’ก Example

curl http://localhost:8000/documents

โค๏ธ 4. Health Check

Endpoint: /ping
Method: GET

๐Ÿ’ก Example

curl http://localhost:8000/ping

โœ… Response

{"status": "ok", "service": "RAG-pipeline"}

Project Structure

PanScience/ โ”‚ โ”œโ”€โ”€ backend/ โ”‚ โ”œโ”€โ”€ app/ โ”‚ โ”‚ โ”œโ”€โ”€ main.py # FastAPI entry point โ”‚ โ”‚ โ”œโ”€โ”€ db.py # Database + LLM initialization โ”‚ โ”‚ โ”œโ”€โ”€ rag.py # RAG ingestion and query logic โ”‚ โ”‚ โ”œโ”€โ”€ utils.py # File handling and text chunking โ”‚ โ”œโ”€โ”€ requirements.txt โ”‚ โ”œโ”€โ”€ Dockerfile โ”‚ โ”œโ”€โ”€ frontend/ โ”‚ โ”œโ”€โ”€ src/ โ”‚ โ”‚ โ”œโ”€โ”€ components/ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Chat.jsx โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ DocManager.jsx โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Landing.jsx โ”‚ โ”œโ”€โ”€ package.json โ”‚ โ”œโ”€โ”€ Dockerfile โ”‚ โ”œโ”€โ”€ docker-compose.yaml โ””โ”€โ”€ README.md

๐Ÿณ Running with Docker

1๏ธโƒฃ Build & Start Containers

docker-compose up --build

This launches:

Service Description URL
๐Ÿง  Backend (FastAPI) Core API http://localhost:8000
๐Ÿ’ฌ Frontend (React) UI Dashboard http://localhost:5173

2๏ธโƒฃ Stop Containers

docker-compose down

๐Ÿงฐ Tech Stack

Layer Technology
๐Ÿ–ฅ๏ธ Frontend React (Vite), TailwindCSS
โš™๏ธ Backend FastAPI, Python
๐Ÿ—ƒ๏ธ Database MongoDB
๐Ÿงฎ Vector Store ChromaDB
๐Ÿง  LLM Gemini / OpenAI / Claude
๐Ÿณ Containerization Docker, Docker Compose

๐Ÿงพ Notes

  • Ensure MongoDB and ChromaDB services are running before ingesting documents.
  • Large PDFs are automatically chunked for efficient retrieval.

About

PanScience AI -- A Context-Aware RAG framework built with FastAPI, React, Mongo and ChromaDB, powered by Gemini and LangChain. Upload research papers, notes, or documents and let the AI answer your questions using real context and semantic memory. Fully containerized with Docker Compose, and easily extensible to OpenAI, or local LLMs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors