Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›οΈ Retail Analytics Platform

End-to-End Enterprise Analytics Consulting Solution for Retail Operations

Python Streamlit XGBoost SQLite Pytest License

Structured like a real-world analytics consulting engagement for Apex Retail Group (50-store omnichannel grocery & apparel chain).


πŸ“Œ Executive Summary & Key Results

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
========================================================================================

πŸ› οΈ Technology Stack

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

πŸ—οΈ Platform System Architecture

                                  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)

πŸ“ Repository Directory Structure

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

⚑ Quickstart & Installation Guide

1. Environment Setup

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.txt

2. Execute Data Warehouse ETL Pipeline

Generate the sales backbone and load the 6-table normalized SQLite warehouse:

python src/data_pipeline/load_warehouse.py

3. Train Machine Learning Models & Optimization Engines

Run 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.py

4. Build Standalone Financial Excel Model

Generate the interactive Excel workbook:

python excel/create_excel_model.py

5. Launch Interactive Streamlit BI Dashboard

Open the interactive executive dashboard in your browser (http://localhost:8501):

streamlit run dashboard/app.py

6. Run Automated Test Suite

Verify data integrity and mathematical formulas with pytest:

pytest tests/

πŸ“„ Consulting Phase Reports Index

This project is documented like a professional management consulting engagement. Click any report link below to review:


πŸ’‘ Standalone Artifacts

  • πŸ—„οΈ 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 (WITH clauses) 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.

🀝 License & Acknowledgments

Distributed under the MIT License. Built as an enterprise retail analytics showcase.

About

An end-to-end Enterprise Retail Analytics Platform built as a management consulting engagement. Features SQLite Data Warehouse with 18 SQL CTE queries, XGBoost Demand Forecasting (56.7% MAPE reduction), ROP/EOQ Inventory Optimization, Elasticity-Based Dynamic Pricing, Streamlit BI Dashboard, and Excel What-If Financial Model.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages