Scott Krukowski Scott Krukowski

Case Study · Contextual AI

Demo paused

Turning an account book into a ranked action list.

A Weibull AFT survival model over thousands of customer orders, pushed to Supabase, wrapped in a two-stage Claude API chat interface. The sales team stops asking 'who should we call?' and starts answering 'we called — here's what we learned.' Built in about two weeks. Zero new SaaS spend.

Demo Reel · Coming

Reorder Intelligence · Chat Demo

25-30 second walkthrough: empty chat → ‘Who's overdue for reorder?' → ranked response → click a customer for detail. Recording queued once the app is back up.

Placeholder

System Architecture

Data → Model → AI Layer → Chat

Step 01 · Source

Epicor CSV

  • Orders export
  • Customers export

Step 02 · ETL

Python Pipeline

  • Clean + normalize
  • Load to Supabase

Step 03 · Store

Supabase

  • orders
  • customers
  • reorder_predictions

Step 04 · Model

Weibull AFT

  • Survival curves
  • 3-tier churn detector

Step 05 · AI Layer

Claude API

  • Stage 1 — route
  • Stage 2 — answer

Step 06 · UI

Chat · Vercel

  • Natural language
  • Live results
Copper: data pipeline Teal: AI layer ~2 week build · $0 infra add

The problem

The commercial team sat on top of two years of order history — 5,976 orders across 854 customers — and no one could answer the simplest growth question: who's about to churn, and who's already gone? Historical reports were snapshots, not predictions. The standard RFM buckets said "these customers bought recently" but couldn't say "this customer bought on a 92-day cadence for three years and it's been 148 days — go call." The team was flying on memory and Excel filters. Meanwhile, seven-figure accounts slipped into silence because nobody realized they had.

The model

A Weibull Accelerated Failure Time (AFT) survival model, fit per customer, that predicts the expected time to the next order from the covariates that actually matter: product mix, order size trend, seasonality, and historical interval variance. Each customer gets a survival curve and a confidence interval. When the observed silent interval crosses the predicted threshold, the customer flips tier.

Three churn tiers surface automatically:

  • HARD CHURN — 730+ days silent, volume-discount-and-reintroduce territory.
  • SOFT CHURN — 540+ days, worth a direct call from the account manager.
  • PATTERN-VIOLATED — customer's own cadence broken; highest-value intervention zone. RFM misses these entirely.

Try the chat

Canned prompts below — no real data — but the responses match what the live app actually returns. Click any prompt to see the flow.

Reorder Intelligence · Chat

Demo Chat · Canned Data

Click a prompt below to see how the model answers. No real data — responses are pre-scripted from the actual app.

What I actually did

  1. Pulled the Epicor CSV export, wrote an ETL pipeline in Python to land orders and customers in Supabase.
  2. Fit the Weibull AFT model with lifelines, added a three-tier churn detector, wrote 1,833 customer predictions back to Supabase.
  3. Added a customer_revenue Postgres view to make revenue-weighted queries fast.
  4. Built a two-stage Claude API layer — stage one routes the user's natural-language question to the right table (customers, predictions, orders, revenue); stage two fills in the answer using the retrieved rows.
  5. Shipped a Next.js chat front-end to Vercel, wired it to the Supabase RPC layer, handed the URL to ownership.

Outcomes

  • Flagged 441 overdue reorders + 1,000+ churned accounts for targeted re-engagement
  • Surfaced multi-million-dollar revenue at-risk across top 10 accounts in under 90 seconds of chat
  • Replaced the capability of CDP + predictive-analytics platforms ($50–100K/yr) with an internal build
  • Shipped in ~2 weeks; sized for ongoing iteration by a non-engineer operator

Stack

Pythonpandaslifelines (Weibull AFT)SupabaseClaude APINext.jsVercel