DEV Community

Cover image for AI extracts. Code calculates. You decide. Building a procurement copilot that never lets the LLM do the math
Stephany Alves
Stephany Alves

Posted on

AI extracts. Code calculates. You decide. Building a procurement copilot that never lets the LLM do the math

The problem

A buyer in aerospace sourcing gets supplier quotations in every possible shape: a PDF from Kansas in USD, a Portuguese proposal in EUR with "30 dias" validity, a German Angebot with tooling charged separately. Before anyone can compare them, someone has to read every line, normalise currencies and Incoterms, add freight and one-time costs, check certifications and revisions, and only then argue about who wins.

LLMs are great at the first part (reading messy documents) and dangerous at the rest. A model that "helpfully" fixes a price or guesses a missing freight cost is a liability when the output becomes a purchase order.

So I built AeroQuote Compass around one rule:

AI extracts. Code calculates. You decide.

🔗 Live demo: https://aeroquote-compass.lovable.app

Code: https://github.com/stephanyalves-eng/aeroquote-compass
All suppliers, prices and parts are fictitious.

The flow: from 20 quotes to a released PO

  1. RFQ setup: part, revision, annual volume, required certification, FX rates, Incoterm adders.
  2. Extraction: the LLM turns each quotation into a fixed 30-field JSON schema, with a 0–100 confidence per field. Missing values stay null. The model is told never to calculate costs, scores or risk.
  3. Buyer validation: nothing enters a calculation before the buyer confirms it. A pending-items panel orders issues by severity: critical blockers, missing fields, low confidence (< 70%) and divergences.
  4. Comparison and decision: deterministic code computes the annual landed cost, eligibility and a weighted score, then explains the recommendation.
  5. PO Check and release: the purchase order is checked against the RFQ, the reviewed quote, the approved decision and the landed cost. Mandatory controls accept no tolerance.
  6. Audit trail: every extraction, edit, weight change, decision and tolerance is logged with date and owner, and exportable to PDF, Excel or CSV.

Buyer validation to recommendation

The rule engine lives outside React

Every business rule is a pure, unit-tested TypeScript module in src/lib/rfq/, so the UI only renders results. The annual landed cost, for example:

annual landed (USD) = applicable unit price × annual volume (in USD)
                    + quoted freight + quoted insurance
                      (or, if neither is quoted, an Incoterm adder % on material)
                    + duties + other adders
                    + one-time costs (tooling, NRE, FAI…) in year 1
Enter fullscreen mode Exit fullscreen mode

Two details that matter in real procurement:

  • Never invent a split. If a supplier quotes neither freight nor insurance, the app shows one combined Incoterm estimate and labels it as an assumption. It never fabricates two numbers.
  • Eligibility is not score. An expired quote, a wrong revision or a missing AS9100D certification makes a supplier not eligible, however cheap it is. Only eligible quotes can be recommended or selected; choosing someone other than the recommendation requires a written justification.

In the demo RFQ, the lowest unit price (USD 15,950) ranks 11th of 16 once landed, and the lowest landed cost belongs to a supplier that is not eligible. The recommended supplier wins on weighted score (cost 40 · lead time 20 · risk 15 · payment 10 · compliance 10 · commercial 5) among eligible quotes only.

PO Check: nothing is corrected silently

PO Check to release

The PO Check compares 26 controls. Each discrepancy shows the approved value, the PO value, the difference, the annual impact, the source and a recommended action:

Status Meaning
✅ Confirmed Within tolerance (with a note)
🟠 Requires review Non-critical difference. The buyer accepts it with a written justification or requests a correction
🔴 Blocker Mandatory control (supplier, part, revision, price beyond tolerance). Release is impossible

Color is never the only signal: red only for blockers, amber for review, green for confirmed, and every status is also written out.

Testing what matters

  • 433 unit tests (Vitest) cover the domain rules: FX, price breaks, landed cost, eligibility, PO tolerances, revision gates, audit attribution, unsaved-work detection.
  • Browser checks (Playwright) run the full flow at 1440 and 390 px and fail on any console error, horizontal overflow or axe-core accessibility violation.
  • A self-audit as a QA analyst found and fixed real issues: work lost on reload, a telemetry function anyone could call with the public key, badge contrast below 4.5:1, and an auth library crashing when browser storage is blocked.

Try the data yourself

I published the 20 synthetic quotes with their gold JSON extraction and the app's reference results:

Use it to evaluate your LLM's structured extraction field by field, or as a teaching case for landed cost.

Stack

TanStack Start · React · TypeScript · Tailwind · shadcn/ui · Supabase (Postgres with Row Level Security) · Vitest · Playwright. Built iteratively with an AI coding agent, with every change verified by tests and browser checks.

🎬 77-second walkthrough: https://github.com/stephanyalves-eng/aeroquote-compass/blob/main/docs/media/2026-11-10/aeroquote-compass-short-16x9.mp4

What would you add to the PO Check? I'd love feedback from anyone working in procurement or document AI.


Top comments (0)