This project is a data engineering pipeline for processing daily customer and order data to generate business-ready KPIs. It supports both database-driven processing (MySQL) and in-memory processing (Pandas). The outputs can be used for reporting, analysis, or visualization (e.g., Tableau).
- Ingests customer and order data from CSV/XML files
- Generates KPIs such as repeat customers, monthly trends, regional revenue, and top spenders
- Provides both SQL-based and Pandas-based pipelines
- Saves all KPI outputs as CSV files in a dedicated
outputs/folder
Follow these steps to set up the project environment:
git clone <your-repo-url>
cd <project-folder>For Windows:
python -m venv venv
venv\Scripts\activateFor macOS/Linux:
python3 -m venv venv
source venv/bin/activatepip install pandas mysql-connector-python python-dotenv lxml- Install MySQL Server (any recent version)
- Create a database (e.g.,
customer_orders) - Ensure the database has tables
customersandorders - Update
src/db/db_connection.pywith your MySQL credentials
from src.db.db_connection import get_connection
conn = get_connection()
print(conn) # Should print connection objectpython -m src.kpis.sql_kpisThis will generate CSV files in the outputs/ folder:
repeat_customers.csvmonthly_trends.csvregional_revenue.csvtop_spenders_30d.csv
python -m src.mainThis will generate CSV files in the outputs/ folder:
repeat_customers_pd.csvmonthly_trends_pd.csvregional_revenue_pd.csvtop_customers_pd.csv
Project Structure
DATA_ENGINEER_PROJECT/
├── data/
│ ├── task_DE_new_customers.csv
│ └── task_DE_new_orders.xml
├── logs/
├── outputs/
│ ├── monthly_trends.csv
│ ├── regional_revenue.csv
│ ├── repeat_customers.csv
│ ├── top_customers.csv
│ └── top_spenders_30d.csv
├── sql/
│ └── schema.sql
├── src/
│ ├── db/
│ │ ├── __init__.py
│ │ └── db_connection.py
│ ├── etl/
│ │ ├── __init__.py
│ │ ├── load_customers.py
│ │ └── load_orders.py
│ ├── kpis/
│ │ ├── __init__.py
│ │ ├── pandas_kpis.py
│ │ └── sql_kpis.py
│ └── __init__.py
├── main.py
├── .env.example
├── .gitignore
├── README.md
└── requirements.txt
- Make the pipeline scalable using Airflow or other orchestrators.
- Store raw and processed data on S3 or another cloud storage.
- Add automated tests for data quality and KPI validation.
- Generate Tableau dashboards directly from outputs.
- Support incremental ingestion for daily files.