AI & Agents · Security & Compliance · Full-Stack & UI/UX
Legal Document Review Agent (Gemini + LangGraph)
By David Gadyan · Published · Updated · Client: Alan Arnott
Multi-agent document-review API for a law firm's due-diligence workflow, built with LangChain and LangGraph on Google Gemini. It runs AI verification checks on cross-references, page numbers, party addresses, signature blocks and ABN/ACN identifiers, validates ABN/ACN against an external API, accepts configurable questions and recommendation counts from the web app, processes long contracts and generates Word review reports.
The problem
A law firm was already using a document-review API in its due-diligence workflow, but it was rigid: hard-coded prompts, a fixed list of ten recommendations, no room for long contracts, and no check that the Australian business identifiers (ABN/ACN) quoted in a document were real. This phase extended the API with dynamic verification checks, external validation and configurable output, all driven by a multi-agent AI pipeline.
What I built
I architected and implemented a LangChain and LangGraph system backed by Google's Gemini LLM:
- A document-verification section with AI-driven checks for cross-references, page numbers, party addresses, signature blocks, and ABN/ACN presence and formatting.
- External validation through an ABN/ACN verification API that confirms each identifier is authentic and has the right digit count.
- Dynamic questioning: the API accepts arbitrary lists of questions and variables from the web app, so the firm defines its own checks instead of relying on hard-coded prompts.
- A parameterised recommendation response, so the client chooses how many improvement suggestions they want instead of a fixed ten.
- A multi-agent workflow on Gemini's extended context window that processes lengthy contracts and due-diligence materials end to end.
- Automated generation of ready-to-use Word review reports that fit the firm's internal processes.
- Documentation and a replication package so future developers can maintain and extend the system.
Security and compliance
Due diligence is a verification job, and the API treats it as one. It checks the document against itself (cross-references, page numbers, signature blocks) and checks ABN/ACN numbers against an external source of truth, so a mistyped or fabricated identifier is caught before anyone relies on it.
Outcome
The firm's reviewers can now ask the API any set of questions, choose how many recommendations they want, run it over long contracts and receive a Word report at the end, with business identifiers verified rather than assumed. The documentation and replication package mean the system can be maintained and extended without me.
Related projects
HubAIOps: HubSpot AI-Readiness Audit App with Claude-Written Plans
AI & Agents · AI ERP & SaaS · Full-Stack & UI/UX
Receptra: AI Voice Receptionist SaaS for Small Businesses
AI & Agents · AI ERP & SaaS · Full-Stack & UI/UX
AI Trading Assistant: a Copilot That Holds You to Your Own Strategy
AI & Agents · Finance & Quant · Full-Stack & UI/UX