learntodriveai.dev/Data Engineering/Debezium CDC + PII in Streams
Data EngineeringProject 117 unitsVerified on 16 October 2026

Debezium CDC + PII in Streams

Vikram DoorgakantDirector of Operations · Pharmaceutical wholesaler · Port Louis, Mauritius
Voicemail · from Vikram
The morning report shows yesterday's numbers but by the time I read it, 50 orders have already gone out. I need the data to be... current. Live. As it changes.
Chat with Vikram

What you hand back

  • A live CDC feed from PostgreSQL
  • Idempotent landing that survives connector restarts
  • PII masked across topics, landing, models and docs
  • CI and pre-push checks that block PII
  • An audit trail of access to sensitive data
  • A README with governance and add-a-table steps

7 units

  1. Unit 1: Meet Vikram and discover the problem

    Listen to the voicemail, question Vikram about the database and compliance, and write the problem statement.

    Open unit 1
  2. Unit 2: Set up Debezium CDC

    Build the Docker stack, set full before-image capture, scope the Debezium connector, and trace one known change into Kafka.

    Open unit 2
  3. Unit 3: The exactly-once gap

    Land the events, kill the connector to expose replayed duplicates, then switch to an idempotent MERGE keyed on id and LSN.

    Open unit 3
  4. Unit 4: PII in the stream

    Find patient and worker names flowing through the stream, mask them at the right boundaries, and report the exposure to Vikram.

    Open unit 4
  5. Unit 5: Automated governance in CI/CD

    Write PII scanning patterns, enforce them in GitHub Actions and a pre-push hook, and add an audit trail.

    Open unit 5
  6. Unit 6: Connector monitoring and composed verification

    Monitor the connector beyond its status, trace one change from source to mart, and check the interfaces between components.

    Open unit 6
  7. Unit 7: Close and deliver

    Push the clean repository, write the README, and explain the compliance protections to Vikram with evidence.

    Open unit 7
Read the full brief

You're building a CDC pipeline for a pharmaceutical distributor in Port Louis, Mauritius — capturing inventory changes from PostgreSQL through Debezium into Kafka, then into the transformation layer, with PII governance verified across every surface.

The discipline skills: Debezium CDC for PostgreSQL (WAL capture, before/after images, connector monitoring), idempotent MERGE keyed on primary key and LSN, automated PII scanning in CI via GitHub Actions, and audit trails for governance evidence.

The AI-direction lesson: composed verification. Multiple agents have contributed to this pipeline — and "each agent's output passes its own tests" does not mean "the composed pipeline works correctly." The verification challenge shifts from checking individual components to checking that pieces produced by different agents compose into a working whole. CDC adds a specific dimension: the WAL captures every committed change, including PII fields. Your mart-layer masking cannot reach Kafka topics or landing tables. A pipeline that works correctly and delivers real-time inventory data can simultaneously leak patient names through surfaces you haven't governed — with no error, no warning. Verifying governance at every surface, not just the output layer, is the culmination of everything you've built.

Your Role

You're building Vikram's CDC pipeline. This is full discovery — he mentioned CDC and compliance in a rushed voicemail, but the specifics come from asking. Nobody hands you a brief.

What's New

Last time you stood up Kafka from scratch, built producers and consumers, counted messages end-to-end, and created your first custom agent. The infrastructure was yours to build.

This time the events come from the database, not your code. Debezium reads the PostgreSQL write-ahead log and publishes every committed change as a CDC event. You do not control what gets captured — the database schema determines the event shape. That includes patient names, prescription data, and employee records that flow through Kafka topics where your mart-layer masking cannot reach.

The hard part: CDC captures everything. PII appears in surfaces you have not governed before. A pipeline that works correctly and delivers stale-free inventory data can simultaneously leak patient names through Kafka topics, landing tables, and generated documentation — with no error, no warning, and no one noticing until the regulatory inspector does.

Tools

  • PostgreSQL — source database with CDC-enabled tables
  • Debezium — CDC connector for PostgreSQL (new this project)
  • Apache Kafka (Docker, KRaft mode) — streaming platform
  • dbt Core — transformation layer
  • BigQuery or DuckDB — warehouse
  • Dagster — orchestration
  • GitHub Actions — CI/CD for governance checks (new at this altitude)
  • Claude Code — AI directing, MCP connections, hooks, agents
  • Git / GitHub — version control

Materials

You'll receive:

  • PostgreSQL database dump — the pharmacy inventory schema with seed data across 6 tables (inventory, prescriptions, controlled substances, temperature excursions, warehouses, pharmacies)
  • Debezium connector template — a configuration template with blank fields for table scope and column filtering
  • Project governance file — CLAUDE.md with the project context, PII inventory, work breakdown, and verification targets

Help available

A senior data engineer, Priya Venkatesh, is available as a chat resource throughout the project. She brings a pattern lens to CDC and PII handling. She's terse and won't direct your choices — ask her when you want a sanity check on grain, masking placement, or composed verification scope.

Materials · 3 files
Start Project 11

You work at a computer with a terminal. Signed in, your place is saved.