This project builds a fully automated, cloud-integrated ETL pipeline that ingests raw order and delivery data from AWS S3, applies a multi-layer data quality framework, computes operational KPIs, and loads structured results into a MySQL database β on a scheduled basis via AWS Lambda.
No manual steps. No stale reports. Data flows from raw CSV to analytics-ready tables automatically.
Operations teams at e-commerce and logistics companies generate thousands of order records daily. Without automation, this creates three recurring problems:
| Problem | Impact |
|---|---|
| Manual KPI calculation | Delayed visibility β reports lag by 24β48 hours |
| No data validation at ingestion | Silent errors propagate into dashboards |
| No anomaly flagging | High-value outlier orders go undetected |
This pipeline eliminates all three.
Raw CSV Orders
β
AWS S3 (Raw Zone) β Cloud storage layer
β
Python ETL Script β Triggered via AWS Lambda (scheduled)
β
Data Quality Layer β Validation, cleaning, outlier detection
β
MySQL Database β cleaned_orders + kpi_summary tables
β
BI Dashboard β Power BI / Tableau ready
The pipeline runs automatically on a configurable schedule using AWS Lambda + EventBridge (CloudWatch Events):
# EventBridge rule β triggers Lambda daily at 6:00 AM UTC
{
"schedule": "cron(0 6 * * ? *)"
}The Lambda function:
- Pulls the latest CSV from the S3 raw zone
- Runs the full ETL and validation pipeline
- Upserts cleaned data and KPI summary into MySQL
- Logs execution status and row counts to CloudWatch
No manual execution required. Each morning, the database reflects the prior day's orders.
| Layer | Technology |
|---|---|
| Cloud Storage | AWS S3 |
| Orchestration | AWS Lambda + EventBridge |
| Transformation | Python (Pandas, NumPy, SQLAlchemy) |
| Database | MySQL (AWS RDS or local) |
| Monitoring | AWS CloudWatch Logs |
| Visualization | Power BI / Tableau (optional) |
| Column | Type | Description |
|---|---|---|
| order_id | VARCHAR | Unique order identifier |
| order_date | DATE | Order date |
| region | VARCHAR | Sales region |
| product_category | VARCHAR | Product segment |
| order_value | FLOAT | Revenue per order |
| discount | FLOAT | Discount applied |
| shipping_cost | FLOAT | Delivery cost |
| delivery_status | VARCHAR | Delivered / Cancelled / Failed |
| delivery_time_mins | INT | End-to-end delivery time |
| Column | Type | Description |
|---|---|---|
| report_date | DATE | Aggregation date |
| total_orders | INT | Total orders processed |
| total_revenue | FLOAT | Sum of order values |
| cancellation_rate | FLOAT | % cancelled orders |
| failure_rate | FLOAT | % failed deliveries |
| avg_order_value | FLOAT | Mean revenue per order |
| total_profit_proxy | FLOAT | Revenue β Discount β Shipping |
Six validation checks run on every pipeline execution before any data touches the database:
def run_quality_checks(df):
checks = {
"missing_values": df.isnull().sum().to_dict(),
"duplicate_records": df.duplicated().sum(),
"negative_values": (df[numeric_cols] < 0).sum().to_dict(),
"type_validation": validate_dtypes(df),
"outlier_orders": detect_outliers_iqr(df, "order_value"),
"row_count": len(df)
}
log_checks(checks)
return checksIf critical checks fail (e.g., >5% missing on key columns), the pipeline halts and logs a CloudWatch alert rather than silently loading dirty data.
kpi_summary = {
"total_orders": len(df),
"total_revenue": df["order_value"].sum(),
"avg_order_value": df["order_value"].mean(),
"cancellation_rate": (df["delivery_status"] == "Cancelled").mean() * 100,
"failure_rate": (df["delivery_status"] == "Failed").mean() * 100,
"delivered_rate": (df["delivery_status"] == "Delivered").mean() * 100,
"total_profit_proxy": (df["order_value"] - df["discount"] - df["shipping_cost"]).sum(),
"outlier_orders": detect_outliers_iqr(df, "order_value").shape[0]
}1. EXTRACT β Pull latest CSV from S3 using boto3
2. VALIDATE β Run 6-point data quality checks
3. CLEAN β Handle nulls, type errors, duplicates
4. TRANSFORM β Compute KPIs, flag outliers
5. LOAD β Upsert into MySQL (cleaned_orders + kpi_summary)
6. LOG β Write pipeline execution summary to CloudWatch
- Regional cancellation hotspot β Region C cancellation rate 2.3Γ higher than average, flagged for ops review
- Outlier detection β 47 orders exceeded IQR upper bound; isolated for revenue reporting correction
- Profit proxy trend β Average profit proxy declined 8% over 6 weeks, driven by rising shipping costs
- Pipeline reliability β 100% successful scheduled runs over 30-day test period
git clone https://github.com/vaishnavibhamare-24/order-analytics-pipeline.git
cd order-analytics-pipelinepip install pandas numpy sqlalchemy pymysql boto3 python-dotenv# .env
AWS_ACCESS_KEY_ID=your_key
AWS_SECRET_ACCESS_KEY=your_secret
AWS_REGION=us-east-1
S3_BUCKET=your-bucket-name
MYSQL_HOST=your-rds-endpoint
MYSQL_USER=admin
MYSQL_PASSWORD=your_password
MYSQL_DB=orders_dbpython etl_pipeline.py# Package dependencies
pip install -r requirements.txt -t ./package
cd package && zip -r ../lambda_package.zip .
cd .. && zip lambda_package.zip etl_pipeline.py
# Deploy
aws lambda update-function-code \
--function-name order-etl-pipeline \
--zip-file fileb://lambda_package.zipaws events put-rule \
--schedule-expression "cron(0 6 * * ? *)" \
--name DailyOrderPipelineTriggerorder-analytics-pipeline/
β
βββ etl_pipeline.py # Main ETL script
βββ quality_checks.py # Data validation module
βββ kpi_engine.py # KPI computation logic
βββ db_loader.py # MySQL upsert logic
βββ requirements.txt
βββ .env.example
β
βββ data/
β βββ sample_orders.csv # Sample dataset for local testing
β
βββ sql/
β βββ create_cleaned_orders.sql
β βββ create_kpi_summary.sql
β
βββ logs/
βββ pipeline_run.log # Local execution logs
| Limitation | Planned Improvement |
|---|---|
| Single-source ingestion (one CSV per run) | Add multi-source S3 prefix scanning |
| No incremental load logic | Implement watermark-based delta loading |
| Basic IQR outlier detection | Add ML-based anomaly detection (Isolation Forest) |
| No arrival-airport data | Out of scope for current version |
| Two weather variables only | Expand feature set in v2 |
Vaishnavi Bhamare Master's in Advanced Data Analytics β University of North Texas
MIT License β free to use, modify, and distribute.