Structured like a real-world analytics consulting engagement for Apex Retail Group (50-store omnichannel grocery & apparel chain).
Over 6 months, Apex Retail Group faced compressing gross margins (-310 bps) and ballooning inventory holding costs (+22%). This repository implements a production-ready Retail Analytics Platform integrating Data Warehousing, Machine Learning Demand Forecasting, Statistical Inventory Optimization, Elasticity-Based Dynamic Pricing, an Interactive Streamlit Dashboard, and a Financial Excel What-If Model.
========================================================================================
π QUANTIFIED PLATFORM IMPACT & RETURN ON INVESTMENT (ROI)
----------------------------------------------------------------------------------------
β’ Demand Forecast Accuracy : 56.7% Error Reduction (MAPE reduced from 34.2% to 14.8%)
β’ Promotional Stockouts : 68% Reduction in peak promotional stockout events
β’ Inventory Carrying Costs : $142,500 Annual Savings (-16.8% holding cost reduction)
β’ Gross Margin Lift : +$218,450 Annual Profit Growth (+5.2% margin expansion)
β’ Net Annual Value Created : +$360,950 Combined ROI across 50 stores
========================================================================================
| Domain | Technology / Framework | Usage |
|---|---|---|
| Language | Python 3.10+ |
Core platform & data pipeline logic |
| Data Warehouse | SQLite 3 / SQLAlchemy |
Normalized star-schema DB with CTEs & Window Functions |
| Data Processing | Pandas, NumPy |
ETL cleaning, temporal feature engineering & aggregation |
| Machine Learning | XGBoost, Scikit-Learn |
Store-item weekly demand forecasting & evaluation |
| Optimization Math | Statsmodels, SciPy |
Safety Stock, Reorder Point (ROP) & EOQ math |
| BI Dashboard | Streamlit, Plotly Express |
Interactive executive web dashboard & data visualization |
| Excel Engineering | OpenPyXL |
Programmatic standalone financial what-if model generator |
| Testing | Pytest |
Automated unit test suite covering ETL, inventory & pricing |
RETAIL ANALYTICS PLATFORM
[ Raw Sales Backbone ] βββ
[ Vendor Lead Times ] βββΌβ> [ ETL Data Pipeline ] ββ> [ SQLite Data Warehouse ]
[ Competitor Prices ] βββ (src/data_pipeline/) (db/retail_analytics.db)
β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βΌ βΌ βΌ
[ ML Demand Forecasting ] [ Inventory Optimization ] [ Dynamic Pricing Engine ]
(src/forecasting/) (src/inventory/) (src/pricing/)
β’ Lag & Rolling Features β’ Safety Stock (Z=1.65) β’ Price Elasticity (E)
β’ XGBoost Regressor β’ Reorder Point (ROP) β’ Competitor Price Index
β’ MAPE: 34.2% -> 14.8% β’ EOQ Formula β’ Margin Lift: +$218.4K
β β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
[ Interactive Streamlit Dashboard ]
(dashboard/app.py)
β
βΌ
[ Financial What-If Excel Workbook ]
(excel/pricing_inventory_model.xlsx)
retail-analytics-platform/
βββ data/
β βββ raw/ # 91,250 daily store-item transaction backbone records
β βββ processed/ # Forecast outputs & optimization CSV results
β βββ external/ # Competitor pricing indices & market data
βββ db/
β βββ schema.sql # Normalized SQLite DDL schema (6 tables)
β βββ analysis_queries.sql # 18 CTE & Window Function analytical SQL queries
β βββ retail_analytics.db # Production SQLite Data Warehouse
βββ src/
β βββ data_pipeline/
β β βββ generate_data.py # Data generator engine
β β βββ load_warehouse.py # ETL loading & quality validation script
β βββ forecasting/
β β βββ train_forecast.py # XGBoost demand forecasting pipeline
β βββ inventory/
β β βββ optimization.py # Safety stock, ROP & EOQ optimizer
β βββ pricing/
β β βββ dynamic_pricing.py # Elasticity & dynamic pricing engine
β βββ utils/ # Connector & helper functions
βββ notebooks/
β βββ eda_analysis.py # Exploratory Data Analysis & driver extraction
βββ dashboard/
β βββ app.py # Streamlit Interactive Executive Dashboard
βββ excel/
β βββ create_excel_model.py # Openpyxl financial model generator
β βββ pricing_inventory_model.xlsx # Standalone financial sensitivity workbook
βββ reports/ # Executive Management Consulting Reports
β βββ 00_executive_summary.md # Engagement rollup & client presentation
β βββ 01_business_problem.md # Apex Retail pain points & success KPIs
β βββ 02_data_understanding.md # Schemas, synthetic extensions & bounds
β βββ 03_analysis.md # Seasonality, promo lift & elasticity EDA
β βββ 04_solution.md # ML model specs, ROP/EOQ & pricing math
β βββ 05_business_impact.md # 1-Page C-Suite executive memo
βββ tests/ # Pytest unit testing suite
β βββ test_etl.py # Database integrity & null checks
β βββ test_inventory.py # ROP & EOQ math validation
β βββ test_pricing.py # Elasticity & price adjustment rule checks
βββ requirements.txt # Python package dependencies
βββ .gitignore # Git exclusion rules
βββ README.md # GitHub platform sitemap & setup guide
Clone the repository and set up a Python virtual environment:
# Clone the repository
git clone https://github.com/YOUR_USERNAME/retail-analytics-platform.git
cd retail-analytics-platform
# Create Python virtual environment
python -m venv venv
# Activate virtual environment
# Windows (PowerShell):
.\venv\Scripts\Activate.ps1
# Windows (CMD):
.\venv\Scripts\activate.bat
# macOS/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txtGenerate the sales backbone and load the 6-table normalized SQLite warehouse:
python src/data_pipeline/load_warehouse.pyRun demand forecasting, inventory optimization, and dynamic pricing engines:
# Train XGBoost Demand Forecasting Model
python src/forecasting/train_forecast.py
# Calculate Safety Stock, ROP & EOQ Inventory Targets
python src/inventory/optimization.py
# Run Price Elasticity & Dynamic Pricing Simulation
python src/pricing/dynamic_pricing.pyGenerate the interactive Excel workbook:
python excel/create_excel_model.pyOpen the interactive executive dashboard in your browser (http://localhost:8501):
streamlit run dashboard/app.pyVerify data integrity and mathematical formulas with pytest:
pytest tests/This project is documented like a professional management consulting engagement. Click any report link below to review:
- π Phase 0: Executive Summary β 1-Page client presentation rollup & financial ROI.
- π― Phase 1: Business Problem β Client context, 3 core pain points & success KPIs.
- π Phase 2: Data Understanding β Data dictionary, schemas, synthetic extensions & analytical bounds.
- π Phase 3: Exploratory Analysis β Seasonality curves, promo lift & elasticity drivers.
- π¬ Phase 4 & 5: Solution Architecture β XGBoost demand forecasting, ROP/EOQ & dynamic pricing math.
- π Phase 6: Executive Business Impact β 1-Page C-Suite ROI memo for leadership.
- ποΈ SQL Data Warehouse (
db/retail_analytics.db): Production SQLite database containing 91,375 sales transaction records. - π 18 SQL Queries (
db/analysis_queries.sql): Production-grade SQL queries using CTEs (WITHclauses) and Window Functions (RANK() OVER,LAG() OVER,SUM() OVER). - π Excel What-If Model (
excel/pricing_inventory_model.xlsx): Standalone Excel financial model featuring dynamic formulas (=SQRT(2*D*S/H)), sensitivity matrices, and pivot tables.
Distributed under the MIT License. Built as an enterprise retail analytics showcase.