Skip to content

pullely-samuel/cc-data-analysis

Repository files navigation

E-commerce Sales Dashboard

A professional Streamlit dashboard for analyzing e-commerce sales metrics, featuring interactive visualizations and configurable date range filtering.

Features

  • Interactive Date Filtering: Select year and month range with automatic comparison to previous year
  • Key Performance Indicators: Revenue, monthly growth, average order value, and total orders with trend indicators
  • Revenue Analysis: Monthly trend comparison between current and previous periods
  • Product Category Analysis: Top 10 categories by revenue with visual ranking
  • Geographic Analysis: US choropleth map showing revenue distribution by state
  • Customer Experience Metrics: Review scores and delivery time analysis

Project Structure

cc-data-analysis/
├── app.py                  # Streamlit dashboard application
├── data_loader.py          # Data loading and preparation functions
├── business_metrics.py     # Business metric calculation functions
├── EDA.ipynb              # Original exploratory data analysis
├── EDA_Refactored.ipynb   # Refactored analysis notebook
├── ecommerce_data/        # Data directory
│   ├── orders_dataset.csv
│   ├── order_items_dataset.csv
│   ├── products_dataset.csv
│   ├── customers_dataset.csv
│   ├── order_reviews_dataset.csv
│   └── order_payments_dataset.csv
└── README.md

Installation

  1. Clone the repository and navigate to the project directory:
cd cc-data-analysis
  1. Install dependencies using uv:
uv sync

Running the Dashboard

Start the Streamlit dashboard:

uv run streamlit run app.py

The dashboard will open in your default browser at http://localhost:8501.

Running the Jupyter Notebook

To run the refactored analysis notebook:

uv run jupyter lab EDA_Refactored.ipynb

Dashboard Layout

Header

  • Title on the left
  • Date filters on the right (apply globally to all visualizations):
    • Year selector (defaults to 2023)
    • Start Month selector
    • End Month selector

KPI Cards Row

Four metric cards displaying:

  • Total Revenue: With year-over-year growth indicator
  • Monthly Growth: Average month-over-month growth rate
  • Average Order Value: With year-over-year growth indicator
  • Total Orders: With year-over-year growth indicator

Trend indicators use green for positive trends and red for negative trends.

Charts Grid (2x2)

  1. Revenue Trend: Line chart comparing current year (solid) vs previous year (dashed)
  2. Top 10 Categories: Horizontal bar chart with blue gradient, sorted by revenue
  3. Revenue by State: US choropleth map with blue color scale
  4. Satisfaction vs Delivery Time: Bar chart showing average review score by delivery time bucket

Bottom Row

  • Average Delivery Time: Days with trend indicator (lower is better)
  • Review Score: Large score display with star rating

Module Reference

data_loader.py

Functions for data loading and preparation:

  • load_raw_datasets(data_dir): Load all CSV files from directory
  • prepare_sales_data(orders, order_items, status_filter): Create merged sales dataset
  • filter_by_date_range(df, start_year, start_month, end_year, end_month): Filter by date range
  • prepare_sales_with_products(sales_data, products): Add product categories
  • prepare_sales_with_customers(sales_data, orders, customers): Add customer geography
  • prepare_sales_with_reviews(sales_data, reviews): Add review scores
  • calculate_delivery_time(df): Calculate delivery days

business_metrics.py

Functions for calculating business metrics:

  • calculate_total_revenue(sales_data): Sum of prices
  • calculate_revenue_growth(current, previous): Percentage growth
  • calculate_monthly_revenue(sales_data): Revenue by month
  • calculate_average_monthly_growth(sales_data): Average MoM growth
  • calculate_total_orders(sales_data): Unique order count
  • calculate_average_order_value(sales_data): AOV calculation
  • calculate_revenue_by_category(sales_data): Category breakdown
  • calculate_revenue_by_state(sales_data): Geographic breakdown
  • calculate_average_review_score(sales_data): Mean review score
  • calculate_average_delivery_time(sales_data): Mean delivery days
  • calculate_review_by_delivery_speed(sales_data): Reviews by delivery bucket

Data Dictionary

Dataset Column Description
orders order_id Unique order identifier
orders customer_id Customer identifier
orders order_status Status (delivered, shipped, canceled, etc.)
orders order_purchase_timestamp Order date and time
orders order_delivered_customer_date Delivery date
order_items order_item_id Item sequence within order
order_items product_id Product identifier
order_items price Item price in USD
order_items freight_value Shipping cost
products product_category_name Product category
customers customer_state US state abbreviation
reviews review_score Rating from 1-5

About

E-commerce Sales Dashboard with Streamlit

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors