A minimal KPI computation system that computes 8 key performance indicators from SQLite data.
# Install dependencies
make install
# Seed database with synthetic data
make seed
# Run KPI job
make run- total_orders - Count of orders created on the date
- total_revenue_dollars - Sum of paid/captured orders
- avg_order_value_dollars - Average order value
- refunds_count - Count of refunded/chargeback orders
- new_users - Count of users who signed up on the date
- active_users - Count of unique users with orders on the date
- net_revenue_dollars - Total revenue minus refunds
- repeat_users - Count of repeat users
# Basic usage
python -m kpi_job.main --date 2025-07-18
# With options
python -m kpi_job.main --date 2025-07-18 --verbose --dry-run
# Using the installed CLI
kpi --date 2025-07-18 --verbosepython-kpi/
βββ kpi_job/
β βββ __init__.py # Package init
β βββ main.py # Main CLI
β βββ models.py # Data models
β βββ seed.py # Data seeding
βββ data/ # SQLite database
βββ artifacts/ # Generated KPI CSV files
βββ pyproject.toml # Project configuration
βββ Makefile # Development commands
βββ README.md # This file
# Install in development mode
make install
# Test installation
make test
# Clean up
make cleandate,kpi_name,kpi_value,unit,computed_at
2025-07-18,active_users,11.0,count,2025-09-16T08:33:42.795407+00:00
2025-07-18,avg_order_value_dollars,103.8,dollars,2025-09-16T08:33:42.795407+00:00
2025-07-18,net_revenue_dollars,-1287.35,dollars,2025-09-16T08:33:42.795407+00:00
2025-07-18,new_users,11.0,count,2025-09-16T08:33:42.795407+00:00
2025-07-18,refunds_count,23.0,count,2025-09-16T08:33:42.795407+00:00
2025-07-18,repeat_users,0.0,count,2025-09-16T08:33:42.795407+00:00
2025-07-18,total_orders,40.0,count,2025-09-16T08:33:42.795407+00:00
2025-07-18,total_revenue_dollars,4151.94,dollars,2025-09-16T08:33:42.795407+00:00
- β Click CLI - Easy command-line interface
- β Pandas Processing - Efficient data manipulation
- β SQLite Storage - Lightweight database
- β CSV Output - Standard artifact format
- β Dollar Calculations - Revenue in dollars
- β Synthetic Data - Built-in test data generation
- Prototyping KPI systems
- Learning data processing with Python
- Quick deployments where simplicity matters
- Proof of concepts and demos
- Educational purposes