How I'd build Lead Router
I'd reach for Next.js on the frontend, FastAPI on the backend, and Postgres for the database. Stripe handles billing, Resend for transactional email, and the Claude API for routing intelligence. I'd estimate 150-160 hours to get this to production: that's auth, multi-tenancy, integrations with HubSpot and Salesforce, a working AI routing engine, and a customer dashboard. It's a real build, not a weekend project.
Day-by-day plan
Day 1: Provision auth schema with JWT + refresh tokens. Set up Postgres multi-tenant model with workspace isolation. Seed initial schema for users, teams, leads, routing rules.
Day 2: Wire Stripe billing for three tiers (Starter, Pro, Enterprise). Implement usage metering, subscription webhooks, and dunning logic for failed charges.
Days 3-4: Build customer onboarding flow. Walk customers through CRM connection (OAuth for HubSpot, API key for Salesforce), define lead sources, map custom fields, set initial routing rules.
Days 5-6: Implement HubSpot and Salesforce sync. Real-time webhook listeners to catch new leads, incremental pulls for historical data, conflict resolution for dual-synced leads.
Day 7: Build the routing engine. Claude API integration to evaluate leads against customer-defined rules and historical assignment patterns. Caching layer to avoid redundant evaluations on duplicate leads.
Day 8: Create routing rules UI. Drag-and-drop rule builder, weight configuration, A/B testing toggle, override mechanisms for admins.
Day 9: Analytics dashboard. Show lead volume, routing accuracy, team assignment distribution, demo show rates by routing cohort.
Day 10: Security audit, deployment setup on Vercel and Railway, runbook documentation, QA of end-to-end workflows.
What's hard about this build
The core technical risk is data quality. You're asking Claude to route leads based on CRM data, but most SMB CRMs are garbage: missing fields, inconsistent naming conventions, stale company records. The routing engine will be only as smart as the data it ingests, and you'll spend more support time on "why is this lead going to the wrong person" than on shipping new features. You also need bulletproof multi-tenant isolation - a bug that leaks one customer's leads into another's is a shutdown event. CRM API rate limits are another gotcha; HubSpot and Salesforce both throttle integrations, and naive syncing will burn your quota. Finally, testing the AI routing against real customer data without accidentally triggering actions on their CRM is a careful dance - you need sandboxed test environments for each integration.
What's fast because of AI
AI compresses weeks into days on this build. Scaffolding the Next.js component library and FastAPI endpoints goes 3x faster with Claude's multi-file generation. Writing comprehensive integration tests for the CRM sync logic - something that's normally tedious - becomes fast because Claude enumerates edge cases I'd miss and generates the test cases. Copywriting for the rules UI, the onboarding flow, and the analytics dashboard all come from Claude prompts instead of design documents. Debugging integration failures is quicker too; Claude can reason about HubSpot API response shapes and suggest fixes faster than I'd hand-trace logs. And edge-case enumeration for the routing logic - what happens when a lead has no email, or matches multiple rules, or arrives during a sync conflict - Claude generates decision trees that I then validate and implement.
How I'd hand it off
You get three Loom walkthroughs: one for customer onboarding, one for admin configuration, one for ops runbook. I'll leave a written runbook covering deployment procedures, database migrations, how to rotate Stripe/HubSpot/Salesforce API keys, and what to do if the routing engine starts timing out. I'll set up 30-day pager rotation so you're on-call for the first month, with escalation docs for common issues. All credentials go into a shared vault with access controls. Monitoring is already baked in: Sentry for errors, log aggregation on Railway, and Stripe webhook alerts for billing issues. You'll be able to run this independently by day 31.