A production-grade, end-to-end real-time data streaming and analytics pipeline built on Microsoft Fabric β simulating live e-commerce order data from ingestion to interactive Power BI dashboards.
Architecture β’ Tech Stack β’ Pipeline Layers β’ Getting Started β’ Project Structure
This project implements a complete real-time streaming data pipeline for e-commerce insights and sales forecasting. Fake order data is continuously generated using Python and streamed via Apache Kafka into Microsoft Fabric Eventstream, where it flows through a Medallion Architecture (Bronze β Silver β Gold) before being served to a live Power BI dashboard.
The entire workflow is orchestrated by a Fabric Pipeline that can be scheduled or triggered on demand.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DATA GENERATION β
β β
β Python + Faker + Kafka Producer β
β βββ Simulates real-time e-commerce orders (order_id, customer, β
β product, price, quantity, city, state, delivery_status ...) β
βββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββ
β Kafka Topic
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MICROSOFT FABRIC EVENTSTREAM β
β β
β Source: Kafka Connection β
β Destination: Lakehouse (lh_ecommerce_orders) β
β βββ Streams data into Tables/dbo/stream_data (Delta format) β
βββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MICROSOFT FABRIC LAKEHOUSE β MEDALLION ARCHITECTURE β
β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β BRONZE βββββΆβ SILVER βββββΆβ GOLD β β
β β β β β β β β
β β Raw ingestedβ β Cleaned & β β Aggregated β β
β β orders with β β enriched β β sales per β β
β β metadata β β USA orders β β state/minuteβ β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β bronze.orders silver.orders gold.orders β
βββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FABRIC WAREHOUSE (wh_ecommerce_orders) β
β β
β dbo.gold_orders β MERGE from lh_ecommerce_orders.gold.orders β
β (Upsert: insert new rows, update existing aggregations) β
βββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SEMANTIC MODEL β POWER BI DASHBOARD β
β β
β Real-time visuals: Sales by State, Orders by Category, β
β Revenue Trends, Delivery Status breakdown β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β²
β Orchestrated by
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FABRIC PIPELINE (pl_ecommerce_orders) β
β β
β stream_orders_to_bronze β cleaned_values_to_silver β β
β aggregated_to_gold β warehouse_script β
β β
β β
Schedulable β
Monitored β
Retriable β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Layer | Technology |
|---|---|
| Data Simulation | Python, Faker, kafka-python |
| Message Broker | Apache Kafka |
| Ingestion | Microsoft Fabric Eventstream |
| Storage | Microsoft Fabric Lakehouse (OneLake / Delta Lake) |
| Processing | PySpark (Structured Streaming) |
| Warehousing | Microsoft Fabric Warehouse (T-SQL) |
| Orchestration | Microsoft Fabric Pipeline |
| Semantic Layer | Microsoft Fabric Semantic Model |
| Visualization | Power BI (Real-time Dashboard) |
Generates realistic fake e-commerce orders continuously and publishes them to a Kafka topic.
# Key libraries
from faker import Faker
from kafka import KafkaProducer
# Simulated fields per order
{
"order_id": uuid,
"timestamp": datetime,
"customer_id": uuid,
"product_id": uuid,
"category": ["Electronics", "Clothing", "Books", "Toys", "Home Decor"],
"price": float,
"quantity": int,
"total_amount": float,
"city": str,
"state": str,
"country": str,
"latitude": float,
"longitude": float,
"delivery_status": ["Processing", "Shipped", "Delivered", "Cancelled"]
}Microsoft Fabric Eventstream connects the Kafka topic as a source and the Lakehouse as a destination, writing incoming events directly into Tables/dbo/stream_data as a Delta table in real time.
Reads from the live stream table and appends raw data to bronze.orders with added metadata columns.
df_orders = (
df_raw
.withColumn("ingested_at", current_timestamp())
.withColumn("source", lit("eventstream"))
)
query = (
df_orders.writeStream
.format("delta")
.outputMode("append")
.option("checkpointLocation", bronze_checkpoint)
.trigger(availableNow=True)
.toTable("bronze.orders")
)
query.awaitTermination()Cleans, validates and enriches the bronze data β filtering for USA orders, handling nulls, removing duplicates and computing total_amount.
df_clean = (
df_bronze
.withColumn("timestamp", to_timestamp("timestamp"))
.withWatermark("timestamp", "1 minute")
.withColumn("price", when(col("price").isNull(), 0.0).otherwise(col("price")))
.withColumn("quantity", when(col("quantity").isNull(), 1 ).otherwise(col("quantity")))
.withColumn("total_amount", col("price") * col("quantity"))
.dropDuplicates(["order_id", "timestamp"])
.filter(col("country") == "USA")
.filter(col("state").isNotNull())
)Aggregates silver data into 1-minute tumbling windows per state β total sales revenue and total items sold.
df_gold = (
df_silver
.withWatermark("timestamp", "1 minute")
.groupBy(window("timestamp", "1 minute"), "state")
.agg(
sum("total_amount").alias("total_sales"),
sum("quantity").alias("total_items")
)
.select(
col("window.start").alias("window_start"),
col("window.end").alias("window_end"),
"state", "total_sales", "total_items"
)
)Note: Uses
outputMode("complete")since windowed aggregations require it.
Syncs the gold layer into the Fabric Warehouse using an upsert (MERGE) β updating existing time-window records and inserting new ones.
MERGE dbo.gold_orders AS target
USING (SELECT * FROM lh_ecommerce_orders.gold.orders) AS source
ON (
target.window_start = source.window_start AND
target.window_end = source.window_end AND
target.state = source.state
)
WHEN MATCHED THEN
UPDATE SET
target.total_sales = source.total_sales,
target.total_items = source.total_items
WHEN NOT MATCHED BY TARGET THEN
INSERT (window_start, window_end, state, total_sales, total_items)
VALUES (source.window_start, source.window_end, source.state,
source.total_sales, source.total_items);The pipeline pl_ecommerce_orders runs all four steps in sequence:
stream_orders_to_bronze
β
cleaned_values_to_silver
β
aggregated_to_gold
β
warehouse_script
β Can be manually triggered or scheduled β Full run monitoring via Fabric Monitoring Hub β Each activity shows duration, input, output and error details
A Fabric Semantic Model connects to wh_ecommerce_orders and feeds a Power BI report with:
- π Total sales revenue by state
- π¦ Orders by product category
- π Revenue trend over time windows
- π Delivery status breakdown
- πΊοΈ Geographic sales map
ecommerce-realtime-pipeline/
β
βββ simulator/
β βββ get_orders.py # Fake order data generator (Faker + Kafka)
β
βββ images/
β βββ architecture.png
β
βββ notebooks/
β βββ stream_orders_to_bronze.ipynb # Bronze layer ingestion
β βββ cleaned_values_to_silver.ipynb # Silver layer cleaning
β βββ aggregated_to_gold.ipynb # Gold layer aggregation
β
βββ warehouse/
β βββ warehouse_script.sql # MERGE script for Fabric Warehouse
β
βββ pipeline/
β βββ pl_ecommerce_orders.json # Fabric Pipeline definition (exported)
β
βββ powerbi/
β βββ ecommerce_orders_report.pbix
β
βββ .env
βββ .gitignore
β
βββ README.md
- Microsoft Fabric workspace (with Lakehouse, Warehouse, Eventstream, Pipeline enabled)
- Apache Kafka cluster (local or cloud)
- Python 3.10+
pip install kafka-python fakerpython producer/kafka_producer.py- Create an Eventstream in your Fabric workspace
- Add Kafka as the source (point to your topic)
- Add Lakehouse (
lh_ecommerce_orders) as the destination - Activate the Eventstream β data will land in
Tables/dbo/stream_data
- Create Lakehouse:
lh_ecommerce_orders - Create Warehouse:
wh_ecommerce_orders - Add the Lakehouse as a linked source inside the Warehouse
Upload the three notebooks to your Fabric workspace and attach them to lh_ecommerce_orders as the default Lakehouse.
Create a Fabric Pipeline pl_ecommerce_orders with these activities in order:
| Order | Activity | Type |
|---|---|---|
| 1 | stream_orders_to_bronze | Notebook |
| 2 | cleaned_values_to_silver | Notebook |
| 3 | aggregated_to_gold | Notebook |
| 4 | warehouse_script | Warehouse Script |
- Create a Semantic Model pointing to
wh_ecommerce_orders - Open Power BI Desktop or Fabric Power BI
- Build your dashboard on top of
dbo.gold_orders
| Decision | Reason |
|---|---|
trigger(availableNow=True) + awaitTermination() |
Processes all available data then stops β safe for pipeline chaining |
| Checkpoints on every layer | Prevents reprocessing old data on pipeline reruns |
outputMode("complete") on Gold |
Required for windowed groupBy aggregations in Spark Structured Streaming |
| MERGE in Warehouse | Upserts gold data safely β no duplicates, no data loss |
| Medallion Architecture | Separates raw, clean and aggregated concerns for maintainability |
Kafka Producer
β 1 order/second (configurable)
β Fabric Eventstream
β Lakehouse: dbo.stream_data (raw Delta)
β Bronze: bronze.orders (+ metadata)
β Silver: silver.orders (cleaned, USA only)
β Gold: gold.orders (1-min window aggregations by state)
β Warehouse: dbo.gold_orders (upserted)
β Power BI: Live dashboard
Pratik Salunkhe Built with Microsoft Fabric, PySpark, Apache Kafka and Power BI.
β If you found this project helpful, give it a star!


