A production‑grade Retrieval‑Augmented Generation (RAG) system built for searching, summarizing, and understanding Indian court judgments using AI — now enhanced with local LLM inference using Ollama.
- 🔍 Intelligent legal search with natural language queries
- 📜 Summaries grounded in citations from court judgments
- 🧠 Hybrid LLM support — OpenAI + Ollama
- OpenAI for cloud inference
- Ollama for privacy‑preserving local inference
- 📄 OCR‑based PDF ingestion (supports scanned documents)
- 🔗 Vector + Hybrid Search using Milvus + optional BM25
- 🎨 Modern React UI — Chat assistant with PDF Upload
React UI → Spring Boot API
↓
OCR + Text Extraction (Tika + Tess4J)
↓
Chunking + Embedding Generation (OpenAI)
↓
Vector Search (Milvus) + BM25 (optional)
↓
LLM Answer Generation (OpenAI / Ollama) + Citations
| Mode | Engine | Use Case |
|---|---|---|
| Cloud | OpenAI GPT models | Best general legal reasoning |
| Local | Ollama (Llama3) | Offline inference / full data privacy |
Ollama allows completely local RAG search for users who want to analyze sensitive legal data without sending it to cloud LLMs.
legalrag/
│
├── backend/ (Spring Boot)
│ ├── ingestion/ # OCR + PDF extraction
│ ├── embeddings/ # OpenAI embeddings
│ ├── vectordb/ # Milvus adapter
│ ├── retrieval/ # RAG pipeline
│ ├── llm/ # OpenAI + Ollama providers
│ └── controller/ # REST API
│
└── frontend/ (React + Vite)
├── components/
├── api.js
├── App.jsx
└── index.css
| Component | Technology |
|---|---|
| Backend | Spring Boot |
| Frontend | React + Vite + Tailwind |
| Vector DB | Milvus |
| Embeddings | OpenAI |
| Local LLM | Ollama (Llama3) |
| OCR | Apache Tika + Tess4J |
| Database | PostgreSQL |
| Deployment | Docker & Docker Compose |
docker-compose up -dcd backend
mvn spring-boot:runcd frontend
npm install
npm run devInstall Ollama → https://ollama.com/download
Then pull a model:
ollama pull llama3Upload sample judgment:
Puttaswamy vs Union of India (Right to Privacy)
https://main.sci.gov.in/supremecourt/2012/35071/35071_2012_Judgement_24-Aug-2017.pdf
Ask:
What did the Supreme Court say about the right to privacy?
Summarize the judgment.
Which constitutional articles were discussed?
| Value | Implementation |
|---|---|
| Real Legal AI Use‑Case | Judgement search + summarization |
| End‑to‑End RAG | Ingestion → Chunking → Search → LLM |
| Full‑stack Engineering | Spring + React + Milvus |
| AI Deployment | Hybrid LLM: Cloud + Local Ollama |
| Scalability | Modular architecture for future courts / laws |
This project is ideal for AI Engineering, Backend Engineering, LegalTech and LLM‑based product roles.
MIT License
