Case Study
LeadFlow — an AI pipeline where the AI classifies and the code scores
LeadFlow qualifies, scores, and routes inbound B2B leads through a public form, a background enrichment pipeline, and an admin dashboard. The non-trivial part is the scoring contract: a fixed rubric turns model classifications into auditable numbers.
- Role
- Solo — design, engineering, documentation.
- Stack
- Next.js 15 · Supabase Postgres · Groq / Gemini · Vercel · Space Grotesk + JetBrains Mono.
- Timeline
- October 3–10, 2026.

01 — The problem
Small sales teams drown in inbound
A five-person B2B sales team gets a few dozen inbound messages a week: demo requests next to job seekers next to SEO cold pitches. Reading all of them costs hours; ignoring them costs pipeline. What the team needs is a front door that decides, in seconds, which messages deserve a human.
The AI-scoring market answered with a black box — “this lead is 78” with no audit trail. Nobody stakes quota on a number nobody can explain, so the tool gets ignored and the spreadsheet comes back.
I split the job the other way: the AI only does what it is good at (classification) and pure code does the math (scoring). The result is a deterministic number that any developer or sales rep could trace back to a category and a rule.
02 — How it works
One form fill, nine steps
The request path does the minimum — validate, insert, return a reference code — and everything expensive happens after the response is already on its way back.
// AI returns categories. Code scores them. // Company fit = 22/30 — not because the AI decided so, // but because company_size = "mid" maps to 22 in a fixed table.
03 — Technical decisions
Six calls I'd defend in an interview
AI classifies, code scores.
The AI returns discrete categories (company_size, industry, intent, budget_signal). A pure function maps them to points with fixed weights. The total is deterministic given the extraction. Any number the UI shows is traceable to a model output and a specific rule.
Fire-and-forget enrichment with `waitUntil`.
The POST returns the reference code in ~370ms. Enrichment runs after. On Vercel, a floating promise dies when the response returns — I hit exactly that in production, with a stranded pending row to prove it. Fixed with `waitUntil` from `@vercel/functions`, which extends the function lifetime until the promise settles. Verified live: submissions reach the DB enriched within 3s.
waitUntil(runEnrichment(id).catch(console.error));
Spam is a hard override, not a point deduction.
The rubric floor is 8/100 for obvious spam. Added an early return: `if (intent === 'spam') return all zeros`. Small rule, large narrative payoff — 0 reads as definitive to the UI, 8 doesn't.
The Signal design system — one instrument across marketing and admin.
Space Grotesk for display, Inter for body, JetBrains Mono for every number. The mono is doing the heavy lifting: every score, ID, date, and status decision uses it. The number 78 is not "a metric in a card" — it is the product's output rendered in the font the product's output deserves.
Custom cursor, applied with restraint.
Desktop-only, gated on `(pointer: fine)` and viewport ≥ 1024px. A cyan dot follows the cursor exactly, a ring lerps behind at 80ms. Hidden over inputs so the caret is visible. The rest of the site does not animate on hover — only the cursor. One signature micro-interaction, not ten.
HTML injection in email templates.
Caught during review. User-supplied name/company went unescaped into the receipt HTML. Fixed with `lib/email/escape-html.ts` and newline stripping on the sales-notification subject. A bug that would have shipped silently.
escapeHtml(name) // & < > " ' — text part stays raw
04 — The Signal redesign
An instrument, not a dashboard
The original LeadFlow read as an AI-generated SaaS. Dark zinc, Inter throughout, three-card feature row. Correct for the product, indistinguishable from every other AI-adjacent portfolio project. The redesign has a name — Signal — and a thesis: an instrument, not a dashboard.
The palette is near-black with electric cyan as the signal color. Signal-high/mid/low tokens map directly to routing decisions (qualified / queued / archived). Typography pairs Space Grotesk for headlines, Inter for body, and JetBrains Mono for every number in the product. Spacing uses clamp tokens that scale section rhythm between 96 and 160 pixels.
Three signature moments carry it. The hero shows a live score animating from 00 to 78 with sub-score bars filling in sequence. The pipeline section pins and scrolls horizontally through five stages — ingest, extract, score, route, act. The admin lead detail reveals the score breakdown on viewport entry: bars fill left-to-right, staggered 120ms, with the total counting up. Each moment reflects the product's actual mechanics, not decoration.




05 — What I'd do differently
Three honest limitations
- Receipt delivery on the free Resend tier is constrained. The shared sender only delivers to the account owner. Verifying a custom domain is the production fix ($10/yr); v1 ships with the limitation documented.
- Rate limiting is a Map, not Redis. Single-instance in-memory. Fine for a demo, resets on cold start. Upstash Redis + sliding window is the correct shape.
- Admin auth is a shared password, not a user system. Correct for a portfolio piece, wrong for multi-tenant. A real version would move to Supabase Auth with RLS policies per user.
06 — Under the hood
The receipts
- 31.6 kB / 155 kB
- First Load JS for / (page / total)
- 22 commits
- layers, fixes, and this rewrite
- ~5,200 lines
- no test suite — verified live instead
- All green
- tsc, lint, build, seed — zero paid tools
Next.js 15 App Router, Tailwind v4, shadcn Base-UI, Supabase Postgres, Groq + Gemini, Resend, Vercel. No 3D, no animation library — the redesign was done with pure CSS, rAF, and IntersectionObserver.

