# mohidmakhdoomi/datapipe architecture

> Architecture diagram of the GitHub repository mohidmakhdoomi/datapipe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohidmakhdoomi/datapipe
- Repository: https://github.com/mohidmakhdoomi/datapipe

## Overview

1. **Repository purpose**
   - This repo is an infrastructure-heavy data platform, not an application codebase.
   - The implemented core is a **Kubernetes-hosted CDC ingestion pipeline** that moves changes from PostgreSQL into Kafka and archives them to S3.
   - The broader repo also contains scaffolding for the next Lambda-architecture layers: batch analytics, realtime speed layer, and orchestration/monitoring.

2. **Primary runtime boundary**
   - The main runtime is a **local `kind` Kubernetes cluster** running on Docker Desktop.
   - Most behavior is expressed as Kubernetes manifests, Helm/value files, and shell scripts rather than long-lived application services.
   - The repo is designed around reproducible local deployment under a strict memory budget.

3. **Source system boundary**
   - The source of truth is a **PostgreSQL** database deployed inside the cluster.
   - It represents the transactional OLTP layer for e-commerce entities such as `users`, `products`, `orders`, and `order_items`.
   - CDC is enabled through PostgreSQL logical replication/WAL, so database changes drive the rest of the pipeline.

4. **Streaming core**
   - The central streaming layer is a **3-broker Kafka cluster in KRaft mode**.
   - Kafka is the durable event backbone between source capture and archival.
   - Topics are provisioned explicitly, and the deployment includes resource-constrained sizing to keep the entire stack within 6 GiB RAM.

5. **CDC ingestion path**
   - **Debezium Kafka Connect source connectors** read PostgreSQL WAL changes and publish Avro-encoded change events into Kafka.
   - Connector configs are stored as JSON files under `1-data-ingestion-pipeline/connectors/`.
   - This is the main real-time ingestion path from relational DB mutations to event streams.

6. **Schema management boundary**
   - **Confluent Schema Registry** sits between producers/consumers as the schema contract layer.
   - Its role is to validate and evolve Avro schemas so CDC events can change without breaking downstream consumers.
   - This is an architectural control point, not just a dependency.

7. **Archive / sink path**
   - A second **Kafka Connect S3 Sink connector** consumes Kafka topics and writes immutable data to **AWS S3**.
   - Output is stored as **Parquet**, partitioned by time (`year/month/day/hour`) for analytical access patterns.
   - S3 is the terminal sink for the core pipeline and the handoff point to later batch/lakehouse layers.

8. **Kubernetes infrastructure and isolation**
   - The repo explicitly defines **namespaces, service accounts, RBAC, network policies, storage classes, and PVCs**.
   - This means the architecture is not just “services running together”; it has a deliberate security and storage boundary model.
   - The manifests in `01-*`, `02-*`, `03-*`, `04-*`, and `task*.yaml` are the concrete deployment substrate.

9. **Automation and validation flow**
   - `deploy-data-ingestion-pipeline.sh` is the main orchestration script that builds/deploys the cluster and applies components in order.
   - There are multiple validation scripts for health, connectivity, CDC correctness, performance, persistence, and S3 archival.
   - `data-generator.py` is used as synthetic workload to exercise the end-to-end path and measure throughput.

10. **Operational artifacts**
   - The `logs/` directory captures deployment logs, resource monitoring output, validation reports, and performance results.
   - These logs are part of the repo’s operational story: they document that the pipeline was exercised and what resource envelope it consumed.
   - `resource-monitor.sh` and related outputs show that observability is treated as a first-class concern for this local platform.

11. **Batch analytics layer scaffolding**
   - `2-batch-analytics-layer/` is a separate subsystem, currently more scaffold than runtime.
   - It contains Spark Operator deployment artifacts, S3 connectivity checks, Snowflake setup, Iceberg catalog setup, and e-commerce table jobs.
   - This layer is intended to consume the archived S3 data produced by the ingestion pipeline.

12. **Developer and environment tooling**
   - `.devcontainer/` and `utils-dev/` support reproducible development and ad hoc data inspection.
   - The devcontainer packages the environment needed to work on the pipeline locally, while utilities include S3 Parquet query/read scripts and resource conversion helpers.
   - These tools are ancillary; they support deployment and analysis but are not part of the production data path.

13. **Design/specification boundary**
   - `.kiro/specs/` contains requirements, design, and task documents for each major capability area.
   - This repository uses docs-as-spec for architecture traceability: ingestion, batch analytics, realtime speed layer, and monitoring each have their own spec set.
   - That makes the repo useful for diagramming both the implemented state and planned architecture.

14. **Overall data flow summary**
   - The implemented flow is: PostgreSQL transaction changes → Debezium CDC on Kafka Connect → Kafka topics with schema enforcement → S3 Sink connector → Parquet files in AWS S3.
   - Kubernetes provides the execution and isolation boundary for all of it.
   - Everything else in the repo supports deployment, validation, security, or future extension of that flow.

Main entry points: [`1-data-ingestion-pipeline/kind-config.yaml`](https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/kind-config.yaml) (kind cluster), [`2-batch-analytics-layer/task2-deploy-spark-operator.sh`](https://github.com/mohidmakhdoomi/datapipe/blob/main/2-batch-analytics-layer/task2-deploy-spark-operator.sh) (Spark operator), [`1-data-ingestion-pipeline/connectors/users-debezium-connector.json`](https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/connectors/users-debezium-connector.json) (Debezium sources), [`1-data-ingestion-pipeline/connectors/users-s3-sink-connector.json`](https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/connectors/users-s3-sink-connector.json) (S3 sink connectors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Platform runtime"]
  node_kind_cluster["kind cluster<br/>kubernetes runtime<br/>[kind-config.yaml]"]
end

subgraph group_ingestion["CDC ingestion"]
  node_postgres[("PostgreSQL<br/>oltp source")]
  node_kafka{{"Kafka KRaft<br/>event backbone"}}
  node_schema_registry["Schema Registry<br/>schema contract"]
  node_kafka_connect["Kafka Connect<br/>connector runtime"]
  node_debezium_connectors["Debezium sources<br/>cdc connectors"]
  node_s3_sink_connectors["S3 sink connectors<br/>archive connectors"]
  node_s3_archive[("AWS S3<br/>object storage")]
  node_data_generator["Data generator<br/>workload driver<br/>[data-generator.py]"]
end

subgraph group_batch["Batch analytics"]
  node_batch_cluster["Batch cluster<br/>kubernetes runtime"]
  node_spark_operator["Spark operator<br/>batch runtime"]
  node_iceberg_catalog["Iceberg catalog<br/>table catalog"]
  node_snowflake_setup["Snowflake setup<br/>warehouse integration"]
end

subgraph group_ops["Ops and specs"]
  node_deploy_script["Deploy script<br/>orchestration script"]
  node_validation_suite["Validation suite<br/>verification scripts"]
  node_resource_monitor["Resource monitor<br/>observability script"]
  node_ingestion_specs["Ingestion spec<br/>design docs<br/>[design.md]"]
  node_batch_specs["Batch spec<br/>design docs<br/>[design.md]"]
  node_speed_specs["Speed spec<br/>design docs<br/>[design.md]"]
  node_monitoring_specs["Monitoring spec<br/>design docs<br/>[design.md]"]
end

node_deploy_script -->|"builds/applies"| node_kind_cluster
node_kind_cluster -->|"hosts"| node_postgres
node_kind_cluster -->|"hosts"| node_kafka
node_kind_cluster -->|"hosts"| node_schema_registry
node_kind_cluster -->|"hosts"| node_kafka_connect
node_postgres -->|"CDC source"| node_debezium_connectors
node_debezium_connectors -->|"publish"| node_kafka
node_schema_registry -->|"schema checks"| node_debezium_connectors
node_schema_registry -->|"schema checks"| node_s3_sink_connectors
node_kafka_connect -->|"runs"| node_debezium_connectors
node_kafka_connect -->|"runs"| node_s3_sink_connectors
node_kafka -->|"consume"| node_s3_sink_connectors
node_s3_sink_connectors -->|"archive"| node_s3_archive
node_data_generator -->|"loads"| node_postgres
node_validation_suite -->|"verifies"| node_debezium_connectors
node_validation_suite -->|"verifies"| node_s3_archive
node_resource_monitor -->|"measures"| node_kind_cluster
node_ingestion_specs -.->|"guides"| node_deploy_script
node_batch_cluster -->|"hosts"| node_spark_operator
node_spark_operator -->|"uses"| node_iceberg_catalog
node_spark_operator -->|"integrates"| node_snowflake_setup
node_s3_archive -->|"consumed by"| node_spark_operator
node_batch_specs -.->|"guides"| node_spark_operator
node_speed_specs -.->|"plans downstream"| node_s3_archive
node_monitoring_specs -.->|"guides"| node_resource_monitor

click node_kind_cluster "https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/kind-config.yaml"
click node_postgres "https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/task4-postgresql-statefulset.yaml"
click node_kafka "https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/task5-kafka-kraft-3brokers.yaml"
click node_schema_registry "https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/task6-schema-registry.yaml"
click node_kafka_connect "https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/task7-kafka-connect-deployment.yaml"
click node_debezium_connectors "https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/connectors/users-debezium-connector.json"
click node_s3_sink_connectors "https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/connectors/users-s3-sink-connector.json"
click node_s3_archive "https://github.com/mohidmakhdoomi/datapipe/blob/main/2-batch-analytics-layer/task3-s3-connectivity-test.yaml"
click node_data_generator "https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/data-generator.py"
click node_deploy_script "https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/deploy-data-ingestion-pipeline.sh"
click node_validation_suite "https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/task8-validation-runner.sh"
click node_resource_monitor "https://github.com/mohidmakhdoomi/datapipe/blob/main/resource-monitor.sh"
click node_ingestion_specs "https://github.com/mohidmakhdoomi/datapipe/blob/main/.kiro/specs/data-ingestion-pipeline/design.md"
click node_batch_cluster "https://github.com/mohidmakhdoomi/datapipe/blob/main/2-batch-analytics-layer/batch-kind-config.yaml"
click node_spark_operator "https://github.com/mohidmakhdoomi/datapipe/blob/main/2-batch-analytics-layer/task2-deploy-spark-operator.sh"
click node_iceberg_catalog "https://github.com/mohidmakhdoomi/datapipe/blob/main/2-batch-analytics-layer/task5-iceberg-catalog-config.yaml"
click node_snowflake_setup "https://github.com/mohidmakhdoomi/datapipe/blob/main/2-batch-analytics-layer/task4-setup-snowflake.sh"
click node_batch_specs "https://github.com/mohidmakhdoomi/datapipe/blob/main/.kiro/specs/batch-analytics-layer/design.md"
click node_speed_specs "https://github.com/mohidmakhdoomi/datapipe/blob/main/.kiro/specs/realtime-analytics-speed-layer/design.md"
click node_monitoring_specs "https://github.com/mohidmakhdoomi/datapipe/blob/main/.kiro/specs/orchestration-monitoring/design.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_kind_cluster toneBlue
class node_postgres,node_kafka,node_schema_registry,node_kafka_connect,node_debezium_connectors,node_s3_sink_connectors,node_s3_archive,node_data_generator toneAmber
class node_batch_cluster,node_spark_operator,node_iceberg_catalog,node_snowflake_setup toneMint
class node_deploy_script,node_validation_suite,node_resource_monitor,node_ingestion_specs,node_batch_specs,node_speed_specs,node_monitoring_specs toneRose
```

## Components

### Platform runtime

Local Kubernetes-based execution and isolation boundary for the stack.

- [kind cluster](https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/kind-config.yaml): kubernetes runtime · Local Kubernetes cluster on Docker Desktop that hosts the pipeline. · `1-data-ingestion-pipeline/kind-config.yaml`

### CDC ingestion

Implemented PostgreSQL-to-Kafka-to-S3 data pipeline.

- [PostgreSQL](https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/task4-postgresql-statefulset.yaml): oltp source · Transactional source database with logical replication/WAL for CDC. · `1-data-ingestion-pipeline/task4-postgresql-statefulset.yaml`
- [Kafka KRaft](https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/task5-kafka-kraft-3brokers.yaml): event backbone · Three-broker Kafka cluster that carries CDC events and archive topics. · `1-data-ingestion-pipeline/task5-kafka-kraft-3brokers.yaml`
- [Schema Registry](https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/task6-schema-registry.yaml): schema contract · Validates and evolves Avro schemas for CDC events and consumers. · `1-data-ingestion-pipeline/task6-schema-registry.yaml`
- [Kafka Connect](https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/task7-kafka-connect-deployment.yaml): connector runtime · Executes Debezium source connectors and S3 sink connectors. · `1-data-ingestion-pipeline/task7-kafka-connect-deployment.yaml`
- [Debezium sources](https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/connectors/users-debezium-connector.json): cdc connectors · Per-table source connectors that read PostgreSQL WAL and publish change events. · `1-data-ingestion-pipeline/connectors/users-debezium-connector.json`
- [S3 sink connectors](https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/connectors/users-s3-sink-connector.json): archive connectors · Per-table sink connectors that write Kafka data to S3 as Parquet partitions. · `1-data-ingestion-pipeline/connectors/users-s3-sink-connector.json`
- [AWS S3](https://github.com/mohidmakhdoomi/datapipe/blob/main/2-batch-analytics-layer/task3-s3-connectivity-test.yaml): object storage · Terminal sink for archived change data and handoff for downstream analytics. · `2-batch-analytics-layer/task3-s3-connectivity-test.yaml`
- [Data generator](https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/data-generator.py): workload driver · Synthetic e-commerce workload used to exercise the CDC path. · `1-data-ingestion-pipeline/data-generator.py`

### Batch analytics

Scaffold for downstream Spark/Iceberg/Snowflake analytics on archived data.

- [Batch cluster](https://github.com/mohidmakhdoomi/datapipe/blob/main/2-batch-analytics-layer/batch-kind-config.yaml): kubernetes runtime · Separate local cluster scaffold for downstream batch analytics. · `2-batch-analytics-layer/batch-kind-config.yaml`
- [Spark operator](https://github.com/mohidmakhdoomi/datapipe/blob/main/2-batch-analytics-layer/task2-deploy-spark-operator.sh): batch runtime · Spark deployment substrate for batch jobs and notebooks. · `2-batch-analytics-layer/task2-deploy-spark-operator.sh`
- [Iceberg catalog](https://github.com/mohidmakhdoomi/datapipe/blob/main/2-batch-analytics-layer/task5-iceberg-catalog-config.yaml): table catalog · Catalog setup for lakehouse-style tables over archived data. · `2-batch-analytics-layer/task5-iceberg-catalog-config.yaml`
- [Snowflake setup](https://github.com/mohidmakhdoomi/datapipe/blob/main/2-batch-analytics-layer/task4-setup-snowflake.sh): warehouse integration · Scaffolding for warehouse connectivity and validation jobs. · `2-batch-analytics-layer/task4-setup-snowflake.sh`

### Ops and specs

Deployment automation, validation, monitoring, and design documents.

- [Deploy script](https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/deploy-data-ingestion-pipeline.sh): orchestration script · Primary automation for cluster bring-up and component deployment. · `1-data-ingestion-pipeline/deploy-data-ingestion-pipeline.sh`
- [Validation suite](https://github.com/mohidmakhdoomi/datapipe/blob/main/1-data-ingestion-pipeline/task8-validation-runner.sh): verification scripts · Health, connectivity, CDC, performance, persistence, and archival checks. · `1-data-ingestion-pipeline/task8-validation-runner.sh`
- [Resource monitor](https://github.com/mohidmakhdoomi/datapipe/blob/main/resource-monitor.sh): observability script · Captures cluster resource usage and operational logs for the constrained stack. · `resource-monitor.sh`
- [Ingestion spec](https://github.com/mohidmakhdoomi/datapipe/blob/main/.kiro/specs/data-ingestion-pipeline/design.md): design docs · Requirements, design, and tasks for the CDC ingestion pipeline. · `.kiro/specs/data-ingestion-pipeline/design.md`
- [Batch spec](https://github.com/mohidmakhdoomi/datapipe/blob/main/.kiro/specs/batch-analytics-layer/design.md): design docs · Requirements, design, and tasks for the analytics layer. · `.kiro/specs/batch-analytics-layer/design.md`
- [Speed spec](https://github.com/mohidmakhdoomi/datapipe/blob/main/.kiro/specs/realtime-analytics-speed-layer/design.md): design docs · Planned realtime speed-layer architecture documents. · `.kiro/specs/realtime-analytics-speed-layer/design.md`
- [Monitoring spec](https://github.com/mohidmakhdoomi/datapipe/blob/main/.kiro/specs/orchestration-monitoring/design.md): design docs · Orchestration and monitoring architecture documents. · `.kiro/specs/orchestration-monitoring/design.md`

## Connections

- Deploy script → kind cluster: builds/applies · Coordinates cluster bring-up and manifest application.
- kind cluster → PostgreSQL: hosts · Runs the source database inside Kubernetes.
- kind cluster → Kafka KRaft: hosts · Runs the Kafka backbone in-cluster.
- kind cluster → Schema Registry: hosts · Runs schema contract service alongside the streaming stack.
- kind cluster → Kafka Connect: hosts · Runs connector runtime in the cluster.
- PostgreSQL → Debezium sources: CDC source · Logical replication/WAL feeds Debezium capture.
- Debezium sources → Kafka KRaft: publish · Writes Avro CDC events into Kafka topics.
- Schema Registry → Debezium sources: schema checks · Provides schema contract validation for event payloads.
- Schema Registry → S3 sink connectors: schema checks · Provides schema contract validation for sink-side serialization.
- Kafka Connect → Debezium sources: runs · Executes the source connectors.
- Kafka Connect → S3 sink connectors: runs · Executes the archive sink connectors.
- Kafka KRaft → S3 sink connectors: consume · Sink connectors read topic data for archival.
- S3 sink connectors → AWS S3: archive · Writes partitioned Parquet files to S3.
- Data generator → PostgreSQL: loads · Creates synthetic OLTP activity to drive CDC.
- Validation suite → Debezium sources: verifies · Checks CDC path behavior and correctness.
- Validation suite → AWS S3: verifies · Confirms archival output and persistence.
- Resource monitor → kind cluster: measures · Captures resource usage for the constrained platform.
- Ingestion spec → Deploy script: guides · Documents implementation and deployment intent.
- Batch cluster → Spark operator: hosts · Runs Spark as batch execution substrate.
- Spark operator → Iceberg catalog: uses · Jobs rely on catalog configuration for table access.
- Spark operator → Snowflake setup: integrates · Supports warehouse connectivity and validation.
- AWS S3 → Spark operator: consumed by · Archived Parquet data is the input for batch analytics.
- Batch spec → Spark operator: guides · Documents batch-layer design and tasks.
- Speed spec → AWS S3: plans downstream · Specifies future realtime architecture around the data platform.
- Monitoring spec → Resource monitor: guides · Documents monitoring and operational boundaries.
