Navigation

Fintech / accounting

ClearLedger

Month-end bank reconciliation and cash application for one NZD account, where every match explains itself and a locked close can never drift.

In the demo you import a fictional company's October bank statement (119 lines), confirm the 107 exact matches in one action, resolve the 12 exceptions and lock the period. Underneath: a versioned rule pipeline that explains every match, money in integer cents, invariants enforced by PostgreSQL constraints, and a lock that refuses until bank and book agree.

My role
Sole engineer: spec to deployment
Walkthrough
90-second guided scenario
Focus
Money-safe matching and period close

Launch guided demo (opens in a new tab)Engineering evidence

Stack: React · TypeScript · PHP/Symfony · PostgreSQL · Playwright + axe

Independently built portfolio showcase · simulated data

ClearLedger reconcile screen with the SILVERPINE HOMES +NZ$3,997.25 receipt selected: the recommended allocation to INV-1042 (NZ$2,684.50) and INV-1043 (NZ$1,312.75), the expanded "Why this match?" rule evidence, the list of 12 exceptions and the close status panel reading "Cannot lock yet".

The business problem

At month end, finance teams reconcile hundreds of bank lines against open invoices and the cash book. Most match cleanly; short payments, one payment for several invoices, garbled references, fees, reversals and repeated imports eat the close, and spreadsheets hide which decisions were made and why.

Try the workflow

  1. Step 1

    ClearLedger import preview for the sample October bank statement: 8 of 8 columns recognised, 119 rows, an opening balance of NZ$184,250.37 matching the prior close, a repeated-line warning for row 68, the first five rows and an "Import 119 lines" button.
    Import: 119 lines, opening balance checked against the prior close, a repeated line flagged before anything is written.
  2. Step 2

    ClearLedger reconcile screen right after import: the guide strip offers "Confirm 107 safe matches", the exceptions list shows 12 items starting with a repeated import from KAURI RIDGE BLDRS, and the close status reads "Cannot lock yet".
    Review: 107 exact, unique matches can be confirmed in one action; 12 exceptions wait with their reasons. The close cannot lock yet.
  3. Step 3

    ClearLedger after October is locked: "October closed — bank and book agree", adjusted bank balance and cash book both NZ$426,591.57, 119 / 119 lines processed, an unexplained difference of NZ$0.00 and a button to export the reconciliation report.
    Close: every line disposed of, bank and book agree, unexplained difference NZ$0.00. October is locked with an immutable snapshot.

Engineering invariants

Rules the system enforces whatever the user does, and where each one is proven.

InvariantWhy it mattersEvidence
Every statement line is in exactly one state: unreconciled, reconciled once, or excluded with a reason.No bank line can be counted twice or silently dropped from the close.DB CHECK chk_rc_line_reconciled / chk_rc_line_excluded (opens in a new tab)Integration/ClearLedgerRowSecurityTest.php :: testALineIsReconciledExactlyWhenItBelongsToAReconciliation
An allocation never exceeds what is still open on the invoice. The open amount is a CHECK-constrained column, updated under a row lock.Cash is never applied twice to the same invoice.chk_rc_item_open in migrations/Version20261122213000.php (opens in a new tab)Integration/ClearLedgerRowSecurityTest.php :: testConstraintsBackTheMoneyInvariants
The period locks only when every line is dealt with and the bank balance agrees with the cash book; otherwise the lock API returns 409. The locked period is stored as a snapshot with its SHA-256 hash.A close that does not reconcile cannot be locked, and a locked close cannot drift.Close gate + snapshot (opens in a new tab)Functional/ClearLedgerApiTest.php :: testMonthEndCloseFromImportToLockedSnapshot

System architecture

ClearLedger system architectureBrowser, then a React and TypeScript single-page app, then a Symfony modular monolith with the Reconciliation module, then PostgreSQL: row-level security isolates every demo session. The backend calls an AI adapter: On request, AI proposes the payer and invoice for a garbled reference (e.g. INV1O58 → INV-1058) and drafts an exception explanation from engine facts; the engine re-verifies, the operator confirms, and uploaded statements are never sent to AI.BrowserAnonymous demo session · guided scenarioReact + TypeScriptSingle-page app · Playwright end-to-end + axeJSON · RFC 9457 problem detailsSymfony modular monolithReconciliation modulerule pipeline · allocations · close snapshotstransactions · constraintsPostgreSQLRow-level security isolates every demo sessionAI adapterJSON schema + semanticvalidation · fixture modeby default · no AI numbersDocker + Caddy on a shared 4-vCPU host · synthetic data only
On request, AI proposes the payer and invoice for a garbled reference (e.g. INV1O58 → INV-1058) and drafts an exception explanation from engine facts; the engine re-verifies, the operator confirms, and uploaded statements are never sent to AI.

Key decisions

  • Keep bank reconciliation (statement vs cash book) separate from cash application (which invoices a receipt pays).

    Why: A reconciled bank account does not mean every receipt has been applied. Showing both keeps the close honest.

    Rejected: One combined status (my first design, changed after review).

    docs/specifications/010-clearledger.md §1 'Two reconciliations, kept apart' and review history

  • Classify lines before matching, and let only one rule auto-confirm: exact reference, amount, direction and counterparty, and unique.

    Why: Reversals, fees and repeated lines can never be matched by accident; bulk confirmation covers only what is provably safe.

    Rejected: Auto-confirming tolerance, date or fuzzy-payer matches. They stay suggestions.

    docs/specifications/010-clearledger.md §1 Pipeline

Engineering evidence

  • Tests

    PHPUnit — month-end close via API, undo + session isolation, RLS/constraint tests, golden file of the seeded month

    API tests of the month-end close, row-security and constraint tests, and a golden file of the seeded month.

  • End-to-end

    Playwright month-end close with axe

    The full close from import to lock, plus a 375 px phone check, with no serious or critical axe violations. 2/2 passing on production on 26 Nov 2026.

    Conditions: Run against production, desktop project

  • Decision records

    Architecture decisions

    ADR 0002 (modular monolith), ADR 0003 (fixture-first AI), ADR 0004 (registered, versioned rules).

  • Engineering page

    “How it's engineered” in the live demo (opens in a new tab)

    The full detail: rules, data model, tests and measurements, next to the running product.

I use AI-assisted development for implementation, exploration and review. I remain responsible for architecture, business rules, code quality and deployment. Critical behaviour is verified with deterministic tests, static analysis and reproducible benchmarks.

Trade-offs and limits

  • Synthetic data for a fictional company (Harbourline Supply Co.)
  • CSV import only; no bank or open-banking connection
  • One NZD account and one period; no general ledger, GST or multi-entity
  • Not accounting advice and not a certified financial system

My contribution

I built ClearLedger as an independent engineering showcase: product specification, architecture, frontend, backend, data model, automated tests and deployment.

Want to discuss the engineering behind this?

Launch demo (opens in a new tab)Get in touch

Source-code walkthroughs available on request.