A comprehensive Streamlit-based analytics dashboard for visualizing key performance indicators (KPIs) from retail sales data.
The Retail KPI Dashboard provides interactive visualizations of critical business metrics derived from the Online Retail II Dataset (2010-2011). This dashboard enables business analysts and stakeholders to monitor:
- Revenue Performance - Monthly revenue trends with month-over-month growth analysis
- Customer Insights - Top 10 customers by total revenue
- Churn Analysis - Customer retention metrics and churn rate visualization
kpi-dashboard/
├── app.py # Main Streamlit application entry point
├── requirements.txt # Python dependencies
├── data/ # Data layer
│ ├── connection.py # PostgreSQL database connection
│ ├── querries.py # SQL query definitions
│ ├── processing.py # Data transformation and processing
│ └── data_loader.py # Cached data loading utilities
├── loader/ # Database loader
│ └── db_loader.py # CSV to PostgreSQL ETL script
└── visualisation/ # Visualization modules
├── month_over_month_vis.py # MoM revenue growth charts
├── churned_comp_vis.py # Customer churn visualization
└── top_ten_vis.py # Top customers bar chart- Month-over-Month Growth - Dual-axis chart showing monthly revenue (bar) and growth percentage (line)
- Top 10 Customers - Horizontal bar chart highlighting highest-revenue customers
- Churn Distribution - Categorical bar chart showing churned vs. active customers
- Python 3.10 or higher
- PostgreSQL 14 or higher
All dependencies are listed in requirements.txt:
streamlit # Web application framework
pandas # Data manipulation and analysis
plotly # Data visualisation
psycopg2 # PostgreSQL adapter
sqlalchemy # SQL toolkit and ORM
python-dotenv # Environment variable management-
Clone the repository
git clone <repository-url> cd kpi-dashboard
-
Create a virtual environment
python -m venv .venv source .venv/bin/activate # Linux/macOS .venv\Scripts\activate # Windows
-
Install dependencies
pip install -r requirements.txt
-
Configure database connection
Create a
.envfile in the project root:DB_USER=your_postgres_user DB_PASSWORD=your_postgres_password DB_HOST=localhost DB_PORT=5432 DB_NAME=retail_kpi_db
-
Initialize the database
Ensure your PostgreSQL database contains the required tables (
mom_percent,customer_profile,customer_churn). Use the loader script to populate data:python loader/db_loader.py
Start the Streamlit application:
streamlit run app.pyThe dashboard will open in the default browser at http://localhost:8501.
- Dataset originally from the UCI Machine Learning Repository
- Built with Streamlit, Pandas, and Matplotlib