A real-time order event processing and monitoring platform built using FastAPI, Apache Kafka, PySpark Structured Streaming, MySQL, and Power BI.
The system receives order events through a REST API, publishes them to Kafka, processes them using PySpark Structured Streaming, stores processed data in MySQL, and visualizes operational insights through a Power BI dashboard.
Client / Application
|
v
REST API (FastAPI)
|
v
Kafka Producer
|
v
Kafka Topic (orders-events)
|
v
PySpark Structured Streaming
|
+-----+-----+
| |
Validate Transform
| |
+-----+-----+
|
v
Aggregate Processed Data
|
v
MySQL Database
|
v
Power BI Dashboard
- Accepts order events through FastAPI REST endpoints
- Publishes events into Kafka topics
- Processes streaming data using PySpark Structured Streaming
PySpark performs:
- Data validation
- Data transformation
- Aggregation
- Streaming analytics
Processed order events are stored in MySQL for:
- Historical analysis
- Reporting
- Business intelligence
Power BI dashboard provides:
- Total orders monitoring
- Order status distribution
- Revenue analysis
- Order trends over time
| Component | Technology |
|---|---|
| API Layer | FastAPI |
| Messaging | Apache Kafka |
| Stream Processing | PySpark Structured Streaming |
| Database | MySQL |
| Visualization | Power BI |
| Containerization | Docker |
Applications send order events:
POST /orders
Example event:
{
"order_id": "ORD1001",
"customer_id": "C101",
"amount": 250,
"status": "COMPLETED"
}The FastAPI service publishes events to:
Topic:
orders-events
PySpark consumes Kafka events and performs:
- Validation
- Transformation
- Aggregation
Processed results are stored in MySQL tables.
Example:
orders
order_summary
Power BI connects to MySQL and displays:
- Order volume
- Order status
- Revenue metrics
- Streaming insights
Start Kafka and MySQL containers:
docker compose up -duvicorn main:app --reloadAPI runs on:
http://localhost:8000
spark-submit streaming_job.pyMySQL runs using Docker.
Connection:
Host: localhost
Port: 3307
Database: <database_name>
Power BI connects to MySQL:
MySQL Database
|
|
Power BI Desktop
Dashboard contains:
Displays total processed orders.
Donut chart showing:
- Completed
- Pending
- Failed
Line chart showing order activity over time.
Displays revenue generated from processed events.
kafka_realtime_ops_monitor/
├── fastapi/
│
├── kafka/
│
├── pyspark/
│
├── mysql/
│
├── powerbi/
│ ├── kafka_orders_dashboard.pbix
│ ├── screenshots/
│ └── README.md
│
└── README.md
- Add Kafka consumer lag monitoring
- Add Prometheus + Grafana metrics
- Add real-time Power BI streaming dataset
- Deploy using Kubernetes
- Add alerting for failed events
Vignesh Saravanan