Skip to content

Latest commit

Β 

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GovVault Banner

πŸ›οΈ GovVault

A local-first RAG (Retrieval-Augmented Generation) assistant for government documents.

Upload dense policy PDFs, government orders, or circulars β€” ask questions in plain English, and get cited, page-accurate answers in seconds. No manual Ctrl+F through 200-page documents.


πŸ“‹ Table of Contents


🎯 Problem Statement

Government offices, legal teams, and policy researchers deal with hundreds of dense, unstructured PDF documents β€” circulars, orders, notifications. Finding a single relevant clause today means manually searching page by page, with no way to verify an answer's source at a glance.

GovVault turns that pile of PDFs into a searchable, conversational knowledge base β€” with every answer traceable back to the exact page it came from.


⚠️ Deployment Note (Read This First)

Only the frontend of this project is publicly deployed.

The backend depends on sentence-transformers, which pulls in a full PyTorch installation. This pushes the deployed image size and RAM footprint well past what free-tier hosting (Render, Railway, etc.) can handle β€” repeated attempts resulted in out-of-memory crashes during deployment. Upgrading to a paid tier to accommodate this wasn't a viable option for this project.

As a result:

  • The live frontend you may find deployed is a UI showcase only β€” it is not connected to a running backend.
  • The full RAG pipeline (PDF upload β†’ local embedding β†’ pgvector search β†’ Groq inference) only runs locally, exactly as described in Getting Started below.
  • A video walkthrough of the complete, working pipeline is embedded on the landing page for anyone who wants to see it in action without setting it up themselves.

To actually run and test the full project β€” backend included β€” you must fork or clone this repository and run it locally using the setup instructions below. There is currently no hosted, end-to-end working version.


✨ Features

  • πŸ“„ PDF Upload & Parsing β€” Text-selectable PDFs are parsed page-by-page using PyMuPDF
  • 🧠 Local Embeddings β€” Documents are vectorized on-device with SentenceTransformers (paraphrase-MiniLM-L3-v2, 384 dimensions) β€” zero embedding API cost
  • πŸ” Vector Search β€” Postgres + pgvector extension for cosine-similarity retrieval, capped at top-5 chunks with a relevance threshold
  • ⚑ Fast Inference β€” Final answer generation via Groq (openai/gpt-oss-20b)
  • πŸ“Œ Page-Level Citations β€” Every answer links back to the exact source page; the in-app PDF viewer jumps there automatically
  • πŸ—‚οΈ Multi-Session Chat β€” Collapsible sidebar with independent chat sessions, each scoped to its own uploaded documents (100% session isolation)
  • βš™οΈ Async Processing β€” PDF vectorization runs as a background Celery task, so large uploads don't block the request thread
  • 🎨 ChatGPT-Style UI β€” React + Tailwind, with react-markdown rendering for formatted AI responses

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   React     │─────▢│   Django + DRF    │─────▢│   PostgreSQL    β”‚
β”‚  (Vite SPA) │◀─────│   REST API        │◀─────│   + pgvector    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚                     β”‚
              β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  Celery     β”‚      β”‚  Groq API       β”‚
              β”‚  + Redis    β”‚      β”‚  (LLM inference) β”‚
              β”‚  (async     β”‚      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚  PDF jobs)  β”‚
              β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”
              β”‚ SentenceTransformers β”‚
              β”‚ (local embeddings)   β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Flow:

  1. User uploads a PDF β†’ Django saves it, kicks off a Celery task, returns immediately
  2. Celery worker extracts text (PyMuPDF) β†’ embeds each page locally β†’ stores vectors in Postgres via pgvector
  3. Frontend polls a status endpoint until processing completes
  4. User asks a question β†’ query is embedded the same way β†’ cosine similarity search retrieves top-5 relevant chunks
  5. Chunks + question are sent to Groq β†’ answer streams back with a link to the source page

πŸ› οΈ Tech Stack

Layer Technology
Frontend React (Vite), Tailwind CSS v4, Axios, React Router, react-markdown
Backend Django, Django REST Framework
Database PostgreSQL + pgvector
Task Queue Celery + Redis
Embeddings SentenceTransformers (paraphrase-MiniLM-L3-v2, 384-dim)
LLM Inference Groq API (openai/gpt-oss-20b)
PDF Parsing PyMuPDF (fitz)
Containerization Docker (Postgres + Redis)

πŸš€ Getting Started

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • Docker & Docker Compose
  • A Groq API key (free tier works)

Backend Setup

cd backend

# Create and activate a virtual environment
python -m venv .venv
.venv\Scripts\activate      # Windows
source .venv/bin/activate   # macOS/Linux

# Install dependencies
pip install -r requirements.txt

# Start Postgres + Redis containers
docker-compose up -d

# Run migrations
python manage.py makemigrations
python manage.py migrate

# Create a .env file (see Environment Variables section below)

Frontend Setup

cd frontend

# Install dependencies
npm install

# Create a .env file
echo "VITE_API_URL=http://127.0.0.1:8000/api" > .env

Running the Full Stack

You'll need three terminals running simultaneously:

# Terminal 1 β€” Docker containers (from backend/)
docker-compose up -d

# Terminal 2 β€” Celery worker (from backend/, with venv active)
celery -A core worker --loglevel=info --pool=solo

# Terminal 3 β€” Django server (from backend/, with venv active)
python manage.py runserver
# Terminal 4 β€” Frontend (from frontend/)
npm run dev

Visit http://localhost:5173.

Note: --pool=solo is required for Celery on Windows. On macOS/Linux you can omit it and use the default prefork pool.


πŸ” Environment Variables

backend/.env

DEBUG=True
DATABASE_URL=postgres://admin:adminpassword@localhost:5432/govvault_db
GROQ_API_KEY=your_groq_api_key_here
CELERY_BROKER_URL=redis://localhost:6379/0

frontend/.env

VITE_API_URL=http://127.0.0.1:8000/api

πŸ“‘ API Endpoints

Method Endpoint Description
POST /api/documents/upload/ Upload a PDF, triggers async vectorization
GET /api/documents/<id>/status/ Poll processing status (pending / processing / completed / failed)
POST /api/chat/ Ask a question, scoped to document_ids

πŸ“ Project Structure

GovVault/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ core/                  # Django project settings, Celery config
β”‚   β”œβ”€β”€ knowledge_base/        # Main app β€” models, views, services, tasks
β”‚   β”‚   β”œβ”€β”€ models.py          # Document, DocumentChunk
β”‚   β”‚   β”œβ”€β”€ views.py           # Upload, Status, Chatbot views
β”‚   β”‚   β”œβ”€β”€ services.py        # PDF parsing + embedding logic
β”‚   β”‚   └── tasks.py           # Celery async task
β”‚   └── docker-compose.yml     # Postgres (pgvector) + Redis
└── frontend/
    └── src/
        β”œβ”€β”€ components/
        β”‚   β”œβ”€β”€ layouts/        # Navbar
        β”‚   β”œβ”€β”€ sections/       # Hero, Features, HowItWorks, TechStack, Footer, VideoShowcase
        β”‚   └── rag-demo/       # RagDemoSection β€” main chat UI
        └── pages/               # LandingPage, ChatPage

⚠️ Known Limitations

  • Scanned/image-based PDFs are not supported β€” PyMuPDF only extracts text from text-selectable PDFs. OCR is not currently implemented.
  • No authentication layer β€” this is a demo/showcase project, not production-hardened.
  • Backend is local-only β€” see the Deployment Note above.

πŸ—ΊοΈ Roadmap

  • OCR support for scanned documents
  • User authentication and per-user document libraries
  • Lighter-weight embedding model to make cloud deployment feasible
  • Streaming LLM responses token-by-token instead of waiting for the full completion

πŸ“„ License

This project was built as a hackathon/showcase project. Feel free to fork, learn from, or build on it.


πŸ™ Acknowledgments