Spaces:
Running
A newer version of the Gradio SDK is available: 6.20.0
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)
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
- OCR Extraction: Uses Tesseract to extract raw text from image uploads.
- 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. - Secure Storage: Automatically commits the digital record to a MongoDB database.
- Live Dashboard: A real-time, searchable Police Dashboard built directly into the UI.
- Instant Notifications: Dispatchers can notify Investigating Officers (IOs) instantly via zero-cost WhatsApp
wa.melinks 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.csvand 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
- Download installer from: https://github.com/UB-Mannheim/tesseract/wiki
- Run installer (default path:
C:\Program Files\Tesseract-OCR\) - 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:
- Set Up Secrets: Go to your Space Settings -> Variables and secrets. Add all variables from your
.envfile as Secrets. - System Dependencies: Hugging Face runs Debian Linux. The repository includes a
packages.txtfile telling Hugging Face to installtesseract-ocrandlibtesseract-devduring the Docker build. - CRLF Warning: Ensure that
packages.txtis saved with Unix (LF) line endings. If it has Windows (CRLF) line endings, the Hugging Face Docker build will fail with aPackage not founderror. - 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.