Engine Internals
Architecture & Pipeline Specifications
High-throughput tokenization, deterministic stream parsing, and ISO 20022 message synthesis with zero runtime allocations.
Bank Statement Parser is architected around a deterministic, four-stage extraction and validation pipeline. Every stage executes in-process with zero outbound telemetry, zero heap allocation in the critical path, and strict mathematical balance verification before emitting ISO 20022 messages.
Four-Stage Processing Pipeline
Stream Ingest
Zero-copy memory mapping (mmap) of input statement bytes with instant magic-byte format detection (PDF, CSV, OFX, MT940, CAMT.053).
Layout Tokenizer
Spatial coordinate mapping and multi-column tabular boundary reconstruction, preserving text flow across complex multi-page financial tables.
Zero Heap AllocationsField Normalizer
Canonical standardization of 24 global date dialects, ISO 4217 currencies, and mod-97 IBAN checksum verification.
ISO 20022 BTC MappingSchema Validator
Mathematical invariant verification (Opening + ΣCredits - ΣDebits = Closing) before emitting validated JSON or ISO 20022 XML.
Deterministic Pipeline Execution Trace
The trace below demonstrates the sub-millisecond execution lifecycle of the four-stage engine processing a multi-page PDF statement into validated ISO 20022 CAMT.053 XML:
Stage 1: Zero-Copy Stream Ingestion
The ingestion subsystem interfaces directly with the host filesystem via memory-mapped files (mmap), bypassing kernel-to-userspace buffer duplication. Byte slices are analyzed using non-backtracking magic-byte sniffers:
- PDF Documents: Validates file header prefix
%PDF-and reads the cross-reference table (xref) directly from the trailer offset. - OFX Streams: Sniffs
OFXHEADERSGML tags or XML prologue<?xml version="1.0"to branch into streaming parser trees. - SWIFT MT940 / MT942: Checks for field delimiter sequences (
:20:,:25:,:28C:) to route into deterministic line tokenizers. - CSV Delimited Files: Evaluates entropy across candidate delimiters (comma, semicolon, tab, pipe) over the first 50 rows to infer column geometry without full-file scans.
Stage 2: Spatial Layout Tokenization
For unstructured formats such as digital PDF statements, standard text extraction destroys critical vertical alignment. Bank Statement Parser utilizes a deterministic coordinate-clustering engine:
- Glyph Extraction: Maps character matrices, font bounding boxes, and baseline coordinates from content stream operators (
BT,ET,Tj,TJ,Tm). - Row Clustering: Groups glyphs with overlapping vertical tolerances into discrete lines, preventing footnote and header collision.
- Column Geometric Alignment: Computes vertical whitespace gutters to delineate Booking Date, Value Date, Narrative, Amount, and Running Balance columns.
- Multi-line Narrative Stitching: Heuristically associates wrapped description text back to the initiating transaction row.
Stage 3: Field Normalization & Standard Mapping
Extracted raw string tokens are converted into strongly-typed canonical primitives:
- Date Canonicalization: Resolves 24 regional date formats (including
DD/MM/YYYY,MM/DD/YYYY,YYYY-MM-DD, and multi-lingual month names) into ISO 8601 UTC timestamps. - Monetary Amounts: Parses European period/comma inversion (e.g.,
1.234,56vs1,234.56), preserving scale as exact 64-bit fixed-point integers to eliminate IEEE 754 floating-point rounding drift. - Account & Bank Identifiers: Verifies ISO 13616 International Bank Account Numbers (IBAN) using mod-97 arithmetic (ISO 7064) and validates ISO 9362 Business Identifier Codes (BIC).
- Transaction Code Classification: Maps proprietary transaction labels to standardized ISO 20022 Bank Transaction Codes (BTC), distinguishing card settlements, direct debits, credit transfers, and fee deductions.
Stage 4: Mathematical Validation & Schema Synthesis
Before any extracted statement is emitted, the engine evaluates strict balance invariants to guarantee data integrity:
Upon invariant satisfaction, the engine streams the normalized data tree into target schemas:
- ISO 20022 CAMT.053: Generates conforming
camt.053.001.08Bank-to-Customer Statement XML messages ready for direct core banking and treasury ingest. - Canonical JSON: Emits clean, strongly-typed JSON with ISO 8601 dates and exact decimal numbers for downstream API consumption.
- Reconciliation CSV: Serializes standardized transaction rows with consistent column headers for enterprise ERP systems.