# rahul-dabholkar/uber-data-streaming-pipeline architecture

> Architecture diagram of the GitHub repository rahul-dabholkar/uber-data-streaming-pipeline, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rahul-dabholkar/uber-data-streaming-pipeline
- Repository: https://github.com/rahul-dabholkar/uber-data-streaming-pipeline

## Overview

#### Purpose and Entry Points
This repository implements an Uber ride ingestion and analytics pipeline: batch lookup/reference data plus simulated real-time rides are transformed through bronze, silver, and gold Delta Live Tables (DLT) layers. Primary operational entry points are the event simulator/sender at `scripts/connection.py`, ride-event generation in `scripts/data.py`, Azure Data Factory metadata at `config.json`, and the Databricks DLT transformation set under `databricks/uber-rides-ingestion-pipeline/transformations/`.

#### Batch Reference-Data Ingestion
Azure Data Factory uses metadata in `config.json` to iterate over lookup datasets and copy JSON from HTTP/GitHub sources into ADLS Gen2’s raw/bronze storage. The mappings are represented locally by files such as `data/map_cities.json`, `data/map_payment_methods.json`, and `data/map_vehicle_types.json`. These static datasets become the enrichment side of the downstream stream-static join.

#### Real-Time Event Production Boundary
The local Python producer generates ride confirmations and occasional mutable customer/driver/location attributes, then publishes them to Azure Event Hubs using OAuth/connection configuration. `scripts/data.py` owns synthetic event generation, `scripts/connection.py` is the sender entry point, and `scripts/send_force_ride.py` emits controlled update events for SCD validation. Event Hubs is the boundary between producer runtime and Spark streaming ingestion.

#### Bronze Streaming and Historical Consolidation
DLT reads Event Hub through Spark’s Kafka connector in `databricks/uber-rides-ingestion-pipeline/transformations/ingest.py`, persisting raw event payloads as `rides_raw`. `databricks/uber-rides-ingestion-pipeline/transformations/silver.py` parses/normalizes streamed payloads and combines them with historical ride input, represented by `data/bulk_rides.json`, into the unified streaming staging relation `stg_rides`. This preserves a single downstream ride flow spanning backfill and live events.

#### Silver Enrichment and Late-Event Handling
`databricks/uber-rides-ingestion-pipeline/transformations/silver-obt.sql` produces the silver operational/business transformation by joining streaming `stg_rides` with static lookup tables. It applies a three-minute watermark on `booking_timestamp`, defining the late-arrival tolerance and limiting streaming state. The silver output is the canonical enriched ride event source for dimensional and fact modeling.

#### Gold Model and Stateful Analytics
`databricks/uber-rides-ingestion-pipeline/transformations/model.py` builds the gold star schema. It applies DLT CDC semantics: Type 2 history to passenger, driver, and location dimensions; Type 1 overwrite semantics to payment, vehicle, booking, and fact-oriented entities. The same stage calculates hourly city metrics with a one-hour window and ten-minute watermark, covering fare, completion, and cancellation behavior.

#### Runtime, Storage, and Governance
Azure Data Factory orchestrates batch ingestion; ADLS Gen2 supplies raw persisted storage; Azure Event Hubs provides live transport; Azure Databricks runs Spark/DLT transformations. Delta tables and Unity Catalog provide managed medallion storage, pipeline lineage, and governance. Databricks notebooks `databricks/bronze-adls.ipynb` and `databricks/silver-obt.ipynb` support interactive ingestion and result validation rather than serving as the main pipeline definition.

Main entry points: [`databricks/uber-rides-ingestion-pipeline/transformations/model.py`](https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/databricks/uber-rides-ingestion-pipeline/transformations/model.py) (Gold model), [`scripts/connection.py`](https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/scripts/connection.py) (Event sender), [`databricks/uber-rides-ingestion-pipeline/transformations/silver.py`](https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/databricks/uber-rides-ingestion-pipeline/transformations/silver.py) (stg_rides), [`databricks/uber-rides-ingestion-pipeline/transformations/silver-obt.sql`](https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/databricks/uber-rides-ingestion-pipeline/transformations/silver-obt.sql) (Silver enrichment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sources["Sources"]
  node_lookup_sources["HTTP/GitHub lookup data<br/>external data"]
  node_lookup_mappings["Lookup mappings<br/>JSON mappings<br/>[map_cities.json]"]
  node_historical_rides["Historical rides<br/>JSON backfill<br/>[bulk_rides.json]"]
  node_event_generator["Ride event generator<br/>Python producer<br/>[data.py]"]
  node_event_sender["Event sender<br/>Python entry point<br/>[connection.py]"]
  node_scd_sender["Forced SCD events<br/>Python producer<br/>[send_force_ride.py]"]
end

subgraph group_azure["Azure ingestion"]
  node_adf_metadata["ADF metadata<br/>pipeline metadata<br/>[config.json]"]
  node_azure_data_factory{{"Azure Data Factory<br/>batch orchestrator"}}
  node_adls_raw[("ADLS raw storage<br/>bronze files")]
  node_event_hubs["Azure Event Hubs<br/>event transport"]
end

subgraph group_dlt["Databricks DLT"]
  node_bronze_ingest["Bronze event ingest<br/>DLT streaming ingest<br/>[ingest.py]"]
  node_rides_raw[("rides_raw<br/>bronze Delta table")]
  node_silver_staging["stg_rides<br/>DLT streaming stage<br/>[silver.py]"]
  node_silver_enrichment["Silver enrichment<br/>DLT SQL transform<br/>[silver-obt.sql]"]
  node_enriched_rides[("Enriched rides<br/>silver Delta table")]
end

subgraph group_gold["Gold analytics"]
  node_gold_model["Gold model<br/>DLT CDC model<br/>[model.py]"]
  node_star_schema[("Gold star schema<br/>Delta dimensions and facts")]
  node_hourly_metrics[("Hourly city metrics<br/>streaming aggregate")]
  node_unity_catalog{{"Unity Catalog<br/>governance and lineage"}}
end

node_lookup_sources -->|"reference JSON"| node_azure_data_factory
node_lookup_mappings -->|"dataset mappings"| node_azure_data_factory
node_adf_metadata -->|"drives iteration"| node_azure_data_factory
node_azure_data_factory -->|"copies lookup data"| node_adls_raw
node_event_generator -->|"ride and attribute events"| node_event_sender
node_scd_sender -->|"controlled updates"| node_event_sender
node_event_sender -->|"publishes"| node_event_hubs
node_event_hubs -->|"Kafka streaming read"| node_bronze_ingest
node_bronze_ingest -->|"raw payloads"| node_rides_raw
node_rides_raw -->|"parse and normalize"| node_silver_staging
node_historical_rides -->|"backfill input"| node_silver_staging
node_silver_staging -->|"unified ride stream"| node_silver_enrichment
node_adls_raw -->|"static lookup tables"| node_silver_enrichment
node_silver_enrichment -->|"canonical silver events"| node_enriched_rides
node_enriched_rides -->|"model input"| node_gold_model
node_gold_model -->|"CDC dimensions and facts"| node_star_schema
node_gold_model -->|"windowed aggregates"| node_hourly_metrics
node_rides_raw -.->|"managed lineage"| node_unity_catalog
node_enriched_rides -.->|"managed lineage"| node_unity_catalog
node_star_schema -.->|"governed tables"| node_unity_catalog
node_hourly_metrics -.->|"governed metrics"| node_unity_catalog

click node_lookup_mappings "https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/data/map_cities.json"
click node_historical_rides "https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/data/bulk_rides.json"
click node_event_generator "https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/scripts/data.py"
click node_event_sender "https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/scripts/connection.py"
click node_scd_sender "https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/scripts/send_force_ride.py"
click node_adf_metadata "https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/config.json"
click node_bronze_ingest "https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/databricks/uber-rides-ingestion-pipeline/transformations/ingest.py"
click node_silver_staging "https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/databricks/uber-rides-ingestion-pipeline/transformations/silver.py"
click node_silver_enrichment "https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/databricks/uber-rides-ingestion-pipeline/transformations/silver-obt.sql"
click node_gold_model "https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/databricks/uber-rides-ingestion-pipeline/transformations/model.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_lookup_sources,node_lookup_mappings,node_historical_rides,node_event_generator,node_event_sender,node_scd_sender toneBlue
class node_adf_metadata,node_azure_data_factory,node_adls_raw,node_event_hubs toneAmber
class node_bronze_ingest,node_rides_raw,node_silver_staging,node_silver_enrichment,node_enriched_rides toneMint
class node_gold_model,node_star_schema,node_hourly_metrics,node_unity_catalog toneRose
```

## Components

### Sources

- **HTTP/GitHub lookup data**: external data · Static city, payment, and vehicle reference sources.
- [Lookup mappings](https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/data/map_cities.json): JSON mappings · `data/map_cities.json`
- [Historical rides](https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/data/bulk_rides.json): JSON backfill · `data/bulk_rides.json`
- [Ride event generator](https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/scripts/data.py): Python producer · `scripts/data.py`
- [Event sender](https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/scripts/connection.py): Python entry point · `scripts/connection.py`
- [Forced SCD events](https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/scripts/send_force_ride.py): Python producer · `scripts/send_force_ride.py`

### Azure ingestion

- [ADF metadata](https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/config.json): pipeline metadata · `config.json`
- **Azure Data Factory**: batch orchestrator · Copies lookup JSON into raw storage.
- **ADLS raw storage**: bronze files
- **Azure Event Hubs**: event transport · Boundary between local producers and streaming ingestion.

### Databricks DLT

- [Bronze event ingest](https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/databricks/uber-rides-ingestion-pipeline/transformations/ingest.py): DLT streaming ingest · Reads Event Hubs through Spark Kafka connector. · `databricks/uber-rides-ingestion-pipeline/transformations/ingest.py`
- **rides_raw**: bronze Delta table · Raw live-event payloads.
- [stg_rides](https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/databricks/uber-rides-ingestion-pipeline/transformations/silver.py): DLT streaming stage · Normalizes live payloads and unifies backfill with streaming rides. · `databricks/uber-rides-ingestion-pipeline/transformations/silver.py`
- [Silver enrichment](https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/databricks/uber-rides-ingestion-pipeline/transformations/silver-obt.sql): DLT SQL transform · Stream-static join with a three-minute booking-time watermark. · `databricks/uber-rides-ingestion-pipeline/transformations/silver-obt.sql`
- **Enriched rides**: silver Delta table · Canonical enriched ride event source.

### Gold analytics

- [Gold model](https://github.com/rahul-dabholkar/uber-data-streaming-pipeline/blob/master/databricks/uber-rides-ingestion-pipeline/transformations/model.py): DLT CDC model · Builds Type 1/2 dimensions, facts, and city metrics. · `databricks/uber-rides-ingestion-pipeline/transformations/model.py`
- **Gold star schema**: Delta dimensions and facts · SCD2 passenger, driver, and location; Type 1 operational entities.
- **Hourly city metrics**: streaming aggregate · One-hour windows with a ten-minute watermark.
- **Unity Catalog**: governance and lineage · Governs managed Delta tables and pipeline lineage.

## Connections

- HTTP/GitHub lookup data → Azure Data Factory: reference JSON
- Lookup mappings → Azure Data Factory: dataset mappings
- ADF metadata → Azure Data Factory: drives iteration
- Azure Data Factory → ADLS raw storage: copies lookup data
- Ride event generator → Event sender: ride and attribute events
- Forced SCD events → Event sender: controlled updates
- Event sender → Azure Event Hubs: publishes
- Azure Event Hubs → Bronze event ingest: Kafka streaming read
- Bronze event ingest → rides_raw: raw payloads
- rides_raw → stg_rides: parse and normalize
- Historical rides → stg_rides: backfill input
- stg_rides → Silver enrichment: unified ride stream
- ADLS raw storage → Silver enrichment: static lookup tables
- Silver enrichment → Enriched rides: canonical silver events
- Enriched rides → Gold model: model input
- Gold model → Gold star schema: CDC dimensions and facts
- Gold model → Hourly city metrics: windowed aggregates
- rides_raw → Unity Catalog: managed lineage
- Enriched rides → Unity Catalog: managed lineage
- Gold star schema → Unity Catalog: governed tables
- Hourly city metrics → Unity Catalog: governed metrics
