# chirag876/bigquery-cross-environment-etl-pipeline architecture

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

- Interactive diagram: https://gitdiagram.com/chirag876/bigquery-cross-environment-etl-pipeline
- Repository: https://github.com/chirag876/bigquery-cross-environment-etl-pipeline

## Overview

This is a serverless cross-environment billing ETL service. A Pub/Sub HTTP delivery is decoded and validated, then the job retrieves organization configuration and its incremental checkpoint from MySQL, accesses the client BigQuery environment through service-account impersonation, extracts and transforms billing rows, and loads them into an isolated internal BigQuery destination. MySQL also records run status and configuration updates. The excerpts show the HTTP entry point, persistence helpers, credential/client utilities, and parts of the ETL and dataset-provisioning code; some ETL call details are documented only in the README.

Main entry points: [`BigQuery Cross-Environment Billing ETL Pipeline/core/services/billing_etl.py`](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/services/billing_etl.py) (ETL orchestrator), [`BigQuery Cross-Environment Billing ETL Pipeline/main.py`](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/main.py) (HTTP entry point), [`BigQuery Cross-Environment Billing ETL Pipeline/core/utility/dataset_utils.py`](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/utility/dataset_utils.py) (Destination provisioning), [`BigQuery Cross-Environment Billing ETL Pipeline/core/database/billing_etl_db.py`](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/database/billing_etl_db.py) (Org configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["Trigger and validation"]
  node_entry["HTTP entry point<br/>[main.py]"]
  node_payload["Payload validation"]
end

subgraph group_orchestration["ETL processing"]
  node_job["ETL orchestrator<br/>[billing_etl.py]"]
  node_checkpoint["Incremental checkpoint<br/>[billing_etl_db.py]"]
  node_extract["Billing extraction<br/>[billing_etl.py]"]
  node_transform["Billing transformation<br/>[billing_etl.py]"]
  node_load["Batch loading<br/>[billing_etl.py]"]
  node_logger["Structured logging<br/>[logger.py]"]
end

subgraph group_cloud_data["Data and access"]
  node_provision["Destination provisioning<br/>[dataset_utils.py]"]
  node_bq_client["BigQuery client<br/>[client.py]"]
  node_credentials["Impersonated credentials<br/>[sa_utils.py]"]
end

subgraph group_persistence["Configuration and audit"]
  node_config["Org configuration<br/>[billing_etl_db.py]"]
  node_db_access["MySQL access<br/>[database_class.py]"]
  node_audit["Run audit status<br/>[billing_etl_db.py]"]
end

node_pubsub(("Pub/Sub"))
node_mysql[("MySQL")]
node_client_bq[("Client BigQuery")]
node_internal_bq[("Internal BigQuery")]

node_pubsub -->|"delivers HTTP"| node_entry
node_entry -->|"validates payload"| node_payload
node_entry -->|"dispatches job"| node_job
node_job -->|"fetches configuration"| node_config
node_config -->|"executes queries"| node_db_access
node_db_access -->|"reads and writes"| node_mysql
node_job -->|"reads checkpoint"| node_checkpoint
node_job -->|"creates destination"| node_provision
node_provision -->|"uses client"| node_bq_client
node_bq_client -->|"requests credentials"| node_credentials
node_provision -->|"updates dataset config"| node_config
node_job -->|"extracts batches"| node_extract
node_extract -->|"queries billing data"| node_client_bq
node_credentials -->|"authorizes access"| node_client_bq
node_job -->|"transforms rows"| node_transform
node_job -->|"loads batches"| node_load
node_load -->|"writes rows"| node_internal_bq
node_job -->|"records run status"| node_audit
node_audit -->|"executes queries"| node_db_access
node_entry -->|"logs requests"| node_logger
node_job -->|"logs ETL events"| node_logger

click node_entry "https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/main.py"
click node_payload "https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/models/billing_etl_model.py"
click node_job "https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/services/billing_etl.py"
click node_config "https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/database/billing_etl_db.py"
click node_db_access "https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/database/database_class.py"
click node_checkpoint "https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/database/billing_etl_db.py"
click node_provision "https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/utility/dataset_utils.py"
click node_bq_client "https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/bigquery/client.py"
click node_credentials "https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/utility/sa_utils.py"
click node_extract "https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/services/billing_etl.py"
click node_transform "https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/services/billing_etl.py"
click node_load "https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/services/billing_etl.py"
click node_audit "https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/database/billing_etl_db.py"
click node_logger "https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/utility/logger.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_entry,node_payload toneBlue
class node_job,node_checkpoint,node_extract,node_transform,node_load,node_logger,node_mysql,node_client_bq,node_internal_bq toneAmber
class node_provision,node_bq_client,node_credentials toneMint
class node_config,node_db_access,node_audit toneRose
class node_pubsub toneIndigo
```

## Components

### Trigger and validation

- [HTTP entry point](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/main.py): `BigQuery Cross-Environment Billing ETL Pipeline/main.py`
- [Payload validation](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/models/billing_etl_model.py): `BigQuery Cross-Environment Billing ETL Pipeline/core/models/billing_etl_model.py`

### ETL processing

- [ETL orchestrator](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/services/billing_etl.py): `BigQuery Cross-Environment Billing ETL Pipeline/core/services/billing_etl.py`
- [Incremental checkpoint](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/database/billing_etl_db.py): `BigQuery Cross-Environment Billing ETL Pipeline/core/database/billing_etl_db.py`
- [Billing extraction](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/services/billing_etl.py): `BigQuery Cross-Environment Billing ETL Pipeline/core/services/billing_etl.py`
- [Billing transformation](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/services/billing_etl.py): `BigQuery Cross-Environment Billing ETL Pipeline/core/services/billing_etl.py`
- [Batch loading](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/services/billing_etl.py): `BigQuery Cross-Environment Billing ETL Pipeline/core/services/billing_etl.py`
- [Structured logging](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/utility/logger.py): `BigQuery Cross-Environment Billing ETL Pipeline/core/utility/logger.py`

### Data and access

- [Destination provisioning](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/utility/dataset_utils.py): `BigQuery Cross-Environment Billing ETL Pipeline/core/utility/dataset_utils.py`
- [BigQuery client](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/bigquery/client.py): `BigQuery Cross-Environment Billing ETL Pipeline/core/bigquery/client.py`
- [Impersonated credentials](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/utility/sa_utils.py): `BigQuery Cross-Environment Billing ETL Pipeline/core/utility/sa_utils.py`

### Configuration and audit

- [Org configuration](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/database/billing_etl_db.py): `BigQuery Cross-Environment Billing ETL Pipeline/core/database/billing_etl_db.py`
- [MySQL access](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/database/database_class.py): `BigQuery Cross-Environment Billing ETL Pipeline/core/database/database_class.py`
- [Run audit status](https://github.com/chirag876/bigquery-cross-environment-etl-pipeline/blob/main/BigQuery%20Cross-Environment%20Billing%20ETL%20Pipeline/core/database/billing_etl_db.py): `BigQuery Cross-Environment Billing ETL Pipeline/core/database/billing_etl_db.py`

### Other components

- **Pub/Sub**
- **MySQL**
- **Client BigQuery**
- **Internal BigQuery**

## Connections

- Pub/Sub → HTTP entry point: delivers HTTP (evidence: `README.md`)
- HTTP entry point → Payload validation: validates payload (evidence: `BigQuery Cross-Environment Billing ETL Pipeline/main.py`)
- HTTP entry point → ETL orchestrator: dispatches job (evidence: `BigQuery Cross-Environment Billing ETL Pipeline/main.py`)
- ETL orchestrator → Org configuration: fetches configuration (evidence: `README.md`)
- Org configuration → MySQL access: executes queries (evidence: `BigQuery Cross-Environment Billing ETL Pipeline/core/database/billing_etl_db.py`)
- MySQL access → MySQL: reads and writes (evidence: `BigQuery Cross-Environment Billing ETL Pipeline/core/database/database_class.py`)
- ETL orchestrator → Incremental checkpoint: reads checkpoint (evidence: `README.md`)
- ETL orchestrator → Destination provisioning: creates destination (evidence: `BigQuery Cross-Environment Billing ETL Pipeline/core/services/billing_etl.py`)
- Destination provisioning → BigQuery client: uses client (evidence: `BigQuery Cross-Environment Billing ETL Pipeline/core/utility/dataset_utils.py`)
- BigQuery client → Impersonated credentials: requests credentials (evidence: `BigQuery Cross-Environment Billing ETL Pipeline/core/bigquery/client.py`)
- Destination provisioning → Org configuration: updates dataset config (evidence: `BigQuery Cross-Environment Billing ETL Pipeline/core/utility/dataset_utils.py`)
- ETL orchestrator → Billing extraction: extracts batches (evidence: `README.md`)
- Billing extraction → Client BigQuery: queries billing data (evidence: `README.md`)
- Impersonated credentials → Client BigQuery: authorizes access (evidence: `README.md`)
- ETL orchestrator → Billing transformation: transforms rows (evidence: `README.md`)
- ETL orchestrator → Batch loading: loads batches (evidence: `README.md`)
- Batch loading → Internal BigQuery: writes rows (evidence: `README.md`)
- ETL orchestrator → Run audit status: records run status (evidence: `README.md`)
- Run audit status → MySQL access: executes queries (evidence: `BigQuery Cross-Environment Billing ETL Pipeline/core/database/billing_etl_db.py`)
- HTTP entry point → Structured logging: logs requests (evidence: `BigQuery Cross-Environment Billing ETL Pipeline/main.py`)
- ETL orchestrator → Structured logging: logs ETL events (evidence: `BigQuery Cross-Environment Billing ETL Pipeline/core/services/billing_etl.py`)
