The AI-Powered Legal Helper is an advanced Retrieval-Augmented Generation (RAG) framework designed to provide precise, context-aware answers to complex legal queries. By synthesizing information from vast legal databases—including the Indian Penal Code (IPC) and the new Bhartiya Nyaya Sanhita (BNS)—the system empowers legal professionals with rapid research capabilities and assists citizens in navigating the complexities of the Indian justice system.
Submit queries in both English and Hindi. The system retrieves corresponding sections from the BNS and IPC with cross-linguistic accuracy, ensuring accessibility for a broader population.
Side-by-side comparison of old IPC sections and their updated BNS counterparts. The system understands the specific mapping between the old and new laws.
Utilizes a sophisticated retrieval system that:
- Searches multiple legal collections simultaneously (IPC, BNS, Mapping).
- Ranks results by semantic relevance.
- Generates context-aware answers.
Every statement generated by the AI is grounded in retrieved legal documents, reducing hallucinations and ensuring verifiability.
The system utilizes a state-of-the-art RAG Pipeline:
- Ingestion & Parsing: Custom PDF parsers extract structured data (sections, chapters) from official gazettes and raw text files. We handle complex formatting and Hindi OCR.
- Vector Store (ChromaDB): Legal text is converted into high-dimensional vector embeddings and stored in dedicated collections (
ipc,bns,mapping). - FastAPI Backend: An async, high-performance API routes queries to the vector store.
- Retrieval: The system searches across collections to find relevant laws and their old/new equivalents.
- Generation: The context is assembled and presented to the user (LLM integration ready).
- Backend: Python, FastAPI, Uvicorn
- Vector Database: ChromaDB (Persistent Local Storage)
- Embedding Model:
sentence-transformers/all-MiniLM-L6-v2 - Data Processing:
pdfplumber,PyMuPDF,EasyOCR(for Hindi) - Frontend: React.js + Vite + Tailwind CSS (Glassmorphism UI)
- Package Manager:
uv(Fast Python package installer)
This project consists of a FastAPI backend (Python) and a React frontend.
- Python 3.10+
- Node.js & npm
- uv (Recommended for fast Python setup)
The backend serves the RAG API and runs on port 5000.
-
Install Dependencies:
uv pip install -r backend/requirements.txt
(Or using standard pip:
pip install -r backend/requirements.txt) -
Run the Server:
uv run python backend/main.py
The server will start at
http://127.0.0.1:5000.- Swagger Documentation:
http://127.0.0.1:5000/docs
- Swagger Documentation:
-
(Optional) Re-Ingest Data: If you need to rebuild the database:
uv run python scripts/ingest_data.py --ipc --bns uv run python scripts/ingest_mapping.py
The frontend is the user interface and runs on port 5173.
- Navigate to the frontend directory:
cd frontend - Install dependencies:
npm install
- Run the development server:
Access the app at
npm run dev
http://localhost:5173.
- Ensure Backend is running.
- Open Frontend in browser.
- Navigate to the Chat page.
- Ask questions like:
- "What is Section 302?"
- "What is the punishment for mob lynching?"
- "Compare IPC vs BNS for theft."
This project is developed for the CSI-Tech Hackathon. All rights reserved.
Disclaimer: This tool is intended for informational and educational purposes only. It does not constitute legal advice.