A comprehensive data engineering solution demonstrating batch ETL, real-time streaming, data warehousing, and machine learning for Smart City IoT data processing
Problem Statement β’ Solution Architecture β’ Technical Implementation β’ Business Value
- Executive Summary
- The Problem
- The Solution
- Project Timeline & Milestones
- Solution Architecture
- Data Model Design
- Milestone 1: Batch ETL Data Warehouse
- Milestone 2A: Real-Time Streaming Pipeline
- Milestone 2B: ETL with Big Data Technologies
- Machine Learning Integration
- Business Use Cases
- Performance Metrics
- Technology Stack Summary
- Project Structure
- Team & Acknowledgments
- Future Enhancements
- Appendix: Detailed Data Catalog
The Smart City Data Engineering Project is a comprehensive graduation project that demonstrates enterprise-grade data engineering skills through the construction of a complete data platform for smart city operations. The project addresses the critical need for urban centers to collect, process, and analyze data from multiple city servicesβincluding energy, transportation, emergency services, traffic management, and waste collection.
| Metric | Value |
|---|---|
| Data Streams Processed | 5 major city services |
| Total Records Managed | 1,051,146+ records |
| Real-time Throughput | 125 events/second |
| ML Models Deployed | 5 production-ready models |
| Technologies Integrated | 15+ enterprise technologies |
| ETL Implementations | 3 distinct approaches (SQL, Python, Talend) |
| Container Services | 25+ Docker containers |
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#3498DB', 'primaryTextColor': '#ffffff', 'primaryBorderColor': '#2980B9', 'secondaryColor': '#E67E22', 'secondaryTextColor': '#000000', 'tertiaryColor': '#9B59B6', 'tertiaryTextColor': '#ffffff', 'lineColor': '#2C3E50', 'fontFamily': 'arial', 'fontSize': '14px'}}}%%
mindmap
root((Smart City<br/>Project))
Milestone 1
Batch ETL
Data Warehouse
Medallion Architecture
SQL/Python/Talend
Milestone 2A
Real-time Streaming
Apache Kafka
Spark Streaming
Machine Learning
Milestone 2B
Big Data ETL
Apache Hive
Trino Query Engine
Airflow Orchestration
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#1A252F', 'lineColor': '#3498DB', 'secondaryColor': '#E74C3C', 'tertiaryColor': '#27AE60'}}}%%
flowchart TB
subgraph ROOT["ποΈ SMART CITY PROJECT"]
direction TB
CENTER[Complete Data<br/>Engineering Solution]
end
subgraph M1["π· MILESTONE 1: Batch ETL"]
direction LR
M1A[π Data Warehouse]
M1B[π Medallion Architecture]
M1C[πΎ SQL / Python / Talend]
M1D[β° Airflow Orchestration]
end
subgraph M2A["π MILESTONE 2A: Real-Time"]
direction LR
M2A1[π‘ Apache Kafka]
M2A2[β‘ Spark Streaming]
M2A3[π€ Machine Learning]
M2A4[π HDFS Storage]
end
subgraph M2B["π£ MILESTONE 2B: Big Data"]
direction LR
M2B1[π Apache Hive]
M2B2[π Trino Queries]
M2B3[π Spark ETL]
M2B4[π Analytics Ready]
end
CENTER --> M1
CENTER --> M2A
CENTER --> M2B
style ROOT fill:#2C3E50,stroke:#1A252F,stroke-width:3px,color:#fff
style CENTER fill:#34495E,stroke:#2C3E50,stroke-width:2px,color:#fff
style M1 fill:#3498DB,stroke:#2980B9,stroke-width:2px,color:#fff
style M1A fill:#5DADE2,stroke:#3498DB,color:#000
style M1B fill:#5DADE2,stroke:#3498DB,color:#000
style M1C fill:#5DADE2,stroke:#3498DB,color:#000
style M1D fill:#5DADE2,stroke:#3498DB,color:#000
style M2A fill:#E67E22,stroke:#D35400,stroke-width:2px,color:#fff
style M2A1 fill:#F39C12,stroke:#E67E22,color:#000
style M2A2 fill:#F39C12,stroke:#E67E22,color:#000
style M2A3 fill:#F39C12,stroke:#E67E22,color:#000
style M2A4 fill:#F39C12,stroke:#E67E22,color:#000
style M2B fill:#9B59B6,stroke:#8E44AD,stroke-width:2px,color:#fff
style M2B1 fill:#BB8FCE,stroke:#9B59B6,color:#000
style M2B2 fill:#BB8FCE,stroke:#9B59B6,color:#000
style M2B3 fill:#BB8FCE,stroke:#9B59B6,color:#000
style M2B4 fill:#BB8FCE,stroke:#9B59B6,color:#000
Modern cities generate massive amounts of data from various sourcesβIoT sensors, GPS trackers, smart meters, and emergency dispatch systems. However, this data often exists in silos, making it impossible to derive actionable insights for city operations.
| Challenge | Impact | Current State |
|---|---|---|
| Data Silos | Each department operates independently | No unified data view |
| Manual Reporting | Decision-making is slow and reactive | Hours to generate reports |
| No Real-time Visibility | Emerging issues go undetected | Post-incident analysis only |
| Lack of Predictions | Resources poorly allocated | Reactive rather than proactive |
| Scalability Issues | Systems can't handle data growth | Performance degradation |
π Transportation Department
- Cannot track bus locations in real-time
- No way to predict passenger loads or delays
- Route optimization done manually
β‘ Energy & Utilities
- Building consumption monitored manually
- Peak demand causes grid stress
- No predictive maintenance for devices
π¨ Emergency Services
- Response time optimization guesswork
- Resource allocation based on historical averages
- No pattern detection for incident prevention
π Traffic Management
- Congestion detected only when severe
- Traffic signals operate on fixed schedules
- No predictive rerouting capabilities
ποΈ Waste Management
- Fixed collection schedules regardless of need
- Trucks visit half-empty containers
- Fuel and time wasted on inefficient routes
We designed and implemented a unified data platform that collects data from all city services, processes it through multiple pipelines (batch and real-time), stores it in an optimized data warehouse, and provides machine learning-powered predictions.
flowchart TB
subgraph "Data Sources"
E[β‘ Energy Meters]
T[π Traffic Sensors]
B[π Bus GPS]
W[ποΈ Waste Containers]
EM[π¨ Emergency Systems]
end
subgraph "Ingestion Layer"
BATCH[Batch ETL<br/>SQL/Python/Talend]
STREAM[Real-time Streaming<br/>Kafka + Spark]
end
subgraph "Storage Layer"
BRONZE[Bronze Layer<br/>Raw Data]
SILVER[Silver Layer<br/>Cleaned Data]
GOLD[Gold Layer<br/>Analytics Ready]
HDFS[HDFS<br/>Data Lake]
HIVE[Apache Hive<br/>Warehouse]
end
subgraph "Analytics Layer"
TRINO[Trino<br/>SQL Queries]
ML[Machine Learning<br/>5 Models]
DASH[Dashboards<br/>Visualization]
end
E & T & B & W & EM --> BATCH & STREAM
BATCH --> BRONZE --> SILVER --> GOLD
STREAM --> HDFS --> HIVE
GOLD & HIVE --> TRINO
GOLD & HIVE --> ML
TRINO & ML --> DASH
style BATCH fill:#E25A1C,color:#fff
style STREAM fill:#231F20,color:#fff
style GOLD fill:#FFD700,color:#000
style ML fill:#4CAF50,color:#fff
| Milestone | Focus | Technologies | Purpose |
|---|---|---|---|
| Milestone 1 | Batch ETL & Data Warehouse | SQL Server, Python, Talend, Airflow | Traditional enterprise DWH |
| Milestone 2A | Real-time Streaming | Kafka, Spark Streaming, HDFS | IoT data processing |
| Milestone 2B | Big Data Analytics | Spark, Hive, Trino | Scalable analytics queries |
gantt
title Smart City Project Timeline
dateFormat YYYY-MM
section Planning
Requirements Analysis :done, 2025-09, 2025-09
Architecture Design :done, 2025-09, 2025-10
Data Modeling :done, 2025-10, 2025-10
section Milestone 1
Database Schema Design :done, 2025-10, 2025-10
SQL ETL Development :done, 2025-10, 2025-10
Python ETL Development :done, 2025-10, 2025-10
Talend Jobs Creation :done, 2025-10, 2025-11
Airflow Integration :done, 2025-11, 2025-11
section Milestone 2A
Kafka Setup :done, 2025-11, 2025-11
Spark Streaming :done, 2025-11, 2025-11
HDFS Integration :done, 2025-11, 2025-11
ML Model Development :done, 2025-11, 2025-11
section Milestone 2B
Hive Warehouse Setup :done, 2025-11, 2025-11
Trino Configuration :done, 2025-11, 2025-11
Full Pipeline Integration :done, 2025-11, 2025-11
section Documentation
Technical Documentation :done, 2025-11, 2025-12
Project Presentation :active, 2025-12, 2025-12
- Complete Galaxy Schema data warehouse
- Three ETL implementations (SQL, Python, Talend)
- Airflow orchestration for Talend jobs
- SCD Type 2 for building dimension
- Comprehensive data generation scripts
- Apache Kafka with 5 topics
- Spark Streaming to HDFS
- 5 Machine Learning prediction models
- Airflow monitoring DAG
- 25+ container Docker infrastructure
- SQL Server to Hive ETL via Spark
- Trino SQL query engine
- 12-task Airflow DAG
- Complete containerized environment
- Production-ready rebuild scripts
graph TB
subgraph "Data Generation"
DS[π Data Generation Scripts<br/>Python-based simulators]
end
subgraph "Source Systems"
CSV[CSV Files<br/>12 datasets]
OLTP[(OLTP Database<br/>SmartCity)]
IOT[IoT Sensors<br/>Real-time]
end
subgraph "ETL Layer"
SQL_ETL[T-SQL Stored Procedures]
PY_ETL[Python/Pandas Pipeline]
TALEND[Talend Visual ETL]
SPARK_ETL[Spark ETL Jobs]
STREAM[Spark Streaming]
end
subgraph "Orchestration"
AIRFLOW[Apache Airflow<br/>DAG Management]
end
subgraph "Storage"
subgraph "Data Warehouse (SQL Server)"
BR[Bronze Layer]
SV[Silver Layer]
GD[Gold Layer]
end
subgraph "Data Lake (Hadoop)"
HDFS_RAW[HDFS Raw]
HIVE_DWH[(Hive Tables)]
end
end
subgraph "Query & Analytics"
TRINO[Trino SQL Engine]
JUPYTER[Jupyter Notebooks]
end
subgraph "Machine Learning"
ML1[Energy Prediction]
ML2[Traffic Prediction]
ML3[Bus Occupancy]
ML4[Waste Optimization]
ML5[Emergency Response]
end
DS --> CSV & OLTP
CSV --> SQL_ETL & PY_ETL & TALEND
OLTP --> SPARK_ETL
IOT --> STREAM
SQL_ETL & PY_ETL & TALEND --> BR --> SV --> GD
SPARK_ETL --> HIVE_DWH
STREAM --> HDFS_RAW --> HIVE_DWH
AIRFLOW -.orchestrates.-> SQL_ETL & TALEND & SPARK_ETL & STREAM
GD & HIVE_DWH --> TRINO
HDFS_RAW --> JUPYTER
JUPYTER --> ML1 & ML2 & ML3 & ML4 & ML5
style BR fill:#CD7F32,color:#fff
style SV fill:#C0C0C0,color:#000
style GD fill:#FFD700,color:#000
style AIRFLOW fill:#017CEE,color:#fff
style STREAM fill:#E25A1C,color:#fff
The project implements the Medallion Architecture pattern for data quality governance:
| Layer | Purpose | Data State | Tables |
|---|---|---|---|
| π₯ Bronze | Raw data ingestion | Unprocessed, as-is from source | 12 tables |
| π₯ Silver | Data cleansing | Cleaned, validated, deduplicated | 12 tables |
| π₯ Gold | Business-ready | Aggregated, dimensional model | 12 tables |
The final Gold layer uses a Galaxy Schema (constellation schema) with shared dimensions across multiple fact tables:
erDiagram
dim_calendar ||--o{ fact_traffic : "date_sk"
dim_calendar ||--o{ fact_energy_consumption : "date_sk"
dim_calendar ||--o{ fact_emergency_calls : "date_sk"
dim_calendar ||--o{ fact_bus_gps : "date_sk"
dim_calendar ||--o{ fact_waste_collection : "date_sk"
dim_zones ||--o{ fact_traffic : "zone_sk"
dim_zones ||--o{ fact_emergency_calls : "zone_sk"
dim_zones ||--o{ fact_bus_gps : "zone_sk"
dim_zones ||--o{ fact_waste_collection : "zone_sk"
dim_buildings ||--o{ fact_energy_consumption : "building_sk"
dim_buildings ||--o{ fact_emergency_calls : "building_sk"
dim_buildings ||--o{ fact_waste_collection : "building_sk"
dim_devices ||--o{ fact_energy_consumption : "device_sk"
dim_devices ||--o{ fact_traffic : "device_sk"
dim_bus_routes ||--o{ fact_bus_gps : "route_sk"
dim_trucks ||--o{ fact_waste_collection : "truck_sk"
dim_event_types ||--o{ fact_emergency_calls : "event_type_sk"
dim_calendar {
int date_sk PK
date date
int day
int month
int year
varchar week_day
}
dim_zones {
int zone_sk PK
varchar zone_id
varchar zone_name
}
dim_buildings {
int building_sk PK
varchar building_id
varchar building_name
varchar building_type
bit is_current
}
fact_traffic {
int date_sk FK
int zone_sk FK
int device_sk FK
int vehicle_count
decimal avg_speed_kmh
}
fact_energy_consumption {
int date_sk FK
int building_sk FK
int device_sk FK
decimal kwh
decimal voltage
}
| Table | Purpose | Key Fields | Special Features |
|---|---|---|---|
| dim_calendar | Date dimension for temporal analysis | date_sk, date, year, month, day, week_day | Conformed dimension |
| dim_buildings | Building information | building_sk, building_id, zone_id, type | SCD Type 2 (history tracking) |
| dim_devices | IoT device catalog | device_sk, device_id, device_type, status | Device metadata |
| dim_zones | City geographic zones | zone_sk, zone_id, zone_name | 6 city zones |
| dim_trucks | Waste collection vehicles | truck_sk, truck_id, capacity_tons | Fleet management |
| dim_bus_routes | Public transit routes | route_sk, route_id, distance_km | 10 routes |
| dim_event_types | Emergency event categories | event_type_sk, event_type_name | 7 event types |
| Table | Business Process | Measures | Grain |
|---|---|---|---|
| fact_traffic | Traffic monitoring | vehicle_count, avg_speed_kmh | Per sensor reading |
| fact_energy_consumption | Building energy | kwh, voltage, current | Per meter reading |
| fact_bus_gps | Bus tracking | speed_kmh, occupancy_est, lat, lon | Per GPS ping |
| fact_emergency_calls | 911 dispatch | response_time_minutes | Per call |
| fact_waste_collection | Waste pickup | fill_level_percent | Per container |
| Category | Table | Records |
|---|---|---|
| Dimensions | dim_buildings | 301 |
| dim_zones | 6 | |
| dim_bus_routes | 10 | |
| dim_calendar | 30 | |
| dim_devices | 602 | |
| dim_event_types | 7 | |
| dim_trucks | 16 | |
| Facts | fact_traffic | 110,000 |
| fact_bus_gps | 508,400 | |
| fact_energy_consumption | 432,000 | |
| fact_emergency_calls | 780 | |
| Total | 1,051,146 |
Milestone 1 demonstrates traditional data warehouse construction using multiple ETL technologies. The same data transformation logic is implemented three times to showcase different approaches:
graph LR
SOURCE[CSV Sources] --> CHOICE{ETL Choice}
CHOICE --> SQL[T-SQL Procedures]
CHOICE --> PYTHON[Python + Pandas]
CHOICE --> TALEND[Talend Open Studio]
SQL --> DWH[(SmartCityDWH)]
PYTHON --> DWH
TALEND --> DWH
AIRFLOW[Apache Airflow] -.orchestrates.-> TALEND
style SQL fill:#CC2927,color:#fff
style PYTHON fill:#3776AB,color:#fff
style TALEND fill:#FF6D00,color:#fff
style AIRFLOW fill:#017CEE,color:#fff
Location: Smart_City_Milestone_1/data_with_sql/
The T-SQL implementation uses stored procedures to move data through each layer:
-- Execution sequence
EXEC bronze.proc_load_bronze; -- Load raw data from CSV
EXEC silver.proc_load_silver; -- Clean and validate
EXEC gold.proc_load_gold; -- Build dimensional modelKey Features:
- Native SQL Server BULK INSERT for high performance
- Stored procedures for maintainability
- Transaction handling for data integrity
- Built-in error logging
Location: Smart_City_Milestone_1/data_with_python/
The Python implementation uses Pandas for data manipulation:
# Pipeline execution
python main.pyKey Features:
- Flexible data transformations with Pandas
- SQLAlchemy for database connectivity
- Configurable via .env file
- Comprehensive logging
Dependencies:
- pandas
- sqlalchemy
- pyodbc
- python-dotenv
Location: Smart_City_Milestone_1/data_with_talend/
Visual ETL using Talend Open Studio with comprehensive job orchestration:
Master Job Architecture:
Job Patterns:
| Pattern | Used For | Components |
|---|---|---|
| SCD Type 2 | dim_buildings | tDBInput β tMap β tDBSCD |
| Dimension Lookup | All fact tables | tDBInput β tMap (joins) β tDBOutput |
| Simple Load | Static dimensions | tDBInput β tMap β tDBOutput |
Location: Smart_City_Milestone_1/Smart_City_Airflow/
Apache Airflow manages the automated execution of Talend jobs:
DAG Configuration:
- Schedule: Daily at midnight
- Retry policy: 3 attempts with 5-minute delay
- Email alerts on failure
Milestone 2A implements a real-time streaming data pipeline for IoT sensor data with machine learning integration. This represents the modern approach to handling high-velocity data streams.
graph TB
subgraph "Data Sources"
IOT1[β‘ Energy Meters<br/>50 devices]
IOT2[π Traffic Sensors<br/>50 devices]
IOT3[π Bus GPS<br/>16 buses]
IOT4[ποΈ Waste Containers<br/>80 units]
IOT5[π¨ Emergency Dispatch]
end
subgraph "Ingestion"
PRODUCER[Python Data Producer<br/>kafka-python]
end
subgraph "Message Broker"
KAFKA[(Apache Kafka<br/>5 Topics Γ 3 Partitions)]
ZK[ZooKeeper<br/>Coordination]
end
subgraph "Stream Processing"
SPARK[Spark Streaming<br/>Structured Streaming API]
end
subgraph "Storage"
HDFS[(HDFS<br/>3Γ Replication<br/>Parquet Format)]
end
subgraph "Machine Learning"
ML[Spark MLlib<br/>5 Trained Models]
end
subgraph "Monitoring"
AIRFLOW[Airflow DAG<br/>Health Checks]
end
IOT1 & IOT2 & IOT3 & IOT4 & IOT5 --> PRODUCER
PRODUCER --> KAFKA
ZK -.-> KAFKA
KAFKA --> SPARK
SPARK --> HDFS
HDFS --> ML
AIRFLOW -.monitors.-> KAFKA & SPARK & HDFS
style KAFKA fill:#231F20,color:#fff
style SPARK fill:#E25A1C,color:#fff
style HDFS fill:#66CCFF,color:#000
style ML fill:#4CAF50,color:#fff
style AIRFLOW fill:#017CEE,color:#fff
| Topic | Data Type | Update Frequency | Message Size |
|---|---|---|---|
| energy | Smart meter readings | 25 events/2sec | ~150 bytes |
| traffic | Traffic sensor data | 25 events/2sec | ~120 bytes |
| bus_gps | Bus location tracking | 25 events/2sec | ~160 bytes |
| waste | Container fill levels | 25 events/2sec | ~140 bytes |
| emergency | 911 call data | 25 events/2sec | ~180 bytes |
Step 1: Data Producer
docker exec -d spark-master python3 /opt/scripts/data_producer.pyStep 2: Spark Streaming
docker exec spark-master spark-submit \
--packages org.apache.spark:spark-sql-kafka-0-10_2.12:3.0.1 \
/opt/scripts/stream_to_hdfs.py 60Step 3: ML Training
docker exec spark-notebook spark-submit \
--master local[*] \
/home/jovyan/ml_energy_prediction.py| Metric | Value |
|---|---|
| Event Ingestion Rate | 125 events/second |
| End-to-End Latency | < 2 seconds |
| Kafka Throughput | ~20 KB/sec |
| HDFS Write Speed | ~100 KB/min |
| Micro-batch Interval | 10 seconds |
Milestone 2B focuses on batch ETL from SQL Server to a Hive data warehouse using Apache Spark, with Trino as the SQL query engine for analytics.
flowchart LR
subgraph "Source"
SQL[(SQL Server 2022<br/>SmartCityDWH<br/>12 tables)]
end
subgraph "Processing"
SPARK[Apache Spark 3.3.0<br/>ETL Engine<br/>~4 min processing]
AIRFLOW[Apache Airflow 2.7.3<br/>Workflow Orchestrator<br/>12 tasks]
end
subgraph "Storage"
HDFS[(HDFS 3.3.5<br/>Distributed Storage<br/>3Γ Replication)]
HIVE[(Apache Hive 2.3.2<br/>Data Warehouse<br/>12 tables)]
end
subgraph "Query Layer"
TRINO[Trino 434<br/>SQL Query Engine<br/>Analytics]
end
SQL -->|JDBC Extract| SPARK
SPARK -->|Transform & Load| HIVE
HIVE -->|Parquet Format| HDFS
HIVE -->|Query Interface| TRINO
AIRFLOW -.orchestrates.-> SPARK
style SQL fill:#CC2927,color:#fff
style SPARK fill:#E25A1C,color:#fff
style HIVE fill:#FDEE21,color:#000
style TRINO fill:#DD00A1,color:#fff
style AIRFLOW fill:#017CEE,color:#fff
flowchart TB
A[wait_for_sqlserver<br/>Health Check] --> B[restore_dwh_backup<br/>Restore DB]
B --> C[verify_restore<br/>Validate Tables]
C --> D[wait_for_spark<br/>Check Spark]
C --> E[wait_for_hive<br/>Check Hive]
D --> F[setup_jdbc_driver<br/>Install Driver]
E --> G[create_hive_database<br/>Create DB]
F --> H[run_spark_etl<br/>β‘ Main ETL Job]
G --> H
H --> I[verify_hive_tables<br/>Validate Load]
I --> J[test_trino_queries<br/>Test Queries]
J --> K[generate_sample_report<br/>Create Report]
K --> L[pipeline_complete<br/>β
Done]
style A fill:#4FC3F7,color:#000
style B fill:#4FC3F7,color:#000
style H fill:#FF7043,color:#fff
style L fill:#66BB6A,color:#fff
# Navigate to project
cd Smart_City_Pipeline_2_Milestone_2
# Start infrastructure
docker compose up -d
# Wait for services
sleep 120
# Trigger DAG
docker exec -u airflow data-pipeline-compose-airflow-scheduler-1 \
airflow dags trigger smartcity_dwh_pipeline-- Traffic analysis by zone
SELECT
z.zone_name,
COUNT(*) as total_readings,
AVG(t.vehicle_count) as avg_vehicles,
AVG(t.avg_speed_kmh) as avg_speed
FROM hive.smartcity_dwh.fact_traffic t
JOIN hive.smartcity_dwh.dim_zones z ON t.zone_id = z.zone_id
GROUP BY z.zone_name
ORDER BY total_readings DESC;The project includes 5 production-ready machine learning models for smart city predictions:
graph LR
subgraph "Data Preparation"
RAW[Raw HDFS Data] --> LOAD[Load Parquet]
LOAD --> CLEAN[Clean & Filter]
CLEAN --> FEATURE[Feature Engineering]
end
subgraph "Models"
FEATURE --> M1[β‘ Energy Model]
FEATURE --> M2[π Traffic Model]
FEATURE --> M3[π Bus Model]
FEATURE --> M4[ποΈ Waste Model]
FEATURE --> M5[π¨ Emergency Model]
end
subgraph "Deployment"
M1 & M2 & M3 & M4 & M5 --> SAVE[Save to HDFS]
SAVE --> SERVE[Ready for Inference]
end
style M1 fill:#FF9800,color:#fff
style M2 fill:#4CAF50,color:#fff
style M3 fill:#2196F3,color:#fff
style M4 fill:#9C27B0,color:#fff
style M5 fill:#F44336,color:#fff
| Property | Value |
|---|---|
| Algorithm | Random Forest Regressor (100 trees) |
| Target | kWh consumption |
| Features | building_id, device_id, hour, voltage, current |
| Performance | RΒ² = 0.62, RMSE = 9.75 kWh |
| Use Cases | Peak demand prediction, anomaly detection |
Feature Importance:
- Hour (34%) - Time of day drives consumption
- Building ID (28%) - Building type correlates with usage
- Current (18%) - Real-time draw indicator
- Device ID (12%) - Device-specific patterns
- Voltage (8%) - Useful for anomaly detection
| Property | Value |
|---|---|
| Algorithm | GBT Regressor + RF Classifier |
| Target | Vehicle count, congestion level |
| Features | zone_id, hour, day_of_week, is_rush_hour |
| Performance | RMSE = 12.3 vehicles, Accuracy = 0.85 |
| Use Cases | Signal optimization, route planning |
Congestion Levels:
- π’ Light: < 50 vehicles
- π‘ Moderate: 50-100 vehicles
- π΄ Heavy: > 100 vehicles
| Property | Value |
|---|---|
| Algorithm | Random Forest + GBT |
| Target | Passenger occupancy, delay estimation |
| Features | route_id, zone_id, hour, speed_kmh |
| Performance | Occupancy RMSE = 8.5%, Delay RΒ² = 0.71 |
| Use Cases | Capacity planning, schedule optimization |
| Property | Value |
|---|---|
| Algorithm | Random Forest + Logistic Regression |
| Target | Fill level, collection need (binary) |
| Features | zone_id, building_id, hour, days_since_last |
| Performance | Fill Level RMSE = 14%, Classification = 0.89 |
| Use Cases | Route optimization, cost reduction |
| Property | Value |
|---|---|
| Algorithm | GBT Regressor + RF Classifier |
| Target | Response time, priority classification |
| Features | zone_id, event_type_id, hour, concurrent_calls |
| Performance | Response Time RMSE = 3.2 min, Priority = 0.87 |
| Use Cases | Resource allocation, dispatch optimization |
The data platform enables the following business capabilities:
| Use Case | Data Source | ML Model | Business Impact |
|---|---|---|---|
| Emergency Response Optimization | fact_emergency_calls | Emergency Model | 15-25% faster response |
| Resource Allocation | Event patterns by zone | Priority Classifier | Better coverage |
| Pattern Recognition | Historical incidents | Time-series analysis | Predictive deployment |
| Use Case | Data Source | ML Model | Business Impact |
|---|---|---|---|
| Route Optimization | fact_bus_gps | Bus Model | 20% efficiency gain |
| Capacity Planning | Occupancy predictions | Occupancy Model | Right-sized fleet |
| Schedule Adherence | Delay predictions | Delay Estimator | Improved on-time % |
| Use Case | Data Source | ML Model | Business Impact |
|---|---|---|---|
| Demand Forecasting | fact_energy_consumption | Energy Model | Peak shaving |
| Anomaly Detection | Voltage/current patterns | Threshold alerts | Preventive maintenance |
| Building Comparison | Consumption by type | Analytics queries | Efficiency programs |
Sample Insight:
- Malls: 299 kWh average consumption
- Residential: 3.25 kWh average consumption
- Commercial peak: 2-4 PM
| Use Case | Data Source | ML Model | Business Impact |
|---|---|---|---|
| Dynamic Routing | Container fill levels | Waste Model | 20-30% fuel savings |
| Collection Scheduling | Fill predictions | Collection Classifier | Optimal timing |
| Fleet Optimization | Truck utilization | Analytics | Right-sized fleet |
| Use Case | Data Source | ML Model | Business Impact |
|---|---|---|---|
| Congestion Detection | fact_traffic | Traffic Model | Early alerts |
| Signal Timing | Vehicle counts by zone | Optimization algorithm | Smoother flow |
| Road Planning | Historical patterns | Trend analysis | Infrastructure investment |
| Metric | Milestone 1 | Milestone 2A | Milestone 2B |
|---|---|---|---|
| ETL Duration | ~5 min | Real-time | ~4-6 min |
| Throughput | Batch | 125 events/sec | ~4,000 rec/sec |
| Data Volume | 1.05M records | Continuous | 1.05M records |
| Query Latency | < 1 sec | N/A | < 3 sec |
| Startup Time | N/A | ~2-3 min | ~2-3 min |
| Resource | Development | Production Recommended |
|---|---|---|
| RAM | 16 GB | 32+ GB |
| CPU | 4 cores | 8+ cores |
| Storage | 50 GB | 500+ GB |
| Network | Local | 10 Gbps+ |
graph LR
A[Current: 1M records] -->|Add Workers| B[5M records]
B -->|Add Kafka Brokers| C[50M records]
C -->|Kubernetes| D[500M+ records]
style A fill:#4CAF50,color:#fff
style D fill:#9C27B0,color:#fff
| Category | Technology | Version | Purpose |
|---|---|---|---|
| Databases | SQL Server | 2022 | Source OLTP & Batch DWH |
| Apache Hive | 2.3.2 | Big Data Warehouse | |
| PostgreSQL | 13 | Airflow Metadata | |
| Processing | Apache Spark | 3.3.0 | ETL & ML Engine |
| Python | 3.7+ | Scripting & ETL | |
| Talend | Open Studio | Visual ETL | |
| Streaming | Apache Kafka | 7.4.0 | Message Broker |
| ZooKeeper | 7.5.0 | Coordination | |
| Storage | Hadoop HDFS | 3.3.5 | Distributed Storage |
| Query | Trino | 434 | SQL Analytics |
| Orchestration | Apache Airflow | 2.7.3 | Workflow Management |
| Celery | Latest | Task Queue | |
| Redis | Latest | Message Backend | |
| Containers | Docker | 20.10+ | Virtualization |
| Docker Compose | 2.0+ | Multi-container | |
| ML | Spark MLlib | 3.3.0 | Machine Learning |
| Notebooks | Jupyter | Latest | Interactive Analysis |
Airflow: webserver, scheduler, worker, triggerer
Kafka: broker, zookeeper, schema-registry, ksqldb
Spark: master, worker-1, worker-2, notebook
Hadoop: namenode, datanode-1, datanode-2, datanode-3, resourcemanager, nodemanager
Hive: metastore, server
Trino: coordinator
Support: postgres, redis, sqlserver
DEPI/
βββ π Smart_City_Milestone_1/ # Batch ETL Data Warehouse
β βββ README.md # Milestone 1 overview
β βββ π data_with_python/ # Python ETL implementation
β β βββ main.py # Pipeline entry point
β β βββ requirements.txt # Dependencies
β β βββ *.py # ETL modules
β βββ π data_with_sql/ # T-SQL ETL implementation
β β βββ init_database.sql # Schema creation
β β βββ bronze/ # Bronze layer scripts
β β βββ silver/ # Silver layer scripts
β β βββ gold/ # Gold layer scripts
β βββ π data_with_talend/ # Talend DDL scripts
β βββ π datasets/ # Source data & generators
β β βββ generate_dimension_data.py # Dimension generator
β β βββ generate_fact_data.py # Fact generator
β β βββ silver_data/ # Generated CSVs
β βββ π Smart_City_Airflow/ # Airflow for Talend
β βββ π docs/ # Documentation & images
β βββ PROJECT_DOCUMENTATION.md # Detailed project docs
β βββ ARCHITECTURE.md # System architecture
β βββ meta_data_definition.md # Data catalog
β βββ data_flow.png # Architecture diagrams
β βββ *.md # ETL documentation
β
βββ π Smart_City_Pipeline_Milestone_2/ # Real-time Streaming
β βββ README.md # Milestone 2A overview
β βββ docker-compose.yml # Infrastructure
β βββ π scripts/ # Python scripts
β β βββ data_producer.py # IoT data simulator
β β βββ stream_to_hdfs.py # Kafka β HDFS
β β βββ ml_energy_prediction.py # Energy ML
β β βββ ml_traffic_prediction.py # Traffic ML
β β βββ ml_bus_prediction.py # Bus ML
β β βββ ml_waste_prediction.py # Waste ML
β β βββ ml_emergency_prediction.py # Emergency ML
β βββ π airflow/ # Monitoring DAG
β β βββ dags/smartcity_pipeline_dag.py
β βββ π docs/ # Documentation
β
βββ π Smart_City_Pipeline_2_Milestone_2/ # Big Data ETL
β βββ README.md # Milestone 2B overview
β βββ docker-compose.yml # Infrastructure
β βββ rebuild.sh # Automation script
β βββ π airflow/ # Pipeline DAG
β β βββ dags/smartcity_dwh_pipeline.py
β βββ π scripts/ # Spark ETL
β β βββ pyspark/smartcity_dwh_etl.py
β βββ π sql/ # SQL Server backup
β β βββ SmartCityDWH.bak
β βββ π trino/ # Trino config
β βββ π docs/ # Documentation
β
βββ π SMART_CITY_PROJECT_DOCUMENTATION.md # THIS FILE
Smart City Data Engineering Team
- DEPI Graduation Project, November 2025
This project leverages outstanding open-source technologies:
- Apache Software Foundation - Kafka, Spark, Airflow, Hadoop, Hive
- Trino Community - Trino SQL Engine
- Docker - Container technology
- Confluent - Kafka ecosystem (Schema Registry, ksqlDB)
- Microsoft - SQL Server
- Jupyter Project - Interactive notebooks
- Python Community - Libraries and frameworks
- Figma Board: Smart City Project on Figma
- Canva Design: Smart City Project on Canva
| Category | Enhancement | Priority |
|---|---|---|
| Cloud | Azure Data Factory / AWS Glue migration | High |
| Real-time | Enhanced Kafka Streams processing | High |
| ML | Model serving with MLflow | Medium |
| Visualization | Power BI / Tableau dashboards | Medium |
| Security | Data encryption & RBAC | High |
- βοΈ Cloud Migration: Azure/AWS implementations
- π Advanced Analytics: Complex KPIs and trend analysis
- π Geospatial Analysis: GIS integration and mapping
- π€ Deep Learning: Neural networks for predictions
- π External APIs: Weather, social media integration
- π± Mobile Dashboard: Real-time monitoring app
| Column | Type | Description |
|---|---|---|
| date_sk | INT | Primary Key. Surrogate key |
| date_key | INT | Natural key (YYYYMMDD) |
| date | DATE | Full date |
| day | INT | Day of month |
| month | INT | Month number |
| month_name | VARCHAR(20) | Month name |
| year | INT | Year |
| week_day | VARCHAR(20) | Day name |
| week_number | INT | Week of year |
| is_weekend | VARCHAR(5) | Weekend flag |
| Column | Type | Description |
|---|---|---|
| building_sk | INT | Primary Key. Surrogate key |
| building_id | VARCHAR(10) | Natural key |
| building_name | VARCHAR(100) | Building name |
| zone_id | VARCHAR(10) | Zone reference |
| building_type | VARCHAR(50) | Type (Residential, Commercial, etc.) |
| owner_name | VARCHAR(100) | Owner |
| address | VARCHAR(255) | Street address |
| lat | DECIMAL(9,6) | Latitude |
| lon | DECIMAL(9,6) | Longitude |
| status | VARCHAR(20) | Current status |
| valid_from | DATETIME | Record start date |
| valid_to | DATETIME | Record end date (NULL if current) |
| is_current | BIT | Current record flag |
| Column | Type | Description |
|---|---|---|
| date_sk | INT | FK to dim_calendar |
| building_sk | INT | FK to dim_buildings |
| device_sk | INT | FK to dim_devices |
| kwh | DECIMAL(10,4) | Energy consumed (kWh) |
| voltage | DECIMAL(7,2) | Voltage reading |
| current | DECIMAL(10,4) | Current reading |
| quality_flag | VARCHAR(10) | Data quality indicator |
| Column | Type | Description |
|---|---|---|
| date_sk | INT | FK to dim_calendar |
| zone_sk | INT | FK to dim_zones |
| device_sk | INT | FK to dim_devices |
| vehicle_count | INT | Vehicles detected |
| avg_speed_kmh | DECIMAL(5,2) | Average speed (km/h) |
| Column | Type | Description |
|---|---|---|
| date_sk | INT | FK to dim_calendar |
| route_sk | INT | FK to dim_bus_routes |
| zone_sk | INT | FK to dim_zones |
| bus_id | VARCHAR(10) | Degenerate dimension |
| lat | DECIMAL(9,6) | Latitude |
| lon | DECIMAL(9,6) | Longitude |
| speed_kmh | DECIMAL(5,2) | Speed (km/h) |
| occupancy_est | INT | Passenger count |
Smart City Data Engineering Graduation Project
DEPI Program | November 2025
This document consolidates all project milestones, technical implementations, and business outcomes into a comprehensive reference for the Smart City Data Engineering Graduation Project.
Last Updated: February 1, 2026



