Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

KPI Monitor

A simple Python script that tracks business metrics and flags potential issues.

What This Does

Monitors key performance indicators (KPIs) from a CSV file and alerts you when:

  • Revenue drops significantly
  • Profit margin falls too low
  • Active users decline

No dashboards, no web apps. Just clear terminal output showing your metrics and any problems.

How It Works

  1. Load data - Reads CSV with date, revenue, costs, profit, and active users
  2. Calculate KPIs - Computes profit margin, revenue growth, user growth
  3. Check alerts - Compares against configurable thresholds
  4. Print report - Shows period-by-period metrics and flags issues

Setup

Install dependencies:

pip install -r requirements.txt

Usage

Run with a file path:

python kpi_monitor.py sample_kpi_data.csv

Or run and enter the path when prompted:

python kpi_monitor.py

Dataset Requirements

Your CSV should have these columns:

  • date - Date in YYYY-MM-DD format
  • revenue - Total revenue for the period
  • costs - Total costs for the period
  • profit - Net profit (revenue - costs)
  • active_users - Number of active users

Example:

date,revenue,costs,profit,active_users
2024-01-01,100000,70000,30000,5000
2024-02-01,105000,72000,33000,5100
2024-03-01,98000,71000,27000,4950

Generate Sample Data

Test the script with sample data:

python sample_data_generator.py

This creates sample_kpi_data.csv with 12 months of data including some intentional issues to trigger alerts.

Configure Thresholds

Edit the top of kpi_monitor.py to adjust alert thresholds:

REVENUE_DROP_THRESHOLD = 10  # Alert if revenue drops more than 10%
MIN_PROFIT_MARGIN = 15       # Alert if profit margin falls below 15%
USER_DECLINE_THRESHOLD = 5   # Alert if active users drop more than 5%

Example Output

📅 Period: 2024-06-01
--------------------------------------------------------------------------------
Revenue:       $  85,234.50  (-15.2%)
Costs:         $  59,664.15
Profit:        $  25,570.35
Profit Margin:        30.0%
Active Users:       5,234  (+2.1%)

🚨 ALERTS:
   ⚠️  REVENUE DROP: Revenue decreased by 15.2% ($100,276 → $85,235)

Limitations

This is a simple monitoring tool with real constraints:

  • No forecasting - Only looks at historical data, doesn't predict future
  • No anomaly detection - Uses fixed thresholds, not statistical methods
  • No data validation - Assumes clean, complete data
  • No visualization - Text output only, no charts or graphs
  • No database support - CSV files only
  • No notifications - Prints to terminal, doesn't send emails/Slack messages
  • Simple period comparison - Only compares consecutive periods
  • No seasonality handling - Doesn't account for seasonal patterns

Future Improvements

If I continue this project, I might add:

  • Export alerts to a log file
  • Email/Slack notifications when alerts trigger
  • Support for multiple KPI files
  • Visualization with matplotlib (simple charts)
  • Moving averages for trend analysis
  • Year-over-year comparisons
  • Configurable alert rules via config file
  • Database support (SQLite, PostgreSQL)
  • More KPIs (customer acquisition cost, churn rate, etc.)

Why This Exists

I wanted to:

  1. Learn basic business analytics with Python
  2. Practice working with time-series data
  3. Build something practical for monitoring
  4. Keep it simple enough to understand and modify

License

MIT - Use this however you want.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages