All projects

Smart City Real-Time Data Engineering Pipeline

Click an image to zoom.

Overview

This project demonstrates an end-to-end Streaming Data Engineering Pipeline that simulates a smart city environment and processes vehicle, GPS, traffic, weather, and emergency data using Apache Kafka and Spark Structured Streaming. A Python generator produces the simulated data for five sources and publishes it to separate Kafka topics. Spark consumes the streams, processes the records, and writes them as Parquet files to Amazon S3. The datasets are then cataloged with AWS Glue Data Catalog and queried through Amazon Athena, where SQL CTAS queries build curated analytical summary tables. Finally, the curated tables are connected to an interactive Power BI dashboard through Athena. The streaming and messaging components run locally using Docker Compose with controlled memory limits, while storage, cataloging, and querying run on AWS.

Key Features

  • End-to-End Streaming Pipeline: Built a complete pipeline from simulated data generation to streaming ingestion, cloud storage, SQL analytics, and Power BI reporting.
  • Multi-Source Data Simulation: Used Python to generate five types of smart city data: vehicle, GPS, traffic observations, weather conditions, and emergency incidents.
  • Kafka Topic-Based Ingestion: Published each data source to its own Kafka topic, keeping the streams separated and independently consumable.
  • Spark Structured Streaming: Consumed the Kafka topics with Apache Spark Structured Streaming and processed the incoming records in real time.
  • S3 Data Lake: Stored the processed streaming data in Parquet format on Amazon S3 for efficient, columnar analytical queries.
  • Data Cataloging: Registered the datasets in the AWS Glue Data Catalog so they could be queried directly as tables in the smartcity database.
  • Serverless SQL Analytics: Used Amazon Athena to query the data lake without managing any query infrastructure.
  • Curated Analytics Layer: Built five curated summary tables using Athena CTAS queries, written back to S3 as Parquet: vehicle summary, GPS summary, traffic summary, weather summary, and emergency summary.
  • Aggregated Metrics: Calculated average and maximum vehicle speed, hourly traffic observations by location and camera, hourly weather averages (temperature, humidity, pressure, wind speed, visibility, UV index), and emergency incidents by type and status.
  • Power BI Dashboard: Connected Power BI to Athena to visualize speed over time, traffic observations, weather trends, emergency incidents by status, and summary KPIs.
  • Dockerized Environment: Ran Zookeeper, Kafka, and a Spark master/worker cluster locally with Docker Compose, using per-service memory limits and heap settings to fit a resource-constrained machine.
  • Reproducible SQL: Kept all Athena CTAS queries in a versioned SQL file, making the curated layer easy to rebuild and review.