The problem
Evolve Money is a Sydney mortgage brokerage that settles roughly $80–90M in loans a year. Every loan file starts the same way: the client emails a pile of documents (licences, payslips, tax returns, bank statements), some as clean PDFs and some as phone photos, and someone reads them and keys the details into the loan system.
The data is as sensitive as personal data gets and has to stay inside the client's environment. So the constraints were set from day one: documents stay in their Microsoft 365 tenant, brokers keep working in Outlook and SharePoint, and nothing is written to the loan system without a person signing it off. I built and run the pipeline. A second developer worked with me on the prototype and on early pieces of the SharePoint upload.
Ingestion: an inbox, not an app
Clients send documents to a dedicated mailbox. A Logic App picks up each new email and posts the attachments to the Function App using its managed identity; requests without a valid Entra ID token never reach my code. The ingest function reads the loan-file ID from the subject, converts HEIC photos to JPEG, stores the originals and starts one orchestration per loan file. Everything for a file lives under one blob prefix (originals, Markdown, page images, extractions, reports, status), and documents sent later reuse cached extractions instead of being paid for twice.
Fan-out, fan-in
My first version chained a storage queue per stage. Within two weeks I replaced it with Azure Durable Functions, because the assessment step needs to know when every document in a file is done, and an orchestrator gives you that join directly: one sub-orchestrator per document, then task_all. Each document runs in parallel with its siblings:
- Convert. PDFs become Markdown for the text model and 200 DPI page images for the vision model.
- Classify. A vision call on the first page picks identity, income, statements or other, with a confidence and flags like
partial_document. "Other" triggers a retry with up to three pages; if the model call fails outright, filename-prefix routing takes over. Anything still "other" goes to a person. - Extract. Each class has a versioned prompt and a Pydantic schema: 22 identity fields, 26 income, 22 statement, 70 in all, each mapped to a loan-system field and tagged
explicit(read off the page) orinferred. Documents over ten pages send only the first two and last two.
One assessment per loan file
After the fan-in, one model call writes a Markdown assessment for the broker: summaries per document class, cross-document checks (names and dates of birth agree, ID not about to expire, payslips consistent with the tax return, statements cover the period, documents missing) and a checklist.
Those checks live in a prompt, so they are advice to a broker, not guarantees. That's fine for a report a person reads. It isn't fine for anything that writes to a system of record.
The agent that proposes loan-system writes
The loan system is Mercury. The sync agent gathers the current state of the loan file from Mercury, then the model returns a typed plan. Each action is CREATE, UPDATE, NOOP or SKIP_REVIEW_REQUIRED against one of seven resources (contact, identification, employment, income, asset, liability, related party), and carries its payload, how it identified the target record, and field-level provenance: which document, which path in its extraction, and the value seen there.
Then a deterministic validator with 14 error codes checks the plan in four rings: shape (it parses), contract (valid operation for the resource, payload keys and enums in the Mercury schema, identifier bindings resolve), evidence (every create or update has provenance pointing at a real document and path) and safety (no two updates on one target, dependencies exist and are acyclic, a payslip used as employment evidence can't quietly become an income record). A failed plan gets one model repair pass with the structured errors, then it's validated again, dry-run, and summarised in plain English.
The model decides what should change. Code decides whether the proposal is well-formed and traceable. A person decides whether it happens.
What I got wrong first
The first validator tried to prove every payload value from its source: equality checks, a growing pile of special cases (name order, address substrings, rent frequency) and a small "transform" vocabulary the planner was meant to use to explain derived values. The planner kept inventing transform names, and for a while no real loan file produced a passing plan.
So I changed the contract. Payloads became the planner's final values and the transform field went. Provenance became mandatory traceability rather than proof: it must resolve to a real document and path, but a derived value that doesn't exactly match its source now warns the reviewer instead of blocking. I added a hand-written golden plan to the prompt and tests, and made SKIP_REVIEW_REQUIRED a normal outcome. Schema, operation, binding, path, dependency and policy errors stayed hard.
Sign-off in SharePoint
Brokers don't log in to anything new. Each loan file is mirrored to a SharePoint library, and the pipeline writes its state into folder columns: Report Ready, Plan Ready, Awaiting Approval, then Executed or Failed. A file only reaches Awaiting Approval once the plan has validated and the dry run has passed. On approval, a Power Automate flow calls the execute endpoint, which checks that the approval is pinned to the latest revision. If new documents have produced a newer plan, the old approval is rejected as stale. The executor only ever runs a validated plan, and the agent runs as a dry run unless that's switched off.
Field ownership: Mercury and GoHighLevel
The brokerage also runs GoHighLevel as its marketing CRM, and before the two systems sync, someone has to decide who owns which field. I sorted Mercury's contact fields into native GoHighLevel fields, custom fields, derived fields (total weekly income, current employer) and excluded data: tax file numbers never go into a marketing CRM. Mercury stays the system of record, and two-way sync waits until ownership is agreed field group by field group.
Running it
The Microsoft 365 side was set up with the brokerage's managed IT provider. In Azure, storage and model endpoints use managed identity and secrets sit in Key Vault.
Production shaped the error handling. SharePoint uploads use 10 MB chunks and honour Retry-After on 429s and 5xx; caching folder existence cut Graph calls for a 298-file upload from about 1,788 to about 308. A telemetry audit showed a long tail on the assessment call, so I tightened its per-request timeout and retry schedule. The suite has 243 pytest tests with every external service mocked.
The pipeline is in production, and I support it.