LedgerGuard.

System boundary and technical judgment

AI handles document variation. Code controls financial risk.

Every pipeline stage belongs explicitly to an AI model, deterministic code, or a human reviewer. A model call never stands in for arithmetic, identity, routing, permissions, or payment authority.
2AI stages
10code stages
1human stage

End-to-end responsibility map

Thirteen stages with an explicit owner

Pipeline

Selected stage · 01 / 13

Intake & file validation

Type, size, and magic-byte checks. No active content ever reaches a browser context.

Owner
Deterministic code
Pipeline position
Stage 1 of 13
Review principle
Explicit responsibility

What AI does

  • Locating candidate fields across varied invoice layouts
  • Extracting header data and line items to a strict schema
  • Classifying invoice type
  • Mapping free-text descriptions to likely PO lines
  • Drafting an exception summary from verified control results
  • Explaining discrepancies in plain language

What deterministic code decides

  • Decimal arithmetic and total recalculation
  • Supplier-master comparison, tax-ID and domain normalization
  • Exact and fuzzy duplicate rules
  • Quantity and unit-price tolerances, PO balance checks
  • Approval thresholds and accounting-period rules
  • Idempotency, permissions, retry limits
  • Instruction-shaped-content screening

The model proposes extracted values. Deterministic code decides whether they satisfy financial controls — never the other way around.

Tolerance policy

Fictional v1 values — all versioned as configuration (current: policy_2026.3).

Unit price Lower of 2% or $25 per line
Quantity Zero, unless a receipt records the additional quantity
Total invoice Lower of 1% or $50
Tax $0.02 rounding only
Invoice date Cannot precede the PO date
Due date Cannot precede the invoice date

Security & privacy

  • Invoice text and QR codes are treated as untrusted data — embedded instructions directed at the model or operator are ignored, never executed.
  • File type, size, and magic bytes are validated at intake. A real AV engine is not practical on serverless infrastructure — this is documented as a production deployment requirement, not simulated.
  • All tables are RLS-locked to service-role access only, from the first migration.
  • Remittance/bank details from an invoice never overwrite the supplier master, ever.
  • Bank and tax identifiers are masked in ordinary logs; full document text is kept out of model-provider logs.
  • Invoice submitters cannot approve their own invoices.
  • No real supplier or financial data appears anywhere in the public portfolio.

Stack & integrations

App
FastAPI (Python, async ASGI) with server-rendered Jinja2 templates
Data
PostgreSQL via SQLAlchemy — NUMERIC money, audit events, jobs; a durable worker process drains the job queue outside the request path
Extraction
Anthropic Claude, native PDF/vision input, tool-forced JSON schema output
Deployment
Docker Compose — app, worker, and Postgres as separate services
Accounting integration
A sandbox accounting adapter — draft-bill change sets only (the AccountingBill model and proposedAccountingChange on each decision are real). External OAuth integration (e.g. QuickBooks Online) is intentionally out of scope for this build; the public demo stops before any external write.

Built by Ariel

Ariel Magalso
AI Engineer
Philippines · Remote

The architecture makes the model boundary inspectable.

This design demonstrates evidence alignment, decimal-safe arithmetic, identity resolution, duplicate rules, versioned tolerances, approval routing, idempotency, security boundaries, and honest integration limits.

Open to opportunities

Need AI automation that can explain itself?

I build measurable AI-assisted workflows with deterministic safeguards, visible evaluation, and human review where the risk demands it.

Contact Ariel