Olist Customer Intelligence Platform
Weekly ETL, monthly retraining, live scoring: a full data platform over 100k real Brazilian orders.

What it is
What it does
I took the Olist Brazilian e-commerce dataset (9 raw CSVs, 100k+ orders, 2016 to 2018) and built the platform around it that I would want as an analyst: an Airflow-orchestrated warehouse, churn and segmentation models that retrain on schedule, a FastAPI service that scores customers with SHAP explanations, and a nine-page Streamlit dashboard on top.
Why it exists
We had the Olist dump (100k orders) but no way to know who was about to churn. I got tired of one-off notebooks, so I built the boring part: the warehouse, the scheduled retraining, the versioning, and the API that still serves the model the next morning.
Repo Amit-kr26/Customer_IntelligenceDemo huggingface.co/spaces/Amit-kr26/Customer_IntelligenceStack Python · Airflow · PostgreSQL · XGBoost · MLflow · FastAPI · Streamlit · Docker
Runs on a free Hugging Face Space, so give it 1 to 2 minutes to boot on first load.
How it is built
Two-layer warehouse
staging.stg_* tables feed a star schema (dim_dates/customers/products/sellers + order-item grain fact_orders) defined in etl/warehouse_ddl.sql, with idempotent ON CONFLICT upserts and reviews deduped by latest answer timestamp.
Data-quality gates
load.py runs non-empty checks across staging and warehouse plus an orphan-FK probe; any failure fails the DAG before models ever see bad data.
Coordinated schedules
olist_etl_pipeline runs weekly; olist_ml_training runs monthly and waits on an ExternalTaskSensor pinned to the ETL's notify_success task.
Leakage-safe churn model
XGBoost (n_estimators=200, max_depth=5, lr=0.05, scale_pos_weight computed at fit) predicts recency>180d churn, with recency itself excluded as target leakage.
Segmentation two ways
Classic RFM via pd.qcut quartiles maps to 7 named segments, while KMeans(k=5, n_init=10) clusters 6 behavioural features into High Value/Loyal/Occasional/At-Risk/Lost cohorts.
Serving with explanations
POST /predict/churn returns probability plus the top-5 SHAP factors per customer; models load once through lru_cache and batch scoring uses a staging-table UPDATE…FROM swap.
One-container deploy
Seven docker-compose services locally; on Hugging Face Spaces a supervisord config runs uvicorn (:8000) and Streamlit (:7860) side by side over a bundled SQLite warehouse.
How the pieces connect
Drawing is wider than the frame. Drag to pan.
Also filed under Data Engineering
- CineMatch2026