← amirulhisyam.com |
ReconPulse v1.0 · Python + SQL Engine
View Source on GitHub ↗

PORTFOLIO PROJECT · DATA CLEANUP · ORCHESTRATION · RECONCILIATION

Multi-Rail Reconciliation & Data Quality Workbench

Simulates an end-to-end automated financial data pipeline across RENTAS+, RPP / DuitNow, FPX, and Card rails — cleansing messy ingestion feeds, deduplicating webhooks via SQL window functions, and classifying settlement breaks.

Ready
TASK 01 IDLE

Ingest & Quarantine Gate

Validates raw ledger & bank CSV/webhook schemas; quarantines corrupted rows.

—
TASK 02 IDLE

Cleanse & Canonicalize

Strips noisy reference IDs, parses MYR/RM text to integer sen, normalizes MYT/UTC dates.

—
TASK 03 IDLE

Dedupe & Multi-Pass SQL

Applies ROW_NUMBER() deduplication, T+0 exact match, and T+1/MDR tolerance window.

—
TASK 04 IDLE

Break Classifier & GL Audit

Tags root causes for treasury/ops escalation and generates audit-ready control ledger.

—
Auto-Reconciled Rate — Exact + Window/Fee Tolerance
Dirty Fields Cleaned — Refs, timestamps, currencies & rails
Noise Filtered Out — Duplicates dropped + corrupted quarantined
Gross Volume Verified — Actionable breaks isolated
Click any row to inspect Raw → Clean lineage & formula check
Canonical Ref Rail Ledger Date Settle Date Ledger Gross Gateway Fee Gateway Net Status / Root Cause

Before matching can succeed, raw feeds from internal microservices and external bank settlement files must be standardized. Every green pill highlights an automated data-cleanup transformation applied during Task 02.

Source Record ID Raw Reference → Canonical Raw Channel → Rail Raw Timestamp → ISO Date Raw Amount → Integer Sen

Records automatically intercepted before hitting the reconciliation join — preventing false breaks caused by double-fired payment webhooks, repeated settlement batch lines, or malformed upstream payloads.

Gate Action Source Feed Record ID Raw Reference Raw Amount / Timestamp Rule Triggered
reconpulse/engine/reconcile.sql SQLite / ANSI Window CTEs
WITH deduped_ledger AS (
  SELECT *,
    ROW_NUMBER() OVER (
      PARTITION BY canonical_ref, rail, gross_amount_cents
      ORDER BY ingested_ts ASC
    ) AS dup_rank
  FROM stg_internal_ledger WHERE is_quarantined = 0
),
joined_pairs AS (
  SELECT
    l.ledger_id, s.settlement_id, l.canonical_ref, l.rail,
    (l.gross_amount_cents - s.gross_reported_cents) AS gross_diff_cents,
    (l.gross_amount_cents - s.fee_cents - s.net_amount_cents) AS net_diff_cents,
    CAST(julianday(s.settlement_date) - julianday(l.tx_date) AS INT) AS day_lag
  FROM (SELECT * FROM deduped_ledger WHERE dup_rank = 1) l
  LEFT JOIN clean_settlement s ON l.canonical_ref = s.canonical_ref
)
SELECT canonical_ref, rail,
  CASE
    WHEN gross_diff_cents = 0 AND net_diff_cents = 0 AND day_lag = 0
      THEN 'MATCHED_EXACT'
    WHEN gross_diff_cents = 0 AND ABS(net_diff_cents) <= 2 AND day_lag BETWEEN 0 AND 2
      THEN 'MATCHED_WINDOW_TOLERANCE'
    WHEN gross_diff_cents != 0 OR ABS(net_diff_cents) > 2
      THEN 'BREAK_AMOUNT_OR_FEE_VARIANCE'
    WHEN settlement_id IS NULL THEN 'BREAK_MISSING_IN_SETTLEMENT'
  END AS recon_status
FROM joined_pairs;
reconpulse/engine/pipeline.py Canonical Cleanup & DAG Runner
def clean_reference(raw_ref: str | None) -> str:
    """Strip whitespace, punctuation & casing noise."""
    if not raw_ref:
        return ""
    return re.sub(r"[^A-Z0-9]", "", raw_ref.strip().upper())

def parse_currency_to_cents(raw_val: str | float | None) -> int | None:
    """Convert 'MYR 1,450.00' / 'RM 320.50' into integer sen."""
    cleaned = re.sub(r"[^0-9.\-]", "", str(raw_val or "").strip())
    return int(round(float(cleaned) * 100)) if cleaned else None

# Orchestrated Execution
orch = PipelineOrchestrator(run_id="RUN-20261125-01")
orch.run_task("01_ingest_raw_feeds", task_ingest)
orch.run_task("02_cleanse_and_standardize", task_cleanse)
orch.run_task("03_sql_multipass_reconciliation", task_reconcile)
orch.run_task("04_export_audit_artifacts", task_export)