Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
51 small wins to finish your pathNext question →

Q17IntermediateSystem design

Design a pipeline that extracts structured data from invoices (PDFs, scans, emails) for an accounts-payable system.

30-second answerSay your answer out loud first, then reveal.
Invoice pipeline: documents arrive by email, upload or API into object storage and a queue, are classified, parsed with OCR or a vision LLM, extracted to a JSON schema and validated deterministically; passing high-confidence items go to the ERP, failed or low-confidence ones go to a human review UI whose corrections feed evals and few-shot examples.

Deep-dive points

  1. Schema: vendor, GSTIN/VAT ID, invoice number, dates, currency, line items (description, qty, unit price, tax), totals. Use enums and formats.
  2. Extraction approach: text-based LLM on OCR output (cheaper) vs vision LLM on page images (better on complex layouts). Route by document quality.
  3. Grounding: ask for the source text span or bounding box per field so reviewers can verify quickly.
  4. Validation is key: line items × quantities must equal the subtotal, subtotal + tax = total, due date after invoice date. Validation catches most extraction errors without a human.
  5. Vendor-specific memory: few-shot examples from that vendor's previously corrected invoices improve accuracy.
  6. Throughput: batch processing, parallel workers, retries, idempotency by file hash.
  7. Security: financial documents need encryption, access control and audit trails.

Metrics: field-level accuracy, straight-through processing rate (no human touch), review time per document, cost per document.

You understood something today that you didn't yesterday.