This project demonstrates an end-to-end data engineering pipeline built using modern data stack tools. It integrates structured data from MySQL and semi-structured JSON data into Snowflake, followed by layered transformations using dbt.
The pipeline enables advanced analytics such as customer lifetime value (CLV), product performance, customer segmentation, time-series trends, and anomaly detection.
CSV / MySQL (DBeaver)
↓
StreamSets (Ingestion Pipelines)
↓
Snowflake (RAW Layer + JSON Stage)
↓
dbt (Transformations)
↓
STAGING → INTERMEDIATE → MARTS
↓
Analytics Tables + Tests + Documentation
- mysql acts as the oltp system
- streamsets handles ingestion
- snowflake is the analytical warehouse
- and dbt is used for transformation and modeling
- MySQL (source system)
- DBeaver (data setup and management)
- StreamSets Data Collector (data ingestion)
- Snowflake (cloud data warehouse)
- dbt (data transformation and modeling)
- GitHub (version control)
Loaded manually into MySQL using DBeaver:
- customers
- products
- orders
These were then ingested into Snowflake using StreamSets.
Multiple JSON files were created, each representing product-level reviews:
product_101_reviews.json
product_102_reviews.json
product_103_reviews.json
product_104_reviews.json
product_105_reviews.json
Each file contains:
- product_id
- rating
- review_text
- timestamp
These were uploaded to Snowflake using:
- Internal stage (reviews_stage)
- COPY INTO commands
- Flattening via dbt
Separate pipelines were configured for:
- customers
- products
- orders
Configuration highlights:
- Origin: JDBC Query Consumer (MySQL)
- Mode: Incremental
- Offset Columns:
- customers → customer_id
- products → product_id
- orders → order_timestamp
- Destination: Snowflake
Steps:
- Create stage
- Upload JSON files
- Load into raw table (preserved in
VARIANTformat) - Parse using FLATTEN in dbt
models/
staging/
stg_customers.sql
stg_products.sql
stg_orders.sql
stg_reviews.sql
intermediate/
int_customer_orders.sql
int_product_sales.sql
int_product_reviews.sql
marts/
mart_customer_segment.sql
mart_product_performance.sql
mart_sales_trends.sql
mart_sales_anomalies.sql
mart_sales_trends_with_rolling.sql
mart_reviews_summary.sql
- Cleans raw data
- Standardizes column names
- Parses JSON reviews and flattens them to convert nested data into rows
- Combines core datasets
- Prepares reusable aggregations
Examples:
- Customer + Orders join
- Product-level revenue
- Review aggregation
Final analytics tables used for business insights:
- Customer segmentation (CLV-based)
- Product performance (sales + reviews)
- Sales trends (time-series)
- Anomaly detection (statistical)
- Rolling averages
- Review summaries
- Customer Lifetime Value (CLV): total spend per customer
- Average Product Rating
- Total Revenue
- Total Orders
- Daily Revenue Trends
- Loyalty Tier Segmentation
| CLV Range | Segment |
|---|---|
| < 100 | Low |
| < 500 | Medium |
| < 1000 | High |
| >= 1000 | VIP |
- Daily aggregation of revenue and orders
- Rolling 7-day average
- Trend monitoring over time
Sales anomalies are identified using statistical thresholds:
- Spike → above mean + 2 * std deviation
- Drop → below mean - 2 * std deviation
Implemented using dbt:
- not_null
- unique
- relationships
- accepted_values
Example:
- Order must have valid customer_id
- Rating must be between 1 and 5
- Order IDs must be unique
Run tests:
dbt test
dbt run
dbt test
dbt docs generate
dbt docs serve
dbt automatically generates:
- Model documentation
- Data lineage graph
- Dependency tracking
The following graph illustrates the complete data flow from raw ingestion in Snowflake to final analytics-ready mart tables.
This lineage highlights how structured (orders, products) and semi-structured (JSON reviews) data are combined to produce enriched product performance metrics.
- STAGING → cleaned raw data
- INTERMEDIATE → reusable logic
- MARTS → final analytics tables
- End-to-end ELT pipeline design
- Handling structured and semi-structured data
- Incremental ingestion with StreamSets
- Data modeling with dbt (layered architecture)
- Business metric computation (CLV, segmentation)
- Time-series analytics
- Anomaly detection
- Data quality validation
- Documentation and lineage tracking

