
Staff upload a deal's source documents, the system extracts the facts, a person confirms each uncertain one, and an attorney approves the filled closing forms.
What It Is
This system cut the time to prepare a real estate closing packet at a Texas law firm from 4 or more hours to 30 to 40 minutes. It is live and in daily use, it has processed more than 30 closings, and it got 174 of 184 fields right (94.6 percent) in a 9-deal test.
Closing on a real estate deal means signing a pile of legal papers. For wraparound and assumption deals in Texas, each deal arrives as a stack of source documents: the contract, a settlement statement, a title commitment, loan statements and payoff letters. Someone has to read them, pull out the facts and fill in about a dozen of the firm's forms by hand.
This project does the reading and the form filling with software. Staff upload the source documents for a deal. The system extracts the facts and shows where each one came from. A person reviews every uncertain fact. The system then fills the firm's closing forms as Word files, and an attorney approves them. Nothing leaves the office until every blank is confirmed by a person or approved by the attorney.
I built it for a Texas real estate law firm. It is a private client engagement, so there is no public source code. I describe it here in general terms and keep the client's details out.
Why It Exists
The firm's process was manual. An attorney built each closing packet by hand, and it took 4 or more hours. I started with a discovery session with the attorney principal and mapped the manual process from end to end. Then I turned it into a workflow that staff can run without needing to understand legal drafting.
One rule drives most of the design: accuracy beats coverage. An empty blank costs a minute of typing. A wrong loan balance on a signed document can cost far more. So a value reaches a form only after a person has looked at it and said so.
How Does Closing Document Automation Work?
A staff member creates a deal and picks its type. Each of the six deal types decides which forms exist and which facts are needed. She uploads the source documents. The system reads the first bytes of each file to check it is really what its name claims, and it ignores a second copy of the same file by its fingerprint. Scanned pages go through optical character recognition (OCR), software that turns a picture of text into text.
Extraction runs in the background. The review screen then lists each proposed fact with its confidence, a plain reason when two documents disagree, the source line and the page image with that line highlighted. The reviewer accepts a value, picks another reading or types her own.
Once every needed value is settled, the system fills the firm's templates and converts them to Word files. A blank it has never learned is left empty. An attorney checks the confirmations and approves the set, and staff cannot download anything before that. Every decision lands in an audit log.

How Facts Are Extracted
Extraction is a ladder with three rungs. First, rules anchored on the printed labels of standard documents. A settlement statement has numbered boxes, so a rule can say the amount printed after a heading is the sale price. Second, GLiNER2, a compact model that finds names, dates and amounts in text, fills only the fields the rules missed. Its results stay below the high-confidence tier. Third, an optional language model may propose an answer for the few fields still unclear. The answer must be printed on the exact document line it cites, or it is thrown away. It is only a suggestion. It never votes on a value or raises a confidence score, and a person decides.
After the ladder, the system resolves all candidates from all documents into one fact per field. If documents agree, confidence rises. If they disagree, it falls and both readings are kept. A Pydantic schema validates the whole set before any form is filled.
The project began as an experiment. A general-purpose entity-finding model on its own found about 30 percent of the fields, and none of its results passed validation. Rules did far better, so the product is built on rules first.

What Keeps It Careful
Accuracy comes first, so the system asks when in doubt. Each blank on a form needs a person's confirmation or the attorney's approval before it can leave the office. Today that means every blank, because the evidence is still thin.
Every route checks the caller's role on the server. SQL uses bound parameters only. Browser writes need a custom header that only the app can send, plus an origin check. The audit log is append-only: database triggers block updates and deletes, and each row is chained to the previous one with a hash, so tampering shows.
Real source documents, templates, final documents, extracted text and evaluation outputs with values never enter the code repository. Tests use made-up values only.
What I Built It With
The backend is FastAPI with a SQLite database and runs on a Mac. The review screen is a Vite and React app. The system is served to the firm's devices over Tailscale, a private network between your own devices, so it is not exposed to the public internet. Pydantic defines the typed data contract.
I also configured the Serena MCP server for Codex, so Codex, OpenAI's coding assistant, could navigate and inspect the attorney's Legal Document Creator codebase. MCP is Model Context Protocol, a standard way to give an AI tool extra abilities.
Where It Stands Today
The system is live and in daily use at the firm. It has processed more than 30 closings.
Each closing packet is 12 to 14 documents that the attorney used to build by hand in 4 or more hours. Now the system spends about 10 minutes on automated generation, and the attorney spends 20 to 30 minutes on review. That is 30 to 40 minutes in total. It took 3 weeks to reach a working proof of concept, 1 more week to reach an MVP, and 2 more weeks to reach a polished, finished product.
The math per packet uses the 4-hour minimum, 240 minutes, as the baseline. Packets that took longer saved more. 240 - 40 = 200 and 240 - 30 = 210, so each packet saves at least 200 to 210 minutes. 200 / 240 = 83 percent and 210 / 240 = 87.5 percent, so it takes at least 83 to 87.5 percent less time. Across more than 30 closings, at least 30 x 200 = 6,000 minutes are saved, which is more than 100 hours.
I measured accuracy with a leave-one-out test over 9 deals. The system got 174 of 184 fields right (94.6 percent), and all 59 high-confidence fields were correct. No blank is approvable without a person yet, so every blank still gets a person or attorney.
The first version used a general-purpose LLM for extraction and filling. It was not accurate enough and its answers varied from run to run, so I replaced it with structured extraction: rules, the GLiNER2 model and Pydantic validation. Template changes for some transaction types then broke the filling rules. So I built a template management system. The attorney uploads a new template, it is ingested automatically, and the filling rules adjust for later runs.
It grows only through reviewed examples and explicit rules. A new case type is not guessed into the system.
Glossary
- LLM
- Large language model, the kind of AI that reads and writes text.
- GLiNER2
- A compact model that finds names, dates and amounts in text.
- Pydantic
- A Python library that checks data against a defined shape.
- OCR
- Optical character recognition: software that turns a picture of text into text.
- FastAPI
- A Python framework for building web back ends.
- SQLite
- A small database that lives in a single file.
- Tailscale
- A private network between your own devices.
- audit log
- A record of who did what and when.
- MCP
- Model Context Protocol, a standard way to give an AI tool extra abilities.
- Codex
- OpenAI's coding assistant.
Key Facts
- Live and in daily use, 30+ closings processed
- 174 of 184 fields correct in a 9-deal leave-one-out test
- Every blank confirmed by a person or approved by the attorney
- Private repository, no public source link