How partomia/spend-analytics works
Spend Analytics unifies retail spending data, categorises merchants, and publishes customer personas, cohort forecasts, and marketing opportunity signals. The principal workflow runs from synthetic source-system ingestion through quality checks and silver/gold preparation, then CAI categorisation and daily ML evaluation, with accepted outputs consumed by the Streamlit console and scorer. The graph preserves the documented orchestration and on-demand paths; several job internals and the report implementation were not excerpted, so those links rely on README statements rather than claims of source inspection.
Main entry points: pipeline.py Daily run stages · evaluate_models.py Model evaluation and KPI gate · categorise.py Merchant categorisation job · storage.py Storage adapters
Components 27
Data foundation
- Bronze ingestion
cde/jobs/generate_spend_bronze.py - Data quality gates
cde/jobs/dq_check.py - Silver resolution
cde/jobs/build_silver.py - Merchant category map
- Gold features
cde/jobs/build_gold_features.py - Storage adapters
spend/storage.py - Published analytics
Analytics and ML
- Merchant categorisation job
cai/jobs/categorise.py - Merchant categoriser
spend/categorise.py - Feature engineering job
cai/jobs/feature_engineering.py - Model training job
cai/jobs/train_models.py - Model evaluation and KPI gate
cai/jobs/evaluate_models.py - Daily run stages
spend/pipeline.py - Customer personas
spend/personas.py - Spend forecasting
spend/forecast.py - Opportunity signals
spend/signals.py - Model registry
spend/registry.py - Experiment tracking
spend/tracking.py
Serving and insights
- Spend Insights Console
app/streamlit_app.py - Console data access
app/data.py - Scorer client
spend/client.py - CAI scorer endpoint
cai/model/predict.py - Request scoring
spend/scoring.py - Spend reporting dashboard
dataviz/build_dashboard.py
Orchestration
- CDE Airflow
cde/dags/spend_dag.py
Other components
- Six spend sources
- CDW Impala
Connections 35
- CDE Airflow → Bronze ingestion: orchestrates
- Six spend sources → Bronze ingestion: ingests
- Bronze ingestion → Data quality gates: checks
- Data quality gates → Silver resolution: passes data
- Silver resolution → Merchant categorisation job: supplies events
- CDE Airflow → Merchant categorisation job: starts job
- Merchant categorisation job → Merchant categoriser: uses
cai/jobs/categorise.py - Merchant categorisation job → Merchant category map: writes map
- Merchant categorisation job → Gold features: hands off
- Silver resolution → Gold features: builds features
- Gold features → Data quality gates: checks layer
- CDE Airflow → Feature engineering job: orchestrates
- Feature engineering job → Daily run stages: runs stage
cai/jobs/feature_engineering.py - Daily run stages → Storage adapters: reads snapshots
spend/pipeline.py - Feature engineering job → Model training job: chains jobs
- Model training job → Daily run stages: runs stage
- Daily run stages → Customer personas: fits personas
spend/pipeline.py - Daily run stages → Spend forecasting: builds forecasts
spend/pipeline.py - Daily run stages → Opportunity signals: derives signals
spend/pipeline.py - Model training job → Model evaluation and KPI gate: chains jobs
- Model evaluation and KPI gate → Daily run stages: runs gate
- Model evaluation and KPI gate → Published analytics: publishes outputs
- Model evaluation and KPI gate → Model registry: records run
- Model evaluation and KPI gate → Experiment tracking: logs experiment
- Published analytics → Spend Insights Console: provides insights
- Spend Insights Console → Console data access: reads views
app/streamlit_app.py - Console data access → Storage adapters: reads tables
app/data.py - Spend Insights Console → Console data access: requests scoring
app/data.py - Console data access → Scorer client: calls scorer
app/data.py - Scorer client → CAI scorer endpoint: posts request
spend/client.py - CAI scorer endpoint → Request scoring: dispatches
cai/model/predict.py - Scorer client → Request scoring: scores locally
spend/client.py - Request scoring → Storage adapters: loads context
spend/scoring.py - Spend reporting dashboard → Storage adapters: reads analytics
dataviz/build_dashboard.py - Storage adapters → CDW Impala: queries tables
spend/storage.py