Inspiration

At the end of 2024, India's prisons held 511,542 people. Of these, 371,440, about 72.6%, were undertrials (NCRB data, as reported here). Not all of them qualify for release, but the law sets clear limits on how long many can be held while they wait.

Section 479 of the Bharatiya Nagarik Suraksha Sanhita, 2023 (BNSS) provides for release once an undertrial has been detained for up to half of the offence's maximum term. For a first-time offender, someone never convicted before, the mark is one-third. Exclusions and conditions apply.

Part of this test is arithmetic. The hard part is bringing together the facts behind it: arrest dates, charged sections, past convictions and other pending cases. We built JuriSync to help District Legal Services Authority (DLSA) lawyers find who may be eligible, see why, and act on it.

Our guiding principle: AI can read and draft, but it never decides eligibility.

How we built it

JuriSync is a full-stack Next.js 16 and TypeScript application using PostgreSQL on Supabase with Prisma. It uses an NVIDIA NIM model (nemotron-3-nano-30b-a3b) for extraction and drafting, Zod for validation, Resend for email, Vercel Cron for scheduled jobs and Vitest for testing.

1. Grounded document reading

The AI extracts five fields from a charge sheet: arrest date, charged sections, prior convictions, other pending cases and bail order. Each fact needs a supporting sentence from the document. We discard facts with missing quotes or truncated sentences, and facts whose source sentence contains hedging.

Every document is read twice in parallel. Matching facts get a confidence of 0.9. Facts that differ, or appear in only one pass, get 0.4 and go to human review.

2. A deterministic eligibility engine

The engine has no database or AI dependency. It checks exclusions first, including death or life-imprisonment offences, juveniles and confirmed multiple pending cases. Cases under special Acts such as NDPS or UAPA are flagged for stricter scrutiny. Unresolved questions go to a person.

For the set of charged sections \(S\), the governing section is the one with the highest maximum sentence \(M(s)\):

$$ s^{\ast} = \arg\max_{s \in S} M(s) $$

The custody threshold in days is:

$$ T = f \cdot M(s^{\ast}) $$

Here, \(f = 1/3\) for a first-time offender and \(f = 1/2\) otherwise. With \(D\) days spent in custody, a case that clears the exclusion checks is classified as:

  • Tier 1: \(D \ge M(s^{\ast})\), the full maximum sentence has been served
  • Tier 2: \(T \le D \lt M(s^{\ast})\), the threshold has been crossed
  • Not yet eligible: \(D \lt T\)

Tier 1 cases always rank first. Within each tier, the most overdue come first.

A second track catches people who have been granted bail but remain in custody, often because they cannot furnish surety. On day \(d\), with bail granted on day \(b\), it flags a person still in custody when:

$$ d - b \ge 7 $$

3. From worklist to action

AI drafts a release or surety-modification application using the facts computed for the case. A lawyer reviews it and files it outside JuriSync. A daily sweep flags stalled cases: 30 days without movement after identification, 60 after filing, or 7 after bail is granted.

To help find other cases involving the same person, we compare names using Jaro-Winkler similarity along with age proximity. For names \(a\) and \(b\), with \(m \gt 0\) matching characters and \(t\) transpositions (half the number of matched characters that are out of order):

$$ J = \frac{1}{3}\left(\frac{m}{|a|} + \frac{m}{|b|} + \frac{m-t}{m}\right) $$

$$ JW = J + \ell p (1 - J) $$

Here, \(\ell\) is the length of the shared prefix (up to 4) and \(p\) is its weight. If \(m = 0\), then \(J = 0\). A match is only a suggestion; a human must confirm it.

4. Protecting sensitive data

Extracted values and source sentences are encrypted with AES-256-GCM. Access is limited by role and district, with statewide access for State Admins. Login requires a password and OTP, and case views are recorded in an audit log, along with other sensitive actions.

Challenges we faced

A confident answer from an uncertain sentence. Consider: "No conviction on record; however, verification is still awaited." A model may still return a firm true or false. Checking that the quote exists is not enough, so we added checks for truncated sentences and hedging words.

Turning law into code. A date calculation alone can give a misleading result. We had to put exclusions before eligibility math and treat uncertainty as its own outcome.

One person, different records. Name spellings can vary across FIRs, and there may be no shared person ID. Similar names can also belong to different people, which is why we never confirm matches automatically.

Incomplete court data. The court metadata we support has no prior-conviction field. These cases go to review unless a clearly labelled synthetic value is explicitly requested. For historical data, we count custody only up to the dataset's snapshot date.

Balancing privacy and accountability. For cases released more than three years ago, a scheduled job deletes extracted facts and anonymizes the linked person record. It keeps case results and status history for aggregate statistics.

What we learned

  • A real quote does not guarantee a reliable fact. The context and wording around a claim matter.
  • Agreement is not proof. Two passes by the same model can make the same mistake. Our confidence scores help route reviews; they are not measured probabilities of correctness.
  • "Needs review" is a useful answer. It is better to show uncertainty than to hide it behind a yes or no.
  • Separation makes decisions testable. Keeping eligibility rules in pure functions lets us test and explain them without calling a model.
  • Privacy is more than encryption. It also involves who can see data, what gets logged and how long personal information is kept.

JuriSync is designed to help a lawyer notice the right case sooner, check the reasons and take the next step. Important legal decisions stay with people.

Built With

  • next.js
  • tailwindcss
Share this project:

Updates

Submission history