# ojaswip2828/etl_pipeline_tests architecture

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

- Interactive diagram: https://gitdiagram.com/ojaswip2828/etl_pipeline_tests
- Repository: https://github.com/ojaswip2828/etl_pipeline_tests

## Overview

This is a real-time transaction ETL pipeline. The producer creates transaction events and publishes them to Kafka; the consumer batches messages, decodes and validates them, normalises valid events, then writes raw, rejected, clean and aggregated data to PostgreSQL. It commits Kafka offsets only after the database write succeeds, enabling harmless replay through idempotent loads. The graph also shows runtime configuration and reporting. The load implementation was not excerpted, so its internal SQL relationships are included only where the README documents them.

Main entry points: [`etl_pipeline/consumer.py`](https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/consumer.py) (Batch consumer), [`etl_pipeline/pipeline.py`](https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/pipeline.py) (Batch orchestration), [`etl_pipeline/db.py`](https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/db.py) (Database setup), [`etl_pipeline/report.py`](https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/report.py) (Run reporting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Event ingestion"]
  node_producer["Event producer<br/>[producer.py]"]
  node_kafka["Kafka topic"]
  node_consumer["Batch consumer<br/>[consumer.py]"]
end

subgraph group_processing["Batch processing"]
  node_extract["Message decoding<br/>[extract.py]"]
  node_pipeline["Batch orchestration<br/>[pipeline.py]"]
  node_quality["Quality checks<br/>[quality.py]"]
  node_transform["Transaction cleaning<br/>[transform.py]"]
end

subgraph group_storage["Persistence"]
  node_loader["Layered batch loading<br/>[load.py]"]
  node_postgres[("PostgreSQL layers")]
  node_schema["Table definitions<br/>[schema.sql]"]
  node_db["Database setup<br/>[db.py]"]
end

subgraph group_operations["Runtime and reporting"]
  node_config["Runtime settings<br/>[config.py]"]
  node_report["Run reporting<br/>[report.py]"]
end

node_producer -->|"publishes events"| node_kafka
node_kafka -->|"supplies batches"| node_consumer
node_consumer -->|"processes batch"| node_pipeline
node_pipeline -->|"decodes records"| node_extract
node_pipeline -->|"validates and dedupes"| node_quality
node_pipeline -->|"cleans valid events"| node_transform
node_consumer -->|"writes batch"| node_loader
node_loader -->|"upserts layers"| node_postgres
node_consumer -->|"commits offsets"| node_kafka
node_consumer -->|"connects and initializes"| node_db
node_db -->|"executes definitions"| node_schema
node_db -->|"opens connection"| node_postgres
node_report -->|"opens connection"| node_db
node_report -->|"queries layers"| node_postgres
node_producer -->|"reads settings"| node_config
node_consumer -->|"reads settings"| node_config
node_report -->|"reads settings"| node_config

click node_producer "https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/producer.py"
click node_consumer "https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/consumer.py"
click node_extract "https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/extract.py"
click node_pipeline "https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/pipeline.py"
click node_quality "https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/quality.py"
click node_transform "https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/transform.py"
click node_loader "https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/load.py"
click node_schema "https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/schema.sql"
click node_db "https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/db.py"
click node_config "https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/config.py"
click node_report "https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/report.py"

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_producer,node_kafka,node_consumer toneBlue
class node_extract,node_pipeline,node_quality,node_transform toneAmber
class node_loader,node_postgres,node_schema,node_db toneMint
class node_config,node_report toneRose
```

## Components

### Event ingestion

- [Event producer](https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/producer.py): `etl_pipeline/producer.py`
- **Kafka topic**
- [Batch consumer](https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/consumer.py): `etl_pipeline/consumer.py`

### Batch processing

- [Message decoding](https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/extract.py): `etl_pipeline/extract.py`
- [Batch orchestration](https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/pipeline.py): `etl_pipeline/pipeline.py`
- [Quality checks](https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/quality.py): `etl_pipeline/quality.py`
- [Transaction cleaning](https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/transform.py): `etl_pipeline/transform.py`

### Persistence

- [Layered batch loading](https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/load.py): `etl_pipeline/load.py`
- **PostgreSQL layers**
- [Table definitions](https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/schema.sql): `etl_pipeline/schema.sql`
- [Database setup](https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/db.py): `etl_pipeline/db.py`

### Runtime and reporting

- [Runtime settings](https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/config.py): `etl_pipeline/config.py`
- [Run reporting](https://github.com/ojaswip2828/etl_pipeline_tests/blob/main/etl_pipeline/report.py): `etl_pipeline/report.py`

## Connections

- Event producer → Kafka topic: publishes events (evidence: `etl_pipeline/producer.py`)
- Kafka topic → Batch consumer: supplies batches (evidence: `README.md`)
- Batch consumer → Batch orchestration: processes batch (evidence: `etl_pipeline/consumer.py`)
- Batch orchestration → Message decoding: decodes records (evidence: `etl_pipeline/pipeline.py`)
- Batch orchestration → Quality checks: validates and dedupes (evidence: `etl_pipeline/pipeline.py`)
- Batch orchestration → Transaction cleaning: cleans valid events (evidence: `etl_pipeline/pipeline.py`)
- Batch consumer → Layered batch loading: writes batch (evidence: `etl_pipeline/consumer.py`)
- Layered batch loading → PostgreSQL layers: upserts layers (evidence: `README.md`)
- Batch consumer → Kafka topic: commits offsets (evidence: `etl_pipeline/consumer.py`)
- Batch consumer → Database setup: connects and initializes (evidence: `etl_pipeline/consumer.py`)
- Database setup → Table definitions: executes definitions (evidence: `etl_pipeline/db.py`)
- Database setup → PostgreSQL layers: opens connection (evidence: `etl_pipeline/db.py`)
- Run reporting → Database setup: opens connection (evidence: `etl_pipeline/report.py`)
- Run reporting → PostgreSQL layers: queries layers (evidence: `etl_pipeline/report.py`)
- Event producer → Runtime settings: reads settings (evidence: `etl_pipeline/producer.py`)
- Batch consumer → Runtime settings: reads settings (evidence: `etl_pipeline/consumer.py`)
- Run reporting → Runtime settings: reads settings (evidence: `etl_pipeline/report.py`)
