Skip to content

About

High-throughput financial transaction reconciliation engine processing 109k+ records/sec with immutable double-entry invariant validation and automated exception queues.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

LedgerMatch-Recon: High-Throughput Financial Reconciliation Engine

Python 3.10+ Architecture: Double--Entry Reconciliation: Multi--Way License: Apache 2.0

Architect & Author: Chethan Raj D S (chethanraj.d.s@gmail.com)
Domain Pedigree: Tier-1 Global Banking Reconciliation Systems (ABN AMRO Amsterdam, Royal Bank of Canada London) · Intellimatch v8.1/v9.1 Architectures · Zero-Error Financial Ledgers


1. Architectural Philosophy: The Zero-Loss Guarantee

In enterprise financial engineering and global payment ledgers (Stripe, tier-1 clearing banks), transactional reconciliation is the final line of defense against financial loss, double-crediting, and silent ledger drift.

LedgerMatch-Recon enforces four non-negotiable principles:

  1. Immutable Double-Entry Ledger: Balance updates never mutate existing rows (UPDATE account SET balance = ... is forbidden). Every transaction is recorded as paired debit and credit journal legs adhering to the zero-sum invariant: $$\sum \text{Debits} - \sum \text{Credits} = 0$$
  2. Multi-Way Matching Engine:
    • 1:1 Matching: Exact external clearing ID, currency, and amount.
    • 1:N Batch Settlements: Reconciles bulk bank payout deposits (e.g., daily settlement $50,000.00) against hundreds of individual customer transactions minus processing fee deductions.
    • N:M Multi-Currency FX Matching: Matches cross-border currency pairs within configurable basis-point (bps) tolerance bands to accommodate foreign exchange settlement drift.
  3. Out-of-Proof Exception Queue: Any transaction failing matching invariants is atomically isolated into an audit queue with tagged reason codes (OUT_OF_PROOF_VARIANCE, UNMATCHED_EXTERNAL, MISSING_PAYOUT_LEG).
  4. Strict Idempotency: Checkpointed batch runs ensure replaying the same clearing file 10 times produces identical balances and zero duplicate journal entries.
                  ┌──────────────────────────────┐
                  │ External Bank Clearing Feeds │
                  │  (SWIFT / Fedwire / Stripe)  │
                  └──────────────┬───────────────┘
                                 │
                                 ▼
                  ┌──────────────────────────────┐
                  │ Idempotent Ingestion Engine  │
                  │   (Deduplication Hash Check) │
                  └──────────────┬───────────────┘
                                 │
                                 ▼
                  ┌──────────────────────────────┐
                  │   Multi-Way Matching Core    │
                  │  ┌────────────────────────┐  │
                  │  │ Rule 1: 1:1 Exact Match│  │
                  │  ├────────────────────────┤  │
                  │  │ Rule 2: 1:N Batch Payout│  │
                  │  ├────────────────────────┤  │
                  │  │ Rule 3: N:M FX Spread  │  │
                  │  └────────────────────────┘  │
                  └───────┬──────────────┬───────┘
                          │              │
        Matched Invariant │              │ Out-of-Proof / Variance
                          ▼              ▼
     ┌────────────────────────┐      ┌────────────────────────┐
     │  Reconciliation Audit  │      │  Out-of-Proof Queue    │
     │  Ledger (Append-Only)  │      │  (Exception Audit Log) │
     └────────────────────────┘      └────────────────────────┘

2. Directory Structure

ledgermatch-recon/
├── pyproject.toml                     # Modern package spec & dependencies
├── schema.sql                         # PostgreSQL production double-entry DDL
├── docker-compose.yml                 # PostgreSQL container setup
├── ledgermatch/
│   ├── models.py                      # Immutable Pydantic models (JournalEntry, TransactionLeg)
│   ├── ledger.py                      # Double-entry journal with invariant validation
│   ├── idempotency.py                 # Ingestion deduplication & batch checkpointing
│   └── engine/
│       ├── rules.py                   # Matching algorithms (1:1, 1:N batch, FX tolerance)
│       ├── matcher.py                 # High-throughput reconciliation orchestrator
│       └── exceptions.py              # Out-of-proof classification & audit queue
├── benchmarks/
│   ├── generator.py                   # 50,000 synthetic banking transactions with edge cases
│   └── run_benchmark.py               # Throughput (recs/sec) and accuracy evaluation
├── tests/
│   ├── conftest.py
│   ├── test_ledger_invariants.py      # Zero-sum debit/credit balance tests
│   ├── test_one_to_one.py             # 1:1 exact matching tests
│   ├── test_one_to_many.py            # 1:N batch payout minus fees tests
│   ├── test_fx_tolerance.py           # Multi-currency FX tolerance tests
│   ├── test_out_of_proof.py           # Exception queue & root cause tests
│   └── test_idempotency.py            # Replay safety tests
└── examples/
    └── run_reconciliation_demo.py     # Live interactive CLI demonstration

3. Quickstart

# 1. Clone repository
git clone https://github.com/Chethan-Raj-D-S/ledgermatch-recon.git
cd ledgermatch-recon

# 2. Run test suite (100% offline, zero external dependencies)
pytest tests/ -v

# 3. Run high-throughput reconciliation benchmark
python benchmarks/run_benchmark.py

# 4. Run interactive demonstration
python examples/run_reconciliation_demo.py

About

High-throughput financial transaction reconciliation engine processing 109k+ records/sec with immutable double-entry invariant validation and automated exception queues.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages