ALDDS / README.md
LitigationBrach's picture
Update README.md
12a8954 verified
|
Raw
History Blame Contribute Delete
5.39 kB

A newer version of the Gradio SDK is available: 6.20.0

Upgrade
metadata
title: ALDDS
emoji: ๐Ÿ’ป
colorFrom: indigo
colorTo: red
sdk: gradio
sdk_version: 6.14.0
python_version: '3.13'
app_file: app.py
pinned: false

โš–๏ธ Automated Legal Document Digitization System (ALDDS)

Python Gradio MongoDB Hugging Face

Upload a photo of a legal document (bailable warrant, summon, etc.) and seamlessly convert it into structured JSON data. ALDDS handles the OCR, AI parsing, secure storage, and live dispatcher notifications in a single streamlined pipeline.

๐Ÿš€ Pipeline & Architecture

Image Upload โ†’ Cloudinary Hosting โ†’ Tesseract OCR โ†’ NVIDIA LLMs โ†’ MongoDB โ†’ WhatsApp Alert
  1. OCR Extraction: Uses Tesseract to extract raw text from image uploads.
  2. AI Parsing: Leverages advanced NVIDIA models (qwen/qwen3-coder-480b-a35b-instruct, Llama 3) to parse the unstructured OCR text into a strict 10-field JSON schema.
  3. Secure Storage: Automatically commits the digital record to a MongoDB database.
  4. Live Dashboard: A real-time, searchable Police Dashboard built directly into the UI.
  5. Instant Notifications: Dispatchers can notify Investigating Officers (IOs) instantly via zero-cost WhatsApp wa.me links populated from an internal CSV database.

๐Ÿ“‹ Features

  • Multi-Model Fallback: The app cycles through a priority list of NVIDIA LLMs ensuring maximum uptime and reliability during the parsing phase.
  • ๐Ÿ‘ฎ Live Police Dashboard: A dedicated tab for station dispatchers to monitor incoming warrants. Includes a real-time MongoDB search filter (by Case No, IO Name, Station, etc.).
  • ๐Ÿ’ฌ WhatsApp Integration: Zero-API-cost notifications. Selecting an officer from the dropdown dynamically pulls their phone number from officers.csv and opens a pre-filled WhatsApp window for the dispatcher to send manually.

๐Ÿ”‘ Environment Setup

To run ALDDS locally or in the cloud, you need the following API keys configured in a .env file (or as Secrets on Hugging Face).

# Cloudinary (Image Hosting)
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret

# NVIDIA API (LLM Parsing)
NVIDIA_API_KEY=your_nvidia_api_key

# MongoDB (Database)
MONGODB_URI=mongodb+srv://username:password@cluster0.../?retryWrites=true&w=majority
Variable Where to get it
CLOUDINARY_* Cloudinary Console โ†’ Dashboard
NVIDIA_API_KEY NVIDIA Build โ†’ API Catalog โ†’ Get API Key
MONGODB_URI MongoDB Atlas โ†’ Database โ†’ Connect

๐Ÿ’ป Local Installation Guide

1. Install Tesseract OCR (System Binary)

Python's pytesseract requires the underlying Tesseract engine to be installed on your OS.

Windows

  1. Download installer from: https://github.com/UB-Mannheim/tesseract/wiki
  2. Run installer (default path: C:\Program Files\Tesseract-OCR\)
  3. The app is hardcoded to look for this path on Windows.

Linux (Debian/Ubuntu)

sudo apt-get update
sudo apt-get install tesseract-ocr

macOS

brew install tesseract

2. Run the App

# Clone repository
git clone https://huggingface.co/spaces/LovnishVerma/ALDDS
cd ALDDS

# Install Dependencies
pip install -r requirements.txt

# Run the Server
python app.py

The interface will launch at http://127.0.0.1:7860.


โ˜๏ธ Hugging Face Spaces Deployment

If you are deploying ALDDS to Hugging Face Spaces, follow these critical steps:

  1. Set Up Secrets: Go to your Space Settings -> Variables and secrets. Add all variables from your .env file as Secrets.
  2. System Dependencies: Hugging Face runs Debian Linux. The repository includes a packages.txt file telling Hugging Face to install tesseract-ocr and libtesseract-dev during the Docker build.
  3. CRLF Warning: Ensure that packages.txt is saved with Unix (LF) line endings. If it has Windows (CRLF) line endings, the Hugging Face Docker build will fail with a Package not found error.
  4. Restart: Always click Restart Space after adding or modifying Secrets so the new environment variables are loaded into the container.

๐Ÿ“Š Extracted JSON Schema

The LLM is strictly prompted to extract the following fields. If a field cannot be found, it defaults to null.

JSON Key Description
Case_FIR_Number FIR or court case reference number
Act_and_Sections Applicable IPC/CRPC legal acts and sections
Type_of_Document Warrant, summon, notice, etc.
Target_Police_Station Police station the document is addressed to
IO_Name_and_Belt_No Investigating Officer's name and belt number
IO_Mobile_Number IO's contact number
Person_Name_To_Serve Name of the person to be served/arrested
Person_Address Address of the target person
Court_Name Issuing court name
Hearing_Date Scheduled hearing or appearance date (DD-MM-YYYY)

Built to streamline station workflows, eliminate manual data entry, and instantly notify field officers.