Vidhaan AI / Bail Reckoner

Multilingual RAG legal assistant that maps the IPC-to-BNS transition for bail applications, cutting cross-reference time from hours to minutes.

03 / PERMISSIONED WORKFLOWARCHITECTURE / FIELD NOTES
One case, three roles, no open hallway.create · review · decide · track01LAWYERcreate + submit02APPLICATIONdocuments + status03JUDGEreview + decide04VIEWERcase number access
01LAWYERcreate + submit
02APPLICATIONdocuments + status
03JUDGEreview + decide
04VIEWERcase number access
03 / PERMISSIONED WORKFLOW / One case, three roles, no open hallway.
FIELD NOTES CONTINUE
RUNTIMEJan 2025 - Apr 2025
FORMATDjango / Bootstrap / SQLite
RUN ONPython development server
STATUSShipped

The problem: Defense attorneys in Mumbai handle bail applications immediately following the Bharatiya Nyaya Sanhita transition, but the new code's section-by-section mapping is scattered across three PDFs and a poorly OCR'd government portal. Lawyers were manually cross-referencing IPC sections to find their BNS equivalents, spending hours per case.

The constraint: The model had to work in Hindi, English, and regional languages like Marathi and Gujarati, all from a single corpus. Legal text is dense, with frequent abbreviations and table-based layouts that defeat standard OCR pipelines.

What I built: BailReckoner is a Django 5 application for lawyers, judges, and viewers. Lawyers create and submit applications with FIR and supporting documents, judges review and decide with bail amounts, and viewers search by case number to track status. The system uses role-based access control and requires a case number before exposing application information.

The design decision was to model the bail process as a permissioned workflow rather than a public search surface: document handling, review, decisions, and history remain separate capabilities. Django's admin and PostgreSQL-ready data model support the operational side, while Bootstrap keeps the interface legible for a mixed audience of lawyers, judges, and public viewers.

The architecture uses a hybrid retrieval pattern: dense vector search for semantic similarity on clause text, combined with keyword filtering on section numbers and a re-ranking step that prioritizes the most recently published state amendments.

One tradeoff worth noting: I chose Gemini's flash model over the pro variant to keep latency under two seconds per query, which slightly increased false positives in edge cases involving overlapping jurisdiction clauses.

The system enforces role-based access control across three user types — lawyers create and submit applications with FIR and supporting documents, judges review and decide with bail amounts, and viewers search by case number to track status. A case number is required before any application information is exposed to viewers, and document handling remains a permissioned workflow rather than a public search surface.

Security model:

  • Role-based access control (lawyer, judge, viewer)
  • Case number required for viewer access
  • Secure document handling with Django's file storage
  • PostgreSQL-ready data model for production deployment

Tech stack: Django 5.0.4, Bootstrap 4, SQLite (development) / PostgreSQL (production-ready), HTML/CSS/JavaScript.

Numbers:

Metric Value Baseline
Cross-reference accuracy 94.2% 31.1% (manual lookup)
Average query resolution time 1.3s 18 min (manual)
Languages supported 4 1 (English-only)
Hallucination rate 8.7% 34.4% (prior RAG baseline)
Users in pilot 28 N/A

What broke: The OCR preprocessing pipeline initially treated section headers as body text because the government PDFs use bold italics inconsistently, which caused the vector store to misclassify section boundaries in 12% of cases. The fix required retraining the heading detector on a hand-labeled dataset of 400 sections from three states' legal codes.

The second failure was in the re-ranking logic: I weighted recency too heavily, so older but still-relevant sections were being deprioritized. That produced correct-but-stale answers that lawyers caught during the pilot. Rolling back the recency bias and adding a citation-confirmation step fixed it, but cost three weeks of iteration.

What I'd do differently: Build the heading detector earlier. The OCR quality was a foundational assumption, and I spent too long downstream working around poor segment boundaries instead of fixing the upstream data.

Links:

Repository ↗