Projects

RELAYOPS

An AI back-office assistant for accounts payable: it reads invoices, receipts and purchase orders, proves where each value came from, checks them against the books, and routes them: straight into the books, to a reviewer, or on hold.

Invoices read in seconds. Every value proven. Every payment decision left to a person.

See it check an invoice

  • Business Automation
  • AI & Workflow
  • 2026
Role
Designed, built and tested end to end
Type
AI document automation · Back-office workflow · Quality engineering
Built with
TypeScript · Claude · PostgreSQL · Tesseract OCR · Next.js · Slack

At a glance

  • 99.7%of values read correctly from documents it had never seen
  • 10 of 10defined critical cases held for a person
  • 100%of values it marked verified were right
  • US$0.002AI cost per document

Measured on 40 documents it had never seen, 18 Nov 2026.

The challenge

Accounts-payable teams retype the same fields from every invoice: supplier, number, dates, lines, tax, totals, bank details. The typing is slow, but the real risk is the invoice that looks normal: a changed bank account, an invoice sent twice, a supplier nobody has heard of, a total that doesn't match the order. AI can read documents quickly, but a finance team can't trust a system that might guess a number or quietly decide to pay.

See it check an invoice

Ten fictional sample documents, each read by Claude Haiku 5.5 and checked by RELAYOPS's own code, as recorded on 18 Nov 2026. Choose a document, then a field. Its box on the page comes from the evidence check, not from the AI.

Everything matches the books: it's recorded automatically, but not approved for payment.

Clean invoice (US): the original document

TotalVerified

USD 285.02

Claude quoted
“$285.02”
Code found it
Found in the document, and it says this value · Page 1
Confidence, set by code
High

What Claude read

The decision

Recorded in the books

Clean, so it was recorded automatically. Approval for payment is a separate decision, by an approver.

16 checks passed · 1 not checked

CRITICAL_FIELDSFIELD_UNVERIFIEDUNKNOWN_SUPPLIERBANK_MISMATCHDUPLICATE_NUMBERPOSSIBLE_DUPLICATETAX_ID_MISMATCHADDRESS_MISMATCHCURRENCYAMOUNT_UNUSUALLINES_SUMTAX_AMOUNTTOTAL_AMOUNTPO_MISMATCHDATESINSTRUCTION_TEXTEMAIL_DOMAIN

Read by Claude Haiku 5.5 on 18 Nov 2026 · 15.4 s · US$0.0022 · checked by rules-v1 and evidence-v2

How it works

Seven stages take a document from intake to the books. Choose one to see what it takes, what it gives, and what happens if it fails.

The pipeline, stage by stage

Seven stages. The AI reads in two of them, code decides in four, and a person makes every decision about money.

AI readsCode decidesA person decides

Code decides

Document intake

Takes a file by upload, API or email and makes it one document, however many times it arrives.

Takes
A PDF, JPEG or PNG of up to 10 MB.
Gives
One document, stored under its SHA-256 fingerprint, with its receipt, an audit event and the first job in the queue.
Then
Queues the classification job for a worker.
Technology
Node.jsPostgreSQLbuilt-in SMTP inboxREST API
If it fails
  • Two arrivals of the same bytes, even at the same moment, give one document: the database's unique fingerprint decides.
  • An email is processed once per Message-ID. An API retry with the same Idempotency-Key gets the first response.
  • If saving fails, the inbox answers “try again later”, so the sender keeps the email.

When something breaks

Three failures RELAYOPS is tested against, step by step: a worker that dies mid-step, an AI service that keeps failing, and an alert sender that crashes.

Failure, step by step

Extract job
queued
Held by
no one
Lease
—
Attempt
0
Worker A
idle
Worker B
idle
Claude readings
0
Extractions saved
0

Step 1 of 7

  1. The extract job waits in PostgreSQL. A unique index allows one live job per document.

When the document finishes: one extraction, one ledger entry, no state move recorded twice. Claude read it twice, because the first answer was never saved.

Follows the test: “the worker killed mid-step resumes after its lease expires, with nothing lost or done twice”
An illustration of RELAYOPS's tested behaviour, with the numbers from its code. Nothing runs on this page.

People decide about money

RELAYOPS reads and checks; it never decides to pay. Every document ends in one of three places, and only a person moves it on from review or hold.

Where the ten samples ended

Recorded in the books

No check held it or sent it for review.

Clean, so it was recorded automatically. Approval for payment is a separate decision, by an approver.

Sent to a reviewer

A check needs a person's judgement.

A person records, fixes or rejects it, with every reason in front of them.

On hold

A critical check: bank details, a duplicate, an unknown supplier or an unreadable critical value.

Leaving hold needs a named person and a reason. Nothing is paid either way.

Choose one to open it in the walkthrough above.

Recording is not paying

  1. 01RecordedCode, for a clean invoice; a reviewer, for the restIn the books, ready to export.
  2. 02Approved for paymentA named approver, with a reasonThe database refuses it without one.
  3. 03PaidThe team, in the accounting toolNever by RELAYOPS.

Recording an invoice says it is right and belongs in the books. Approval for payment says it should be paid: a separate decision, by a named approver, with a reason. Paying happens in the accounting tool, outside RELAYOPS. No code path, role or setting in RELAYOPS can make a payment, and its tests check that.

Performance

Measured on 40 documents it had never seen (invoices, purchase orders, receipts and other mail; digital PDFs, scans and phone photos; US, UK, Australian and Philippine formats), 18 Nov 2026.

RELAYOPS was built and tuned on 80 sample documents. The other 40 were kept apart and run once, with the model, the prompt and the rules frozen. Reading, evidence and rules are scored separately, so a right value without proof still counts as a miss.

Held-out test, 40 documents

Reading

MeasureResultWhat it measures
Document type identified40 of 40Invoice, purchase order, receipt or other, as the answer record says.
Values read correctly930 of 933 (99.7%)Each value compared with the answer record written when the sample was made.

Evidence

MeasureResultWhat it measures
Values whose source text was found in the document and says that value841 of 857 (98.1%)Scored even when the value is right: a right value whose quote isn't on the page counts as a miss.
Values marked verified that were right840 of 840 (100%)Of everything RELAYOPS called verified, how much was right.
Smudged values reported as verified0 of 2Values smudged on purpose: none was passed off as read.

Decisions

MeasureResultWhat it measures
Defined critical test cases held for a personall 10 of 10The release gate: every defined critical case must be held. It is a gate on these cases, not a claim to catch every real one.
Clean digital invoices sent to a person unnecessarily0 of 18Clean digital PDFs that went to a reviewer or on hold anyway.
Clean scans and photos sent to a person5 of 5Local OCR couldn't confirm enough of their text, so each went to a person instead of being guessed.
Documents routed as expected35 of 40The other 5 are the clean scans and photos above.

Speed and cost

MeasureResultWhat it measures
Time to read a document (classify and extract)12.3 s median, 15.7 s for the slowest 5%Claude's two calls for one document.
AI cost per documentUS$0.0017Claude's two calls at API prices: US$0.0695 for all 40.

The critical cases are changed bank details, duplicate invoices, unknown suppliers, and bank details or totals that can't be read. Every one of the 10 defined cases was held for a person.

  • Tested like a product.
    • 98 unit tests, 40 database tests (including one that kills a real worker mid-step) and 5 browser tests at phone, tablet and desktop widths with accessibility checks.
    • An evaluation suite scores extraction, evidence and rules separately, on a tuning set and a held-out test set.
    • Every defined critical case must be held before a release.

Engineering decisions

ComponentTechnologyPurpose
PipelineTypeScript on Node.jsIntake, reading, evidence, rules, routing, side effects
AIClaude Haiku 5.5Classifies and extracts, as structured output checked against a strict schema
Text and OCRpdf.js · Tesseract (runs locally)The document's own text, for checking every quote
Database and queuePostgreSQLDocuments, books and audit trail; the job queue with leases, retries and a dead-letter list
Review appNext.jsEvidence view, decisions with reasons, metrics
IntakeBuilt-in SMTP inbox · REST APIEmail and API intake, each processed once
AccountingXero and QuickBooks CSVRecorded invoices, one row per line
AlertsSlackJobs moved to the dead-letter list
  • Code, not a workflow builder. TypeScript with a real database and job queue: every step is versioned and tested, at the cost of more to build than a no-code flow.
  • The AI reads; code decides. Claude returns values with their source text and nothing else. Plain rules check bank details against the supplier record, duplicate invoice numbers, purchase-order quantities and prices, tax and totals to the cent, dates, currency, and amounts far above a supplier's usual. Rules take longer to write than a prompt, but every decision has a tested reason, and text aimed at the AI can't change one.
  • The smallest model that met every target. On the 80 tuning documents, Claude Haiku, Sonnet and Opus 5.5 all met the accuracy targets. Haiku cost US$0.0019 a document, against US$0.025 for Sonnet and US$0.050 for Opus, so Haiku was chosen and frozen for the held-out test.
  • PostgreSQL as the queue. No separate queue server: a job, its result and the document's move are saved in one transaction, so they can't disagree. A dedicated broker would scale further; this needs one database.
  • Local OCR. Tesseract runs on the same machine, at no cost per page. When it can't confirm a value on a scan or a photo, the document goes to a person instead of being guessed.
  • A CSV handoff, not a live integration. RELAYOPS holds no login to the accounting system. Bills arrive in Xero as drafts and in QuickBooks as open bills, for the team to pay there.
  • Workspaces are isolated. One workspace's documents never meet another's: not in duplicate checks, the books, exports or reports.

My role

  • I designed RELAYOPS end to end: the data model, the state machine, the evidence check, the rules, the reliability design and the evaluation suite.
  • I built it with an AI coding agent (Claude Code), reviewing and approving each stage.
  • It brings together my two areas:
    • business process automation, which takes the retyping out of accounts payable;
    • quality assurance, which makes every value provable and every failure recoverable.