Hammad Ur Rehman

Case studyLegal AI · Document AILead developer, AIVSTUDIOS

A pipeline that reads, sorts and rebuilds thousands of court documents.

Production legal document automation: OCR, document classification and multi-agent LLM analysis of court decisions, with a human-in-the-loop PDF editor before anything is final.

The problem

Legal teams were manually collecting, reading and reformatting thousands of court PDFs into standardized records. Every record had to be read, classified, cleaned up, numbered and bookmarked by hand: slow, repetitive, and easy to get wrong.

Constraints

Confidential legal data
These are real court documents. This page describes the system rather than showing client records.
Thousands of PDFs
The volume rules out manual handling, so every repeatable step has to be automated end to end.
Accuracy matters
A misclassified decision or a wrong page number ends up in a court record, so a person reviews the output before it is final.

Architecture

Seven stages, each doing one job. Automation and LLM agents handle the volume; a reviewer signs off in the PDF editor before volumes are assembled.

  1. PDF ingest. An automation bot pulls court PDFs in.
  2. OCR. Scanned pages become searchable text.
  3. Classification. Each document is classified by type.
  4. LLM agents. Agents read and analyze court decisions.
  5. Record builder. Standardize, de-duplicate, split, number, bookmark.
  6. PDF editor. Human-in-the-loop review and edits.
  7. Final volumes. Volume assembly and flattening.
Court-document pipeline architectureFlow diagram: PDF ingest, then OCR, then Classification, then LLM agents, then Record builder, then PDF editor, then Final volumes.01 PDF ingestAn automation bot pulls court PDFs in02 OCRScanned pages become searchable text03 ClassificationEach document is classified by type04 LLM agentsAgents read and analyze court decisions05 Record builderStandardize, de-duplicate, split, number, bookmark06 PDF editor · human reviewHuman-in-the-loop review and edits07 Final volumesVolume assembly and flattening
From raw court PDFs to final volumes. The highlighted step is where a person reviews and corrects the output.

What I built

  • Document ingestion: an automation bot collects the court PDFs, so nobody downloads them by hand.
  • Information extraction and LLM analysis of court decisions: one agent reads each decision, a second classifies it.
  • A record builder that shrinks, standardizes, numbers, titles and splits documents, checks for duplicates, and generates bookmarks.
  • An AI-powered PDF editor for review, with agents for edits and rendering plus automation for volume assembly, OCR and flattening.

Human-in-the-loop review

Automation does the volume work; people make the final call. Every output opens in a custom PDF editor where a reviewer can correct anything the pipeline got wrong. Agents behind the editor apply the edits and re-render the document, then the volume is assembled, OCR’d and flattened into its final form.

Outcome

Replaced a manual process that took hours per record.

Stack

PythonMulti-agent LLMOpenAI APIOCRPDF processingInformation extractionDocument classificationWorkflow automation

Need a document pipeline like this? Open to full-time remote Applied AI roles and freelance legal-AI projects.