Submission of Infra assessment | Implement reliable CDC pipeline, lakehouse storage, schema contract safety, and catalog metadata - #16
Open
ashokchetan800 wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request delivers a complete, production-grade Change Data Capture (CDC) Lakehouse Reliability implementation for a Payments & Digital Wallet system using DuckDB and Python.
The architecture guarantees:
Source Schema Design
customers: Account profile container (customer_idPK,name,email,statusenum).wallets: Financial balance container (wallet_idPK,customer_idFK,balanceDECIMAL(18,2)currency,statusenum).merchants: Registered merchant container (merchant_idPK,name,email,statusenum).transactions: Payment lifecycle event (transaction_idPK,wallet_idFK,merchant_idFK,amountfeedirectionenum,statusenum,settled_atcreated_at).ledger_entries: Double-entry accounting audit record (entry_idPK,transaction_idFK,wallet_idFK,entry_typeenum,amountbalance_aftercustomer_id,wallet_id,status, andtransaction_id.CHECKconstraints (non-negative balances/fees, positive transaction amounts, valid status enums, timestamp ordering).CDC Strategy
1, 2, 3...) trackinginsert,update, anddeleteoperations viaCDCCapture.insert/updateupserts entity state, whiledeletemarks soft-delete flag_deleted = true.records_since(offset), allowing pipeline consumers to resume cleanly after network partitions or service restarts without missing events.append_to_lake), and primary key upsert idempotency in the Warehouse (apply_cdc_records).Lake and Warehouse Modeling
lake_cdc_eventstable storing un-mutated raw CDC event payloads(sequence, operation, table_name, primary_key, data, captured_at).wh_*) reflecting the latest operational snapshot keyed on entity primary keys with_cdc_seqand_deletedflags.reconstruct_snapshot_at(conn, target_seq)replays Lake events up to sequencetarget_seqto reconstruct exact prior warehouse state at any historical moment.Schema Change Safety
check_schema_compatibility()compares source DDL againstSCHEMA_CONTRACT.assert_schema_compatible()logs aSTOP-THE-LINEalert and raisesSchemaIncompatibilityError.1.Validation Parity
settled_at >= created_at), and status enum compliance.pipeline/validations.pyexecuted byscripts/run_data_quality_checks.pyreturning exit code0on success or1on failure.Catalog Exposure
Exposed metadata for Lake (
lake_cdc_events) and Warehouse (wh_*) datasets incatalog/catalog.json. Metadata includes layer classification (lakevswarehouse), owner teams, update cadences, intended audiences, and column-level schemas with data types and descriptions. Validated viascripts/validate_catalog.py.Validation
Ran the complete test suite and CI verification scripts locally:
pytest tests/(18/18 passed)python scripts/check_schema_contracts.py(Exit 0 — all 5 tables passed)python scripts/run_data_quality_checks.py(Exit 0 — all system & business rules passed)python scripts/validate_catalog.py(Exit 0 — catalog metadata valid)ruff check .&black --check .(Passed with zero errors)Known Limitations / Next Steps
CDCCapture. In production, this would use Debezium reading Postgres WAL into Apache Kafka.Responsible AI Usage
Author Checklist
ruff&black)pytest18/18 passed)scripts/check_schema_contracts.py)scripts/run_data_quality_checks.py)scripts/validate_catalog.py)