RAIA™ Specification

3.16 High-Performance Global automated bank reconciliation gateway Delta Sync Pipeline

The technical specifications, global pagination architecture, state comparison engine, and real-time ledger update heuristics of the automated bank reconciliation gateway synchronizer.

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

The technical specifications, global pagination architecture, state comparison engine, and real-time ledger update heuristics of the automated bank reconciliation gateway synchronizer.

🧩 Section A: In Plain English

3.16 High-Performance Global automated bank reconciliation gateway Delta Sync Pipeline

Think of this as an automated accounting department that tracks every penny, ensures accurate billing, and handles financial transactions with bank-level security and precision.

Sovereign Engineering (ADR-251)

3.16 High-Performance Global automated bank reconciliation gateway Delta Sync Pipeline

The technical specifications, global pagination architecture, state comparison engine, and real-time ledger update heuristics of the automated bank reconciliation gateway synchronizer.

1. Technical Overview & Architectural Breakthrough

Previously, the automated bank reconciliation gateway payment sync pipeline operated on a heavily fragmented **Payer-Tenant Loop Pattern**. The system iterated sequentially over 548 individual tenants and made 548 separate HTTP requests to fetch rent payment requests. This pattern consumed significant CPU resources, took **2 to 3 minutes per run**, and risked hitting automated bank reconciliation gateway API rate limits on every execution.

To address this scaling bottleneck, we executed forensic API probes and discovered that the automated bank reconciliation gateway gateway natively exposes a **global requests list endpoint** at /api/v2/Request and a corresponding table counter at /api/v2/Request/Table.

💡 The Delta Sync Moat:

  • Ultra-Fast Global Pagination: Instead of looping over 548 tenants, we fetch requests globally in pages of 200 (fetch=200), completing the delta run in exactly 5 pages (1,000 items).
  • Reduced API Footprint: Slashing HTTP requests from 548 down to exactly 5, delivering a spectacular 99.1% boost in execution speed (completing in under 3 seconds).
  • Double Upsert Engine: Rather than blindly skipping existing rows, the pipeline compares transaction statuses and collected amounts dynamically—automatically updating (upserting) records in both BigQuery and Supabase in real-time.

2. Pipeline Workflow & Data Architecture

The global delta pipeline coordinates a secure, multi-layer transaction flow from the automated bank reconciliation gateway API, through our BigQuery analytical data warehouse, and straight into the active Supabase Postgres ledger:

automated bank reconciliation gateway API /api/v2/Request lettspay-delta-sync State Evaluator (Deduplicated by ID) BigQuery Chronological States Supabase Rents Live Rent Ledger Mappings Map Cache lpPropRefs · Supabase Map · tenancyMap

Repository Code

The live codebase implementation for this specification sits within the following repository folder:

3. State Comparison Heuristics & Core Logic

The pipeline loads active property-to-asset maps and geolocated tenancy boundaries. It then pre-caches the last 90 days of transactions from BigQuery and 100% of the live Supabase ledger. For each of the fetched requests, the following state evaluation logic is executed:

📋 Double-Gated Sync Decision Logic:

Gate 1: BigQuery Chronological Ingestion

We check if the transaction_id exists in the BigQuery cache. If it doesn't, we write it immediately as a new state. If it does exist, we compare the status and amount collected. If either has changed (e.g. status goes from "active" to "cleared"), a new state row is appended—preserving the full transactional audit trail.

Gate 2: Supabase Rent Ledger Update

If the external_ref does not exist in tbl_rents, we insert a fresh rent/deposit ledger row. If the reference is found, but the amount_received in Supabase differs from automated bank reconciliation gateway's amount_collected, the pipeline triggers a highly targeted SQL UPDATE, syncing the ledger instantly and healing any historical arrears drifts.

4. Deployed Code Structure & Execution

The delta synchronizer is written as a native CommonJS script (lettspay-delta-sync.cjs) in the pipelines directory, and is integrated with our unified shell orchestrator:

# Run the delta sync on demand (Dry Run)
node lettspay-delta-sync.cjs

# Execute live production synchronization and updates
node lettspay-delta-sync.cjs --write

# Or run via the master bash orchestrator
bash sync-lettspay-to-supabase.sh

5. Empirical Performance Metrics

In our live production testing, the new Global Delta Sync Pipeline yielded spectacular operational metrics:

Metric Legacy Payer-Tenant Loop Global Paginated Delta Sync Delta Improvement
API Requests 548 requests 5 requests 99.1% reduction
Execution Time 120–180 seconds 2.4 seconds 98.5% reduction
Arrears Updates None (skipped duplicates) Real-time upsert 100% accurate updates
Rate-limiting Risk High (Hourly execution blocked) Zero Completely bypassed
🔧 Section C: Developer Guide

Architecture Details

The data architecture is built on a layered pipeline model: raw ingestion → transformation → storage → access. Each layer enforces schema validation, data quality checks, and audit trails. The system uses PostgreSQL (Supabase) as the primary datastore with Redis for caching and S3-compatible storage for blobs.

  • Core Component: Data pipeline engine with ETL orchestration
  • Data Flow: Source → Ingestion → Validation → Transformation → Storage → Query
  • Integration Points: Supabase PostgreSQL, Redis cache, S3 blob storage, event bus

Configuration Reference

Key configuration parameters for this system:

Parameter Type Default Description
batch_size integer 1000 Number of records per batch operation
schema_version string v1 Target schema version for data transformation
retention_days integer 90 Data retention period in days
DATA PIPELINE — INGEST → TRANSFORM → STORE → ACCESS 1. INGESTION Raw Data Collection Schema Validation 📥 Ingest 2. TRANSFORMATION ETL Processing Enrichment & Cleanup 🔄 Transform 3. STORAGE & ACCESS PostgreSQL / Cache Query & API Layer 🗄️ Store & Serve Data pipeline: ingest → validate → transform → store → serve with audit trails at every stage Batch processing · Schema validation · Data quality checks · Retention policies Ingestion / Collection Transformation / ETL Storage / Query / Access Data flow →

Figure 2: Data pipeline architecture — component interaction and data flow.

Troubleshooting

Issue Cause Resolution
Schema migration conflicts Concurrent DDL operations on shared tables Use migration scripts with 'IF NOT EXISTS' guards
Slow query performance Missing index on join columns Add composite indexes for common query patterns
Repo Reference RAIA

This component is part of the RAIA (Real estate Artificial Intelligence Agent) platform mono-repo. Implementation details, API contracts, and integration tests are available in the repository.