Skip to main content
@kneeraazon
R&D PrototypeAI & AutomationCase Study

Built for B2B Sales · FastAPI · Celery · XGBoost · Next.js · PostgreSQL

RevOps Lead Scoring Platform

Scores B2B leads from product-usage and engagement signals, ranks them hot, warm, cool or cold, and tells sales which to call first. A transparent formula is always live while an XGBoost model scores in shadow beside it until its accuracy is trusted. A web app shows ranked leads, analytics, run history and a simulator that explains a score; HubSpot and Salesforce integrations and signed webhooks connect it to a CRM. FastAPI, Celery, PostgreSQL and Next.js, built to refuse unsafe configuration in production.

OUTCOME.01810API tests passing
OUTCOME.02528 / 528Seeded bugs caught, API and web (recorded)
OUTCOME.030.1 sTo score 100 leads in the local run
2D SYSTEM TOPOLOGY // END-TO-END REQUEST PIPELINE4-STAGE DATA FLOW

Event Ingest → Feature Build → Score Engine → CRM Sync

FIG.01 // INTERFACE & SYSTEM CAPTURE1 / 10
The dashboard: four counters (100 leads scored, 5 hot leads, last run 0.1 seconds, model v1.0.0), a Top HOT Leads table and a Recent Scoring Runs panel.
The dashboard: four counters (100 leads scored, 5 hot leads, last run 0.1 seconds, model v1.0.0), a Top HOT Leads table and a Recent Scoring Runs panel.

Role

Full-Stack Developer

Duration

Since April 2026

Tech Stack

Python 3.14FastAPICeleryPostgreSQL 18Redis 8XGBoostNext.js 16TypeScriptAlembicnginxDocker Compose
SECTION 01 // PROBLEM STATEMENT

The Problem

A sales team with thousands of product-led leads cannot call them all. It needs a ranked list that says who to call first and why, that updates as people use the product, and that it can trust enough to act on without the model becoming a black box.

The starting point was a prototype whose HubSpot webhook could be called by anyone, whose webhook targets were not checked, which loaded model files with pickle, which stored CRM tokens in plain text and whose web app could not sign in.

SECTION 02 // SYSTEM ARCHITECTURE & EXECUTION

My Approach

  1. Scoring. A transparent formula is always live and its tier boundaries (hot 75, warm 50, cool 25) are settings. An XGBoost model scores in shadow alongside it and is promoted only when its accuracy is trusted; the simulator shows exactly which signals add how many points.
  2. Pipeline. Events are ingested, features are built per contact, and every contact is scored on a schedule by Celery workers and also from a command line, through one shared scoring module.
  3. Interface. A Next.js app with a dashboard, ranked and filterable leads with export, companies, analytics (precision per tier, score distribution, conversions), CRM integrations, run history, settings and the simulator, behind a cookie session and a same-origin proxy so no token reaches the browser.
  4. Integrations. HubSpot batch sync out and a signed deal-won webhook in, Salesforce OAuth, outbound webhooks with signatures and retries, and S3-compatible raw imports. Every URL the server calls on a user's behalf is checked: public addresses only, no credentials, no redirects.
  5. Safe by default. The API refuses to start outside development with a placeholder or short secret or a wildcard CORS origin, stored CRM tokens are encrypted, models are XGBoost JSON rather than pickle, and rate limits cannot be dodged with a forged forwarding header.
  6. Delivery. Docker Compose for development and a production layout with nginx, Alembic migrations, and CI.
  7. Review. Fixes for the anyone-can-call webhook, the server-side request forgery risk, plaintext tokens, token-type confusion, a sign-in-less web app, webhooks that never fired, a list that lost leads when a shadow score was newer, and a company size that never reached the score.
SECTION 03 // VERIFIED OUTCOMES

Results & Impact

Re-run on 2026-11-14 in a scratch copy: ruff passes, 810 API tests pass, the web app's type-check and lint are clean and its 473 tests in 28 files pass.

The platform was also run locally on that date against PostgreSQL 18: migrations, a seed of 100 synthetic contacts and an admin user, and a scoring pass that scored 100 of 100 contacts with no errors in 0.1 seconds (5 hot, 18 warm, 40 cool, 37 cold). Every page of the web app rendered. To give Analytics something to show, 13 fictional conversions were recorded through the API (4 of 5 hot, 5 of 18 warm, 4 of 40 cool), so the precision figures in the screenshots are fictional. The simulator scored a high-intent profile HOT at 100 of 100 and listed the points each signal added.

Recorded in the repository's work-done.md: a mutation check that put 239 deliberate bugs into the API's authentication, encryption, URL and signature code and 289 into the web app's session and proxy code, with the tests failing for every one; and no known vulnerabilities in 99 Python packages and none in the production npm dependencies.

Not verified: the Celery worker and scheduled runs (no Redis was available, so scoring ran from the command line); HubSpot and Salesforce against real accounts; the XGBoost model path and the AI reports, which need a trained model and an API key; the Docker images; and the mutation runs, which were not repeated on 2026-11-14.