This repository contains a fully integrated, production-ready data pipeline that supports both batch and streaming data processing using open-source technologies. It is designed to be easily configured and deployed by any business or individual with minimal modifications.
The pipeline incorporates:
-
Data Ingestion:
- Batch Sources: SQL databases (MySQL, PostgreSQL), Data Lakes (MinIO as an S3-compatible store), files (CSV, JSON, XML)
- Streaming Sources: Kafka for event logs, IoT sensor data, and social media streams
-
Data Processing & Transformation:
- Batch Processing: Apache Spark for large-scale ETL jobs, integrated with Great Expectations for data quality checks
- Streaming Processing: Spark Structured Streaming for real-time data processing and anomaly detection
-
Data Storage:
- Raw Data: Stored in MinIO (S3-compatible storage)
- Processed Data: Loaded into PostgreSQL for analytics and reporting
-
Data Quality, Monitoring & Governance:
- Data Quality: Great Expectations validates incoming data
- Data Governance: Apache Atlas / OpenMetadata integration (lineage registration)
- Monitoring & Logging: Prometheus and Grafana for system monitoring and alerting
-
Data Serving & AI/ML Integration:
- ML Pipelines: MLflow for model tracking and feature store integration
- BI & Dashboarding: Grafana dashboards provide real-time insights
-
CI/CD & Deployment:
- CI/CD Pipelines: GitHub Actions or Jenkins for continuous integration and deployment
- Container Orchestration: Kubernetes with Argo CD for GitOps deployment
Read this README and follow the step-by-step guide to set up the pipeline on your local machine or cloud environment. Customize the pipeline components, configurations, and example applications to suit your data processing needs.
- Architecture Overview
- Directory Structure
- Components & Technologies
- Setup Instructions
- Configuration & Customization
- Example Applications
- Troubleshooting & Further Considerations
- Contributing
- License
- Final Notes
The architecture of the end-to-end data pipeline is designed to handle both batch and streaming data processing. Below is a high-level overview of the components and their interactions:
Note: The diagram may not reflect ALL components in the repository, but it provides a good overview of the main components and their interactions. For instance, I added BI tools like Tableau, Power BI, and Looker to the repo for data visualization and reporting.
ββββββββββββββββββββββββββββββββββ
β Batch Source β
β(MySQL, Files, User Interaction)β
ββββββββββββββββββ¬ββββββββββββββββ
β
β (Extract/Validate)
βΌ
βββββββββββββββββββββββββββββββββββββββ
β Airflow Batch DAG β
β - Extracts data from MySQL β
β - Validates with Great Expectations β
β - Uploads raw data to MinIO β
βββββββββββββββββββ¬ββββββββββββββββββββ
β (spark-submit)
βΌ
ββββββββββββββββββββββββββββββββββ
β Spark Batch Job β
β - Reads raw CSV from MinIO β
β - Transforms, cleans, enriches β
β - Writes transformed data to β
β PostgreSQL & MinIO β
ββββββββββββββββ¬ββββββββββββββββββ
β (Load/Analyze)
βΌ
ββββββββββββββββββββββββββββββββββ
β Processed Data Store β
β (PostgreSQL, MongoDB, AWS S3) β
βββββββββββββββββ¬βββββββββββββββββ
β (Query/Analyze)
βΌ
ββββββββββββββββββββββββββββββββββ
β Cache & Indexing β
β (Elasticsearch, Redis) β
ββββββββββββββββββββββββββββββββββ
Streaming Side:
βββββββββββββββββββββββββββββββ
β Streaming Source β
β (Kafka) β
ββββββββββββββ¬βββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββ
β Spark Streaming Job β
β - Consumes Kafka messages β
β - Filters and detects anomalies β
β - Persists anomalies to β
β PostgreSQL & MinIO β
βββββββββββββββββββββββββββββββββββββ
Monitoring & Governance:
ββββββββββββββββββββββββββββββββββ
β Monitoring & β
β Data Governance Layer β
β - Prometheus & Grafana β
β - Apache Atlas / OpenMetadata β
ββββββββββββββββββββββββββββββββββ
ML & Serving:
ββββββββββββββββββββββββββββββββ
β AI/ML Serving β
β - Feature Store (Feast) β
β - MLflow Model Tracking β
β - Model training & serving β
β - BI Dashboards β
ββββββββββββββββββββββββββββββββ
CI/CD & Terraform:
ββββββββββββββββββββββββββββββββ
β CI/CD Pipelines β
β - GitHub Actions / Jenkins β
β - Terraform for Cloud Deploy β
ββββββββββββββββββββββββββββββββ
Container Orchestration:
ββββββββββββββββββββββββββββββββ
β Kubernetes Cluster β
β - Argo CD for GitOps β
β - Helm Charts for Deployment β
ββββββββββββββββββββββββββββββββ
A more detailed flow diagram that includes backend and frontend integration is available in the assets/
directory. This diagram illustrates how the data pipeline components interact with each other and with external systems, including data sources, storage, processing, visualization, and monitoring.
Although the frontend & backend integration is not included in this repository (since it's supposed to only contain the pipeline), you can easily integrate it with your existing frontend application or create a new one using popular frameworks like React, Angular, or Vue.js.
end-to-end-pipeline/
βββ .devcontainer/ # VS Code Dev Container settings
βββ docker-compose.yaml # Docker orchestration for all services
βββ docker-compose.ci.yaml # Docker Compose for CI/CD pipelines
βββ End_to_End_Data_Pipeline.ipynb # Jupyter notebook for pipeline overview
βββ requirements.txt # Python dependencies for scripts
βββ .gitignore # Standard Git ignore file
βββ README.md # Comprehensive documentation (this file)
βββ airflow/
β βββ Dockerfile # Custom Airflow image with dependencies
β βββ requirements.txt # Python dependencies for Airflow
β βββ dags/
β βββ batch_ingestion_dag.py # Batch pipeline DAG
β βββ streaming_monitoring_dag.py # Streaming monitoring DAG
βββ spark/
β βββ Dockerfile # Custom Spark image with Kafka and S3 support
β βββ spark_batch_job.py # Spark batch ETL job
β βββ spark_streaming_job.py # Spark streaming job
βββ kafka/
β βββ producer.py # Kafka producer for simulating event streams
βββ storage/
β βββ aws_s3_influxdb.py # S3-InfluxDB integration stub
β βββ hadoop_batch_processing.py # Hadoop batch processing stub
β βββ mongodb_streaming.py # MongoDB streaming integration stub
βββ great_expectations/
β βββ great_expectations.yaml # GE configuration
β βββ expectations/
β βββ raw_data_validation.py # GE suite for data quality
βββ governance/
β βββ atlas_stub.py # Dataset lineage registration with Atlas/OpenMetadata
βββ monitoring/
β βββ monitoring.py # Python script to set up Prometheus & Grafana
β βββ prometheus.yml # Prometheus configuration file
βββ ml/
β βββ feature_store_stub.py # Feature Store integration stub
β βββ mlflow_tracking.py # MLflow model tracking
βββ kubernetes/
β βββ argo-app.yaml # Argo CD application manifest
β βββ deployment.yaml # Kubernetes deployment manifest
βββ terraform/ # Terraform scripts for cloud deployment
βββ scripts/
βββ init_db.sql # SQL script to initialize MySQL and demo data
-
Ingestion & Orchestration:
- Apache Airflow β Schedules batch and streaming jobs.
- Kafka β Ingests streaming events.
- Spark β Processes batch and streaming data.
-
Storage & Processing:
- MinIO β S3-compatible data lake.
- PostgreSQL β Stores transformed and processed data.
- Great Expectations β Enforces data quality.
- AWS S3 β Cloud storage integration.
- InfluxDB β Time-series data storage.
- MongoDB β NoSQL database integration.
- Hadoop β Big data processing integration.
-
Monitoring & Governance:
- Prometheus β Metrics collection.
- Grafana β Dashboard visualization.
- Apache Atlas/OpenMetadata β Data lineage and governance.
-
ML & Data Serving:
- Docker and Docker Compose must be installed.
- Ensure that Python 3.9+ is installed locally if you want to run scripts outside of Docker.
- Open ports required:
- Airflow: 8080
- MySQL: 3306
- PostgreSQL: 5432
- MinIO: 9000 (and console on 9001)
- Kafka: 9092
- Prometheus: 9090
- Grafana: 3000
-
Clone the Repository
git clone https://github.com/hoangsonww/End-to-End-Data-Pipeline.git cd End-to-End-Data-Pipeline
-
Start the Pipeline Stack
Use Docker Compose to launch all components:
docker-compose up --build
This command will:
- Build custom Docker images for Airflow and Spark.
- Start MySQL, PostgreSQL, Kafka (with Zookeeper), MinIO, Prometheus, Grafana, and Airflow webserver.
- Initialize the MySQL database with demo data (via
scripts/init_db.sql
).
-
Access the Services
- Airflow UI: http://localhost:8080
Set up connections:mysql_default
β Host:mysql
, DB:source_db
, User:user
, Password:pass
postgres_default
β Host:postgres
, DB:processed_db
, User:user
, Password:pass
- MinIO Console: http://localhost:9001 (User:
minio
, Password:minio123
) - Kafka: Accessible on port
9092
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000 (Default login:
admin/admin
)
- Airflow UI: http://localhost:8080
-
Run Batch Pipeline
- In the Airflow UI, enable the
batch_ingestion_dag
to run the end-to-end batch pipeline. - This DAG extracts data from MySQL, validates it, uploads raw data to MinIO, triggers a Spark job for transformation, and loads data into PostgreSQL.
- In the Airflow UI, enable the
-
Run Streaming Pipeline
- Open a terminal and start the Kafka producer:
docker-compose exec kafka python /opt/spark_jobs/../kafka/producer.py
- In another terminal, run the Spark streaming job:
docker-compose exec spark spark-submit --master local[2] /opt/spark_jobs/spark_streaming_job.py
- The streaming job consumes events from Kafka, performs real-time anomaly detection, and writes results to PostgreSQL and MinIO.
- Open a terminal and start the Kafka producer:
-
Monitoring & Governance
- Prometheus & Grafana:
Use themonitoring.py
script (or access Grafana) to view real-time metrics and dashboards. - Data Lineage:
Thegovernance/atlas_stub.py
script registers lineage between datasets (can be extended for full Apache Atlas integration).
- Prometheus & Grafana:
-
ML & Feature Store
- Use
ml/mlflow_tracking.py
to simulate model training and tracking. - Use
ml/feature_store_stub.py
to integrate with a feature store like Feast.
- Use
-
CI/CD & Deployment
- Use the
docker-compose.ci.yaml
file to set up CI/CD pipelines. - Use the
kubernetes/
directory for Kubernetes deployment manifests. - Use the
terraform/
directory for cloud deployment scripts. - Use the
.github/workflows/
directory for GitHub Actions CI/CD workflows.
- Use the
Congratulations! You have successfully set up the end-to-end data pipeline with batch and streaming processing. However, this is a very general pipeline that needs to be customized for your specific use case.
Note: Be sure to visit the files and scripts in the repository and change the credentials, configurations, and logic to match your environment and use case. Feel free to extend the pipeline with additional components, services, or integrations as needed.
-
Docker Compose:
All services are defined indocker-compose.yaml
. Adjust resource limits, environment variables, and service dependencies as needed. -
Airflow:
Customize DAGs in theairflow/dags/
directory. Use the provided PythonOperators to integrate custom processing logic. -
Spark Jobs:
Edit transformation logic inspark/spark_batch_job.py
andspark/spark_streaming_job.py
to match your data and processing requirements. -
Kafka Producer:
Modifykafka/producer.py
to simulate different types of events or adjust the batch size and frequency using environment variables. -
Monitoring:
Updatemonitoring/monitoring.py
andprometheus.yml
to scrape additional metrics or customize dashboards. Place Grafana dashboard JSON files in themonitoring/grafana_dashboards/
directory. -
Governance & ML:
Replace stub implementations ingovernance/atlas_stub.py
andml/
with real integrations as needed. -
CI/CD & Deployment:
Customize CI/CD workflows in.github/workflows/
and deployment manifests inkubernetes/
andterraform/
for your cloud environment. -
Storage:
Data storage options are in the
storage/
directory with AWS S3, InfluxDB, MongoDB, and Hadoop stubs. Replace these with real integrations or credentials as needed.
- Real-Time Recommendations:
Process clickstream data to generate personalized product recommendations. - Fraud Detection:
Detect unusual purchasing patterns or multiple high-value transactions in real-time.
- Risk Analysis:
Aggregate transaction data to assess customer credit risk. - Trade Surveillance:
Monitor market data and employee trades for insider trading signals.
- Patient Monitoring:
Process sensor data from medical devices to alert healthcare providers of critical conditions. - Clinical Trial Analysis:
Analyze historical trial data for predictive analytics in treatment outcomes.
- Predictive Maintenance:
Monitor sensor data from machinery to predict failures before they occur. - Supply Chain Optimization:
Aggregate data across manufacturing processes to optimize production and logistics.
- Sentiment Analysis:
Analyze social media feeds in real-time to gauge public sentiment on new releases. - Ad Fraud Detection:
Identify and block fraudulent clicks on digital advertisements.
Feel free to use this pipeline as a starting point for your data processing needs. Extend it with additional components, services, or integrations to build a robust, end-to-end data platform.
- Service Not Starting:
Check Docker logs (docker-compose logs
) to troubleshoot errors with MySQL, Kafka, Airflow, or Spark. - Airflow Connection Issues:
Verify that connection settings (host, user, password) in the Airflow UI match those indocker-compose.yaml
. - Data Quality Errors:
Inspect Great Expectations logs in the Airflow DAG runs to adjust expectations and clean data. - Resource Constraints:
For production use, consider scaling out services (e.g., running Spark on a dedicated cluster, using managed Kafka).
Contributions, issues, and feature requests are welcome!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
- We will review your changes and merge them into the main branch upon approval.
This project is licensed under the MIT License.
This end-to-end data pipeline is designed for rapid deployment and customization. With minor configuration changes, it can be adapted to many business casesβfrom real-time analytics and fraud detection to predictive maintenance and advanced ML model training. Enjoy building a data-driven future with this pipeline!
Thanks for reading! If you found this repository helpful, please star it and share it with others. For questions, feedback, or suggestions, feel free to reach out to me on GitHub.