Overview
The Review Tool (/review) is a web-based debugging interface for inspecting OCR responses, validating reconciliation, and understanding why the engine made specific decisions.
Access the tool at:
http://localhost:3000/review (or your deployed URL + /review)Key Features
Auto-Detection
Automatically finds invoice objects in nested JSON (LangFuse traces, API responses)
Visual Breakdown
Line-by-line math display: qty × rate, discounts, taxes, totals
Error Highlighting
Color-coded reconciliation status (green = matched, red = error)
Hypothesis Tracing
Shows all alternates considered and why one was chosen
Quick Start
Paste JSON Payload
Copy the full API response or LangFuse trace and paste into the text area:
- From API
- From LangFuse
Interface Components
1. JSON Input Area

- Accepts any JSON structure (no need to clean/format)
- Auto-detects invoice objects at any depth
- Supports both compact and V4 schemas
- Load Sample button for quick testing
2. Detection Status
After clicking Preview, the tool shows:- Compact (myBillBook): Legacy structured schema (
voucher,items,party) - MyBillBook v4: Full V4 schema (
doc_level,items,totals,reconciliation) - voucher_info: V4 variant with
voucher_infoinstead ofdoc_level(auto-normalized)
3. Invoice Viewer
Displays the structured invoice data with expandable sections:- Compact Schema
- V4 Schema

- Voucher details (invoice number, date, totals)
- Party information (name, GSTIN, address)
- Item lines with computed totals
- Reconciliation status
4. Reconciliation Breakdown
For Compact Schema
Shows line-level math table:
| Column | Description |
|---|---|
| No | Line number |
| Item | Item name |
| Qty | Quantity |
| Rate ex-tax | Per-unit price (tax-exclusive) |
| Base ex-tax | Qty × Rate before discounts |
| Item discount ₹ | Line-level discount amount |
| Invoice discount ₹ | Voucher-level discount allocated to this line |
| Taxable ex-tax | Final taxable amount after all discounts |
| Tax % | GST rate |
| Tax ₹ | GST amount (Taxable × Tax%) |
| Line total ₹ | Final line amount (Taxable + Tax) |
- 🟢 Green footer: Items taxable, tax, and total
- 🟡 Yellow metadata: Voucher discount applied, round-off used, discount mode
For V4 Schema
Shows detailed reconciliation results:
Totals Summary
Totals Summary
Printed Anchors
Printed Anchors
Reconciliation Metadata
Reconciliation Metadata
- ✅ Matched (error ≤ ₹0.05): Green background
- ⚠️ Close (error ≤ ₹1.00): Yellow background
- ❌ Unmatched (error > ₹1.00): Red background
Use Cases
1. Debug Extraction Failures
Check Alternates Considered
Look at the Analysis:
alternates_considered array:from_printed_with_tax had much lower error (125.50 vs. 510.00) but still didn’t match.Inspect Items
Check if items were extracted correctly:If items are missing → multi-page PDF issue or OCR failure.
2. Understand Reconciliation Logic
Scenario: Why did the engine pickfrom_printed_without_tax instead of as_is?
Check Implied Round-Off
Both have reasonable round-offs (< ₹6), so the decision was purely based on error.
3. Validate Discount Allocation
Scenario: Multi-discount invoice with complex header discounts.Verify Sequential Application
- After 10%:
50000 × 0.9 = 45000 - After 5%:
45000 × 0.95 = 42750 - After ₹1000:
42750 - 1000 = 41750
taxable_ex_tax = 42750, but calculation gives 41750. Why?4. Compare LangFuse Traces
Use Case: You ran the same invoice through two different models. Which extracted better?Sample Payloads
The Review Tool includes a “Load Sample” button that populates a demo invoice:- Nested LangFuse trace format
- Compact schema with 3 items
- Zero discounts and charges
- Small round-off (₹0.10)
Tips & Tricks
Auto-Scroll to Results
Auto-Scroll to Results
After clicking Preview, the page automatically scrolls to the invoice viewer. Adjust scroll position by setting:
Copy Reconciliation Details
Copy Reconciliation Details
Right-click on the reconciliation card → Inspect → Copy JSON object from React DevTools.
Test with Raw OCR Output
Test with Raw OCR Output
Paste the output from The Review Tool won’t detect invoice schema but will display the raw text for inspection.
/api/ocr (raw text) to see what the model sees before structuring:Compare Before/After Reconciliation
Compare Before/After Reconciliation
- Paste the raw model output (before
reconcileV4()) - Note the error and alternates
- Manually run reconciliation in browser console:
- Compare with API response to verify reconciliation logic
Development Notes
The Review Tool is implemented inapp/review/page.tsx using:
-
Auto-detection: Recursive JSON traversal with schema validation
-
Schema detection: Type guards for compact vs. V4
-
Reconciliation display: Separate components for compact (
CompactBreakdown) and V4 (InvoiceViewerV4)
To extend the Review Tool (e.g., add new schema types), update the
findInvoiceCandidate function and add corresponding viewer components.Related Topics
OCR Modes
Understand what each mode returns for paste into Review Tool
Reconciliation Engine
Deep dive into the logic behind the alternates and scoring

