A global logistics company wants to opmitizr it's supply chain by analyzing shipping, inventory and demand data in real-time, the solution is a data pipeline that extracts data from various sources and ensure timely devlivery.
- Kafka (Data Ingestion)
- Apache Flink (Stream Processing)
- Apache Airflow (Batch Processing)
- GCP BigQuery (Data Storage)
- Power BI/Tableau (Visualization)
- Start Kafka:
bin/zookeeper-server-start.sh config/zookeeper.properties & bin/kafka-server-start.sh config/server.properties - Run Kafka Producer:
python kafka_producer.py - Run Kafka Consumer:
python kafka_consumer.py - Start Flink Job:
python flink_processing.py - Run Airflow DAG:
airflow dags trigger supply_chain_batch_processing - Execute Predictive Model:
python predictive_model.py
- Reduced supply chain delays by 20%
- Improved customer satisfaction
Clone the repository to your local machine: git clone
Install the required dependencies using pip:
pip install -r requirements.txt
Set up Apache Kafka on your local machine or use a cloud Kafka service. If using local Kafka, ensure that the broker is running on localhost:9092.
To deploy the entire system in containers using Docker, build and run the Docker container:
docker-compose up --build
This will start the Kafka producer, consumer, and other components of the pipeline.
- Kafka Producer: Simulates real-time transaction data.
- Kafka Consumer: Ingests transaction data and sends it to Spark for processing.
- Spark Fraud Detection: Streams and processes transactions, applying fraud detection logic.
- TensorFlow Model: Classifies transactions as fraudulent or legitimate.
- AWS Lambda: Sends alerts for suspicious transactions.
- DBT: Transforms and models data in the pipeline.
To test the fraud detection pipeline:
- Run the Kafka producer to simulate transaction data.
- Start the Kafka consumer to consume the data.
- Check the Spark streaming console output to view fraud detections.
- If a fraudulent transaction is detected, the AWS Lambda function will trigger an alert to the configured phone number.
