Skip to content

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

title Docwise API
emoji 📄
colorFrom blue
colorTo green
sdk docker
app_port 7860
pinned false
DocWise

DocWise — Multi-Document RAG SaaS

Upload your documents. Ask anything. Get answers with sources.

Live Demo API Docs Python FastAPI PostgreSQL HuggingFace


What it does

DocWise lets you upload PDF documents and have a conversation with them using AI. Ask questions across multiple documents at once, compare them side by side, or search semantically across your entire library. Every answer cites its source document.


Features

📄 Multi-document upload

Upload multiple PDFs. Each one is chunked, embedded, and indexed into a per-user vector store. Document records persist across sessions via PostgreSQL.

💬 Conversational RAG with memory

Chat with your documents with full conversation memory. Follow-up questions work correctly — "explain that more" and "what did you mean by X" understand context from previous turns.

🔍 Semantic cross-document search

Search for a concept across your entire document library. Results ranked by similarity score with source attribution.

📊 Document comparison

Ask the same question across two or more documents simultaneously. Useful for comparing contracts, research papers, or policy documents.

📍 Source citations

Every answer includes which document it came from. No silent hallucination.

⚡ Async ingestion pipeline

Upload returns immediately. PDF processing runs as a background task. Poll the status endpoint to check when your document is ready to query.


Architecture

┌──────────────────────────────────────────────────────┐

│ Streamlit Frontend │

│ Upload · Chat · Search · Compare │

└───────────────────────┬──────────────────────────────┘

│ HTTP

┌───────────────────────▼──────────────────────────────┐

│ FastAPI Backend — HuggingFace Spaces │

│ Upload · Ingest · Chat · Search · Compare │

└──────────┬────────────────────────────┬──────────────┘

│ │

┌──────────▼──────────┐ ┌───────────---▼---─────────────┐

│ PostgreSQL │ │ RAG Layer │

│ Neon (cloud) │ │ LangChain + ChromaDB │

│ Document records │ │ Google Gemini 3.1 Flash Lite │

│ Upload status │ │ HuggingFace Embeddings │

└─────────────────────┘ └──────────────-----────────────┘

Ingestion workflow:

  1. User uploads PDF via Streamlit
  2. FastAPI saves file and creates DB record with status processing
  3. Background task chunks PDF → generates embeddings → stores in ChromaDB
  4. DB record updated to ready
  5. User polls status endpoint, then starts chatting

Tech stack

Layer Technology
Frontend Streamlit
Backend FastAPI
Database PostgreSQL (Neon)
ORM SQLAlchemy
AI model Google Gemini 3.1 Flash Lite
RAG framework LangChain
Vector store ChromaDB
Embeddings HuggingFace sentence-transformers
Backend deploy HuggingFace Spaces (Docker)
Frontend deploy Streamlit Cloud

API reference

GET /health

Health check.

{ "app": "DocWise", "status": "running", "version": "1.0.0" }

POST /documents/upload

Upload a PDF document and start asynchronous ingestion.

Query Parameters

Parameter Type Required Description
user_id string Yes Unique identifier for the user uploading the document

Request Body

multipart/form-data

Field Type Required Description
file PDF File Yes Document to upload and index

Response

{
  "doc_id": "a1b2c3d4",
  "status": "processing"
}

DELETE /chat/{session_id}

Clear conversation memory for a session.


Getting started locally

Prerequisites: Python 3.11+, Neon account from neon.tech

git clone https://github.com/subata24/Docwise
cd Docwise
python -m venv venv
source venv/bin/activate      # Windows: venv\Scripts\activate
pip install -r requirements.txt

Create .env in the root:

GOOGLE_API_KEY
GOOGLE_MODEL
DATABASE_URL=postgresql://user:pass@localhost/docwise
CHROMA_PERSIST_DIR=./chroma_db
UPLOAD_DIR=./uploads

Run backend:

uvicorn backend.main:app --reload --port 7860
# API docs at http://localhost:7860/docs

Run frontend:

streamlit run frontend/app.py

Project structure

Docwise/

├── backend/

│ ├── main.py # FastAPI routes

│ ├── ingest.py # PDF chunking + ChromaDB indexing

│ ├── rag.py # LangChain RAG + conversation memory

│ ├── models.py # SQLAlchemy database models

│ ├── database.py # DB connection setup

│ └── schemas.py # Pydantic request/response shapes

├── frontend/

│ └── app.py # Streamlit UI

├── Dockerfile

├── docker-compose.yml

├── requirements.txt


Engineering highlights

  • Per-user ChromaDB collections — users only retrieve from their own documents
  • MMR retrieval (Maximal Marginal Relevance) returns diverse chunks, not repetitive ones
  • ConversationBufferWindowMemory keeps last 6 turns — follow-up questions work correctly
  • Async background ingestion — no request timeouts on large PDFs
  • Document status tracking in PostgreSQL — client polls until ready
  • Source attribution on every answer
  • Dockerized and deployed on HuggingFace Spaces free tier — no credit card required


Author

Subata Khan — AI Engineer & LLM Systems Developer

LinkedIn GitHub


Built to make document intelligence accessible — one PDF at a time.

About

Production-ready multi-document RAG SaaS for chatting with PDFs, built with FastAPI, LangChain, ChromaDB, PostgreSQL, Docker, and Google Gemini.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages