Case study · RAG and AI chatbots

PayRight: AI that checks every supplier invoice against the contract, with a human in the loop

A UK contract compliance and invoice assurance platform. AI extracts contract clauses, people confirm them, and every invoice is scored against contract and PO.

PayRight validation report for an invoice, with accuracy score, invoiced and expected totals, variance, potential savings and linked contract and purchase order
Client
PayRight, powered by GovernTerms (UK)
Role
AI full-stack developer
Timeline
– (4 months)
Stack
  • Claude Code
  • React
  • Node.js + TypeScript
  • PostgreSQL / Supabase
  • OCR and document extraction
  • Role-based access control

PayRight, powered by GovernTerms, is a UK platform that checks supplier invoices against the contracts and purchase orders behind them. It finds billing discrepancies, potential overcharges and savings, and shows exactly why. From January to April 2026 I was its AI full-stack developer.

One principle shaped everything: PayRight is decision support, not an autopilot. It never approves, blocks or changes a payment on its own. AI finds and explains; a person confirms and decides.

The problem

Checking an invoice properly means reading the contract: the agreed prices, minimum commitments, notice periods, discounts and price-review terms, then comparing every invoice line with them and with the purchase order. Done by hand it is slow, so it mostly isn’t done, and overcharges slip through.

AI can read contracts quickly, but finance teams can’t act on a black box. Every finding has to be traceable to the clause it came from, and nothing should count until a person has checked what the AI extracted.

What I built

The workflow: AI identifies, a person confirms, the system validates

  1. Upload contract

    PDF, Word, Excel or scanned copies

  2. AI extracts clauses

    Pricing, discounts, commitments, with source references

  3. Human confirms

    Every clause approved, edited or rejected first

  4. Upload PO and invoice

    Linked to the confirmed contract

  5. Validate and score

    Expected total, variances, savings, accuracy score

That split is enforced in the product. A contract cannot be used for validation until every extracted clause has been reviewed.

Contract management page with the four-step contract workflow banner and a table of contracts showing clause confirmation progress
Contract management: the workflow is spelled out, and each contract shows how many of its clauses have been confirmed.

Contract intelligence

Uploaded contracts go through document extraction and OCR, then AI pulls out the clauses that affect billing and turns legal language into structured rules: pricing, discounts, minimum commitments, notice periods, tolerances and service credits. Each clause keeps a reference back to its source: the document, page, section and the original text. In the review screen a person confirms, edits or undoes each one, or adds a clause the AI missed.

Clause review dialog for a contract: four AI-extracted clauses tagged Pricing and Discount, each confirmed, with Undo and Edit buttons and a progress bar showing 4 of 4 confirmed
Clause review: nothing is used for validation until a person has confirmed it.

Invoice and PO validation

Invoices and purchase orders come in as PDF, CSV, Excel or JSON, with extracted data shown for checking before anything is processed. Each invoice is linked to a purchase order, and the PO to a contract.

Data ingestion page: choose a purchase order, drop PDF, CSV, Excel or JSON files, and preview the extracted data before processing
Data ingestion: every invoice is tied to a purchase order, and the PO to a contract.

The validation engine then calculates what the invoice should total from the confirmed clauses and the PO, and compares it line by line. It flags pricing variances, quantity mismatches, discount violations, contract validity issues, tolerance breaches and service credit conditions, then produces a report with the variance, the potential saving, an accuracy score and a plain-language summary. The reviewer approves or rejects; the platform only recommends.

Validation report for an invoice: accuracy score 20.3% failed, invoiced total £4,846.15, expected total £3,438.46, variance +£1,407.69, potential savings £1,407.69, validation summary and linked supplier, contract and purchase order
A validation report from test data: £1,407.69 above what the contract allows, 11 discrepancies, sent to a person to approve or reject.

Scoring, benchmarking and reports

Accuracy is scored at invoice, contract and supplier level. A dashboard tracks invoices processed, discrepancies, potential savings and accuracy over time, and ranks suppliers. Supplier benchmarking uses anonymised, derived metrics, so no customer’s financial data is exposed to anyone else.

PayRight dashboard: invoices processed, discrepancies found, potential savings, accuracy score, validation trends chart, overall accuracy gauge, recent activity and supplier accuracy
The dashboard, shown here with test data.

For audit, each validation can be exported as a non-editable PDF assurance report with timestamps, version tracking, data completeness indicators, results, discrepancy explanations, the AI recommendations and an audit disclaimer.

Security and governance

Role-based access for admins, users and superusers, data isolated per customer, email verification at sign-in, and an audit log across every critical action.

Build log

January 2026

Started

Began as the AI full-stack developer, building the platform with Claude Code.

Along the way

Contracts and clauses

Document ingestion and OCR, AI clause extraction with source references, and the mandatory human confirmation workflow.

Along the way

Validation and reporting

The validation engine comparing invoices with contracts and POs, accuracy scoring, supplier benchmarking, the dashboard and the PDF assurance reports.

April 2026

Wrapped up

Handed over with the full contract-to-invoice workflow in place.

What this project shows

  • AI that finance teams can trust. Every finding traces back to a clause, page and section, and nothing counts until a person confirms it.
  • Document AI on messy inputs. Contracts, invoices and POs as PDFs, scans, Word, Excel and JSON, turned into structured, comparable data.
  • Governance designed in, not added later. Human approval, audit logs, non-editable reports and privacy-preserving benchmarks from the start.

Have contracts, invoices or other documents your team checks by hand? See RAG development and custom AI chatbots, or book a call.

Building something like this?

A multi-tenant SaaS, a scan-to-data pipeline, dashboards for two kinds of users. A 30-minute call is enough to scope your version.

Book a 30-minute call