Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

🛒 Retail Sales Analytics Dashboard

An end-to-end analytics project that turns raw retail transaction data into a decision-ready dashboard — built with Python, Pandas, SQL, and Streamlit. It covers the full workflow a data analyst would run: generate/clean data, compute business KPIs, analyze trends, and present them through an interactive, filterable dashboard.

1. Project Objective

Retail teams need quick answers to recurring questions: Which products and stores are driving revenue? Is growth accelerating or slowing month to month? Are discounts actually paying off? Which customer segments matter most?

This project answers those questions end-to-end — from a raw transactions table to an interactive dashboard — and is built as a portfolio piece demonstrating the analyst workflow: data generation/cleaning → SQL/Pandas aggregation → KPI design → visualization → business interpretation.

2. Dataset Description

The dataset (data/retail_sales.csv) is a synthetic but realistic retail transaction log — 15,000 orders spanning Jan 2023–Dec 2024, generated by data/generate_sample_data.py with:

  • 5 categories (Electronics, Apparel, Home & Kitchen, Beauty, Sports), each with 5 representative products
  • 5 regions (North, South, East, West, Central) across 20 stores
  • Seasonal uplift: Oct–Dec orders get a 1.4x revenue multiplier to mimic India's festive-quarter demand spike
  • Randomized discounting (0–30%, weighted toward smaller discounts) to enable discount-impact analysis
  • 4 customer segments (Regular, Premium, New, Wholesale) and 5 payment methods
Column Type Description
order_id string Unique order identifier
order_date date Order date
category / product string Product taxonomy
region / store string Sales location
quantity, unit_price numeric Order line details
discount_pct, discount_amount numeric Discount applied
gross_amount, net_amount numeric Revenue before/after discount
payment_method string Payment channel
customer_segment string Customer classification

The pipeline is schema-driven, so swapping in a real POS export instead of the synthetic CSV requires no code changes — just matching column names.

3. Tools Used

Layer Tool Purpose
Data generation & cleaning Python, Pandas, NumPy Synthetic data, type coercion, dedup, derived date fields
Analysis Pandas (src/analytics.py) + SQL (sql/queries.sql) KPIs, aggregations, growth/discount analysis
Visualization Streamlit, Plotly Interactive dashboard and charts
Testing Pytest Unit tests on every analytics function

4. Architecture / Workflow

data/generate_sample_data.py
        │  (synthetic transactions)
        ▼
data/retail_sales.csv
        │
        ▼
src/data_processing.py  ──► load_data() / clean_data() / filter_data()
        │  (typed, deduped DataFrame + derived date fields)
        ▼
src/analytics.py  ──► KPI & aggregation functions
        │  (revenue, growth, top products, store & discount analysis, segments)
        ▼
app.py (Streamlit)  ──► sidebar filters → tabbed dashboard (Overview, Products,
        │                Regions & Stores, Discounts, Customer Segments, Raw Data)
        ▼
   Interactive dashboard in the browser

sql/queries.sql  ──► the same analysis expressed in standalone SQL,
                      for use against a real database instead of the CSV

Every chart in app.py calls a pure function in src/analytics.py — no aggregation logic lives in the UI layer, so the same functions are unit-tested independently (tests/test_analytics.py, 11 tests) and reusable outside Streamlit (e.g., in a notebook or scheduled report).

5. Key Business Insights

Computed from the full 15,000-order dataset (see sql/queries.sql or src/analytics.py to reproduce):

  • Revenue is Electronics-heavy: ₹41.9 crore total revenue, with Electronics alone contributing ~66% (₹27.6 cr) — more than the other four categories combined.
  • Top 5 products are all electronics and are tightly clustered — Smartwatch, Smartphone, Headphones, Bluetooth Speaker, and Laptop each generate ₹52–57 lakh, meaning no single SKU is a disproportionate bet.
  • Festive-quarter effect is visible in the growth data: October shows a +67.9% MoM revenue jump, consistent with the built-in Oct–Dec seasonal uplift, before cooling off into November/December.
  • Regional performance is nearly flat: revenue across all 5 regions sits within a ~2.6% band (₹82.8M–₹85.0M), i.e. no single region is over- or under-indexed — expansion decisions likely shouldn't be region-driven here.
  • Store performance has more spread than region performance: the top store (Store_12, ₹2.34 cr) outperforms the median store meaningfully, suggesting store-level operational factors (not just regional demand) explain performance gaps.
  • Discounting shows a mild negative relationship with basket size: average order value actually decreases as discount depth increases (₹30,467 with no discount → ₹23,542 at >20% discount), and the correlation between discount % and net revenue is slightly negative (-0.04). This suggests deep discounts in this dataset aren't buying larger baskets — a real-world flag worth investigating (e.g., are discounts concentrated on already-low-value items?).
  • Regular customers drive the base, Premium/Wholesale drive efficiency: Regular segment contributes the most orders and revenue (₹21.0 cr, 7,493 orders), but it's worth comparing per-order value across segments in the dashboard's Customer Segments tab to see which segment is most valuable per transaction.
  • Payment method split is fairly even, with Credit Card slightly ahead (₹8.63 cr) — no single channel dominates, so payment-method-specific promotions would need to be broad-based to move the needle.

(All figures reproducible by running data/generate_sample_data.py then python -c "from src.data_processing import load_data; from src import analytics as an; ..." — see Getting Started.)

6. Getting Started

git clone https://github.com/<your-username>/retail-sales-dashboard.git
cd retail-sales-dashboard
python -m venv venv
source venv/bin/activate      # Windows: venv\Scripts\activate
pip install -r requirements.txt

python data/generate_sample_data.py   # generates data/retail_sales.csv
streamlit run app.py                  # opens at http://localhost:8501
pytest tests/                         # run unit tests

7. Dashboard Features

  • KPI row: total revenue, orders, average order value, units sold, latest MoM growth (with color-coded delta)
  • Tabbed layout: Overview, Products, Regions & Stores, Discounts, Customer Segments, Raw Data
  • Filters: date range, region, category, customer segment, payment method (sidebar, apply globally)
  • Charts: revenue trend, MoM growth bars (green/red), category pie, top-product bar with unit labels, region/store bars, best store per region, discount-band analysis, payment-method split, segment comparison
  • Data export: download the currently filtered slice as CSV

8. Future Improvements

  • Swap the synthetic CSV for a live database connection (Postgres/SQLite) using the queries in sql/queries.sql directly
  • Add cohort/retention analysis for repeat customers (current dataset doesn't model customer IDs across orders)
  • Add forecasting (e.g., Prophet or simple moving-average projection) for next-quarter revenue
  • Add statistical significance testing to the discount-impact analysis rather than relying on correlation alone
  • Deploy to Streamlit Community Cloud and link the live app here
  • Add automated screenshot generation to keep this README's visuals in sync with the app

License

MIT — see LICENSE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages