This project simulates a real-time flight tracking system (similar to AirRadar 2024) using a modern data engineering pipeline.
It generates fake flight events, streams them through Kafka, processes with Spark, stores in PostgreSQL, and visualizes with Streamlit.
- Python (Faker) → Generate fake flight data (Producer)
- Kafka → Message broker for real-time streaming
- Spark (Structured Streaming) → Process and transform flight events
- Postgres → Store flight data
- Streamlit → Interactive dashboard to visualize flight positions & statuses
- Docker Compose → Containerized setup for all services
-
Start the environment
docker-compose up -d
-
Check containers
docker ps
-
Run the data producer
- Open the
script/producer.ipynbnotebook in Anaconda environment - Run it to generate fake flights data and send events to Kafka topic
flights.
- Open the
-
Verify Kafka topic
- Open Kafka UI in your browser at http://localhost:8090
- Check that topic
flightsis receiving messages
-
Check PostgreSQL
- Open pgAdmin at http://localhost:8085
- Login with:
- Email:
admin@admin.com - Password:
admin
- Email:
-
Create PostgreSQL Connection
- In pgAdmin, create a new server connection:
- Name:
postgres_general - Host:
postgres - Port:
5432 - Username:
admin - Password:
admin
- Name:
- In pgAdmin, create a new server connection:
-
Create Database
- Open Query Tool in pgAdmin and run:
CREATE DATABASE flights_project;
- Open Query Tool in pgAdmin and run:
-
Create Flights Table
- Connect to the
flights_projectdatabase and run:CREATE TABLE flights ( flight_id VARCHAR PRIMARY KEY, origin TEXT, destination TEXT, status TEXT, departure_time BIGINT, arrival_time BIGINT );
- Connect to the
-
Run Spark Script
- Open the
scriptsfolder and copy the Spark script into a Jupyter Notebook. - Access Jupyter at http://localhost:8888.
- Before running the script, install PostgreSQL driver:
pip install psycopg2-binary
- Run the notebook and confirm that records are being inserted into PostgreSQL.
- Open the
-
View Dashboard
- Open the Streamlit app at http://localhost:8501
- Explore the real-time flights map and flight statuses.
[ Python Producer (Faker) ]
↓
Kafka Topic: flights
↓
Spark Structured Streaming
↓
PostgreSQL
↓
Streamlit Dashboard
{
"flight_id": "FL1001",
"origin": [40.6413, -73.7781],
"destination": [51.4700, -0.4543],
"status": "On Time",
"departure_time": 1695638400,
"arrival_time": 1695645600
}To stop and remove containers, volumes, and networks:
docker-compose down -v- Kafka topic:
flights - Postgres DB: flights_project
- Streamlit UI shows flight map with status colors (On Time / Delayed / Cancelled).
- All services are containerized and orchestrated via Docker Compose.