A comprehensive, real-time data engineering pipeline simulating a music streaming platform's analytics.
This project simulates user listening behavior and pipes the data through an end-to-end modern data stack:
- EventSim: Generates simulated JSON user interactions (plays, skips, signups).
- Kafka: Captures streaming events as the primary message broker.
- PySpark (Structured Streaming): Consumes Kafka topics, parses the data, and writes to Data Lake in Parquet format.
- MinIO: Acts as the S3-compatible Object Storage (Data Lake).
- ClickHouse: High-performance OLAP database connecting directly to our MinIO S3 bucket.
- DBT (Data Build Tool): Applies transformations (ELT) inside ClickHouse to build staging schemas and data marts.
- Apache Airflow: Orchestrates the manual Spark jobs, DBT models, and manages pipeline dependencies.
~ (Home Directory)
βββ eventsim_project/ # Main project repository
β βββ airflow/ # Airflow DAGs and configurations
β βββ dbt/ # DBT models and macros for transformations
β βββ kafka/ # Custom scripts for Kafka automation
β βββ scripts/ # Shell scripts to manage services (start, stop, etc.)
β βββ setup/ # Setup guides for each service (.md files)
β βββ spark_streaming/ # PySpark structured streaming scripts
β βββ docker-compose.yaml # Docker Compose configuration for all services
β βββ README.md # Project documentation
βββ eventsim/ # EventSim (Data Generator) repository clone
βββ kafka_2.13-3.6.1/ # Kafka installation binaries & properties
βββ minio # MinIO server executable binary
βββ MinIO/
βββ minio_data/ # MinIO Data Lake storage (Parquet files)
Note: ClickHouse is installed system-wide (Global installation), which usually places executables in /usr/bin/clickhouse and data in /var/lib/clickhouse/.
If you are deploying this for the first time, or need to rebuild a component, please refer to the detailed, step-by-step installation guides in the setup/ directory:
To spin up the entire pipeline, make sure you have granted execution p instances in the following order:
-
Setup Virtual Environment (If you haven't already):
python3 -m venv ~/eventsim_project/venv source ~/eventsim_project/venv/bin/activate pip install -r ~/eventsim_project/requirements.txt
-
Start Kafka & Zookeeper (Depends on your local installation):
python3 ~/eventsim_project/kafka/run_kafka.py -
Create the Kafka Topic (Only needed the first time): Grant execution permission to the script:
chmod +x ~/eventsim_project/scripts/*.sh
Run the script:
~/eventsim_project/scripts/create_kafka_topic.sh -
Start the Data Stream:
~/eventsim_project/scripts/run_eventsim_local.shTurn on Kafka consumer to check the data stream:
~/eventsim_project/scripts/run_kafka_consumer_local.sh -
Start the Data Lake:
~/eventsim_project/scripts/run_minio.sh -
Start Spark Processor: Delete checkpoint folder (eventsim_project/checkpoints) and bucket music-events (MinIO Console) manually, then run this script
~/eventsim_project/scripts/run_spark.shTurn on browser, go to http://localhost:9051/login, user: minioadmin, password: minioadmin

-
Start Analytics Database:
~/eventsim_project/scripts/run_clickhouse.shImportant: Initialize the tables manually when running locally by executing the SQL script:
clickhouse-client --queries-file ~/eventsim_project/scripts/clickhouse_init_local.sql~/eventsim_project/scripts/clickhouse_client.sh -
Orchestrate Transformations:
~/eventsim_project/scripts/run_airflow.shThen open the Airflow Web UI to trigger the DAG manually:
- Go to http://localhost:8080 and log in (username:
admin, password:admin) - Find the DAG named
music_events_pipelinein the list - Click the toggle on the left to unpause it (if it's grey/off)
- Click the βΆ Trigger DAG button (play icon on the right) to run it manually
- Click on the DAG name to monitor the progress of each task in the Graph view

- Go to http://localhost:8080 and log in (username:
-
Run app to check the result:
~/eventsim_project/scripts/run_app.sh
This approach runs all infrastructure services (Kafka, MinIO, Spark, ClickHouse, Airflow) inside Docker, while EventSim is run manually from your local machine to push data into the Dockerized Kafka.
- Docker Desktop is running
- All scripts have execution permission:
chmod +x ~/eventsim_project/scripts/*.sh
-
Start all infrastructure services (Kafka, MinIO, Spark, ClickHouse, Airflow):
cd ~/eventsim_project docker compose up -d
Wait ~30 seconds for all services to initialize.
-
Verify services are healthy:
docker compose ps
All containers should show status
runningorexited (0)for init containers. -
Start the EventSim data stream (runs on local machine, pushes to Docker Kafka on port 29092):
~/eventsim_project/scripts/run_eventsim_docker.shOpen additional terminals and run the same script to increase data throughput.
-
Verify data is reaching Kafka (optional check):
~/eventsim_project/scripts/run_kafka_consumer_docker.shYou should see JSON events streaming in. Press
Ctrl+Cto stop. -
Monitor Spark writing to MinIO:
- Open MinIO Console: http://localhost:9051 (user:
minioadmin, pass:minioadmin) - Navigate to bucket
music-eventsβ folderdata/ - Parquet files should appear within 1β2 minutes of EventSim running.
- Open MinIO Console: http://localhost:9051 (user:
-
Trigger the Airflow DAG:
- Open Airflow UI: http://localhost:8080 (user:
admin, pass:admin) - Find DAG
music_events_pipelineβ unpause it β click βΆ Trigger DAG
- Open Airflow UI: http://localhost:8080 (user:
-
View the results:
- Open the Streamlit app: http://localhost:8501
- Or run it locally:
~/eventsim_project/scripts/run_app.sh
docker compose downTo also remove all data volumes (clean slate):
docker compose down -v


