# wbatchayon/data_stream_flow architecture

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

- Interactive diagram: https://gitdiagram.com/wbatchayon/data_stream_flow
- Repository: https://github.com/wbatchayon/data_stream_flow

## Overview

Data Stream Flow is an Airflow-orchestrated data pipeline, with a Flask API for triggering and checking pipeline runs. The documented path covers remote CSV ingestion and validation, Pandas/Spark processing, streaming and generated records, then object storage and search indexing. Kafka, MinIO, Elasticsearch, Prometheus, and Grafana are external services or integrations. The DAG excerpt and source index establish its module wiring; unsampled DAG sections limit certainty about task ordering. Monitoring is documented and represented in the tree, but its runtime wiring is not shown.

Main entry points: [`src/dags/data_pipeline_dag.py`](https://github.com/wbatchayon/data_stream_flow/blob/main/src/dags/data_pipeline_dag.py) (Pipeline DAG), [`src/scripts/process/process_with_pandas_and_spark.py`](https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/process/process_with_pandas_and_spark.py) (Pandas And Spark), [`src/scripts/stream/spark_streaming_2.py`](https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/stream/spark_streaming_2.py) (Kafka Stream Consumer), [`src/scripts/storage/store_to_minio.py`](https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/storage/store_to_minio.py) (MinIO Storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Pipeline Interface"]
  node_api["Trigger API<br/>[api.py]"]
end

subgraph group_orchestration["Orchestration"]
  node_airflow["Airflow Service"]
  node_dag["Pipeline DAG"]
end

subgraph group_dataflow["Data Pipeline Stages"]
  node_ingest["CSV Ingestion<br/>[load_remote_csv.py]"]
  node_process["Pandas And Spark"]
  node_stream_prep["CSV Stream Prep"]
  node_generator["Data Generator"]
end

subgraph group_integrations["Storage And Streaming"]
  node_producer["Kafka Publisher"]
  node_spark_consumer["Kafka Stream Consumer"]
  node_minio_writer["MinIO Storage<br/>[store_to_minio.py]"]
  node_search_writer["Elasticsearch Indexer"]
end

subgraph group_observability["Monitoring"]
  node_prometheus_config["Prometheus Setup<br/>[prometheus.yml]"]
  node_grafana_config["Grafana Setup"]
end

node_user(("Pipeline Operator"))
node_kafka["Kafka"]
node_minio[("MinIO Object Store")]
node_elasticsearch[("Elasticsearch")]
node_prometheus["Prometheus"]
node_grafana["Grafana"]

node_user -->|"triggers or checks"| node_api
node_api -->|"calls REST API"| node_airflow
node_dag -->|"runs as DAG"| node_airflow
node_dag -->|"invokes ingestion"| node_ingest
node_dag -->|"invokes processing"| node_process
node_dag -->|"invokes stream prep"| node_stream_prep
node_dag -->|"invokes generator"| node_generator
node_dag -->|"invokes publisher"| node_producer
node_dag -->|"invokes consumer"| node_spark_consumer
node_dag -->|"invokes storage"| node_minio_writer
node_dag -->|"invokes indexing"| node_search_writer
node_ingest -.->|"CSV input"| node_process
node_process -.->|"processed CSV"| node_stream_prep
node_process -.->|"processed CSV"| node_generator
node_producer -->|"publishes records"| node_kafka
node_kafka -->|"provides topic stream"| node_spark_consumer
node_spark_consumer -.->|"writes output files"| node_minio_writer
node_minio_writer -->|"uploads objects"| node_minio
node_search_writer -->|"indexes documents"| node_elasticsearch
node_prometheus_config -.->|"configures"| node_prometheus
node_grafana_config -.->|"configures"| node_grafana

click node_api "https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/api/api.py"
click node_dag "https://github.com/wbatchayon/data_stream_flow/blob/main/src/dags/data_pipeline_dag.py"
click node_ingest "https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/ingest/load_remote_csv.py"
click node_process "https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/process/process_with_pandas_and_spark.py"
click node_stream_prep "https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/stream/spark_streaming_1.py"
click node_generator "https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/stream/python_data_generator.py"
click node_producer "https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/stream/publish_to_kafka.py"
click node_spark_consumer "https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/stream/spark_streaming_2.py"
click node_minio_writer "https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/storage/store_to_minio.py"
click node_search_writer "https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/storage/index_to_elasticsearch.py"
click node_prometheus_config "https://github.com/wbatchayon/data_stream_flow/blob/main/monitoring/prometheus.yml"
click node_grafana_config "https://github.com/wbatchayon/data_stream_flow/tree/main/monitoring/grafana"

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_api toneBlue
class node_airflow,node_dag,node_minio,node_elasticsearch toneAmber
class node_ingest,node_process,node_stream_prep,node_generator toneMint
class node_producer,node_spark_consumer,node_minio_writer,node_search_writer toneRose
class node_prometheus_config,node_grafana_config,node_user,node_kafka,node_prometheus,node_grafana toneIndigo
```

## Components

### Pipeline Interface

- [Trigger API](https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/api/api.py): `src/scripts/api/api.py`

### Orchestration

- **Airflow Service**
- [Pipeline DAG](https://github.com/wbatchayon/data_stream_flow/blob/main/src/dags/data_pipeline_dag.py): `src/dags/data_pipeline_dag.py`

### Data Pipeline Stages

- [CSV Ingestion](https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/ingest/load_remote_csv.py): `src/scripts/ingest/load_remote_csv.py`
- [Pandas And Spark](https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/process/process_with_pandas_and_spark.py): `src/scripts/process/process_with_pandas_and_spark.py`
- [CSV Stream Prep](https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/stream/spark_streaming_1.py): `src/scripts/stream/spark_streaming_1.py`
- [Data Generator](https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/stream/python_data_generator.py): `src/scripts/stream/python_data_generator.py`

### Storage And Streaming

- [Kafka Publisher](https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/stream/publish_to_kafka.py): `src/scripts/stream/publish_to_kafka.py`
- [Kafka Stream Consumer](https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/stream/spark_streaming_2.py): `src/scripts/stream/spark_streaming_2.py`
- [MinIO Storage](https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/storage/store_to_minio.py): `src/scripts/storage/store_to_minio.py`
- [Elasticsearch Indexer](https://github.com/wbatchayon/data_stream_flow/blob/main/src/scripts/storage/index_to_elasticsearch.py): `src/scripts/storage/index_to_elasticsearch.py`

### Monitoring

- [Prometheus Setup](https://github.com/wbatchayon/data_stream_flow/blob/main/monitoring/prometheus.yml): `monitoring/prometheus.yml`
- [Grafana Setup](https://github.com/wbatchayon/data_stream_flow/tree/main/monitoring/grafana): `monitoring/grafana`

### Other components

- **Pipeline Operator**
- **Kafka**
- **MinIO Object Store**
- **Elasticsearch**
- **Prometheus**
- **Grafana**

## Connections

- Pipeline Operator → Trigger API: triggers or checks (evidence: `src/scripts/api/api.py`)
- Trigger API → Airflow Service: calls REST API (evidence: `src/scripts/api/api.py`)
- Pipeline DAG → Airflow Service: runs as DAG (evidence: `src/dags/data_pipeline_dag.py`)
- Pipeline DAG → CSV Ingestion: invokes ingestion (evidence: `src/dags/data_pipeline_dag.py`)
- Pipeline DAG → Pandas And Spark: invokes processing (evidence: `src/dags/data_pipeline_dag.py`)
- Pipeline DAG → CSV Stream Prep: invokes stream prep (evidence: `src/dags/data_pipeline_dag.py`)
- Pipeline DAG → Data Generator: invokes generator (evidence: `src/dags/data_pipeline_dag.py`)
- Pipeline DAG → Kafka Publisher: invokes publisher (evidence: `src/dags/data_pipeline_dag.py`)
- Pipeline DAG → Kafka Stream Consumer: invokes consumer (evidence: `src/dags/data_pipeline_dag.py`)
- Pipeline DAG → MinIO Storage: invokes storage (evidence: `src/dags/data_pipeline_dag.py`)
- Pipeline DAG → Elasticsearch Indexer: invokes indexing (evidence: `src/dags/data_pipeline_dag.py`)
- CSV Ingestion → Pandas And Spark: CSV input
- Pandas And Spark → CSV Stream Prep: processed CSV
- Pandas And Spark → Data Generator: processed CSV
- Kafka Publisher → Kafka: publishes records (evidence: `src/scripts/stream/publish_to_kafka.py`)
- Kafka → Kafka Stream Consumer: provides topic stream (evidence: `src/scripts/stream/spark_streaming_2.py`)
- Kafka Stream Consumer → MinIO Storage: writes output files
- MinIO Storage → MinIO Object Store: uploads objects (evidence: `src/scripts/storage/store_to_minio.py`)
- Elasticsearch Indexer → Elasticsearch: indexes documents (evidence: `src/scripts/storage/index_to_elasticsearch.py`)
- Prometheus Setup → Prometheus: configures
- Grafana Setup → Grafana: configures
