Fresh Leads: local business leads, verified the moment you search
A live SaaS I designed and built end to end. You type a trade and a town, like “dentists in Austin”, and it finds the real businesses, checks that their phone numbers and emails work, confirms they are still trading, and grades each one 0–100 for what you sell.
- 1,590+unit tests
- 91metro areas indexed
- 8MCP tools for AI apps
- 2FArequired for everyone
Visit the live site (opens in new tab) · Read the engineering write-up: My crawler said 1 in 7 websites were down (opens in new tab)
The problem
People who sell to local businesses, such as web designers, SEO agencies and card-terminal resellers, buy lead lists that were scraped months ago. Half the numbers are dead, and the list is the same for everyone. A dentist with a broken website is a great lead for a web designer and irrelevant to someone selling payment terminals.
What it does
- Find: real businesses from public maps (OpenStreetMap, Google Places), or from an owned index of 91 metro areas refreshed every 20–30 days.
- Check: visits each business website. Is it up, secure, mobile friendly? Does it take bookings or online orders?
- Grade: scores each business 0–100 against a buyer playbook (websites, payments, marketing, booking software), with a plain-English reason.
- Verify on open: when a customer opens a lead, the phone line is ring-tested and the mailbox is checked. If both are dead, the customer isn’t charged.
- Act: AI-drafted first email built only from that business’s checked findings, CSV/Excel/PDF export, and push to HubSpot, Salesforce, GoHighLevel or any webhook.
Architecture
One Next.js application on Vercel serves the marketing site, the dashboard, an operator panel, a public REST API and an MCP connector. All state lives in one Supabase Postgres database. The dashboard, REST API and MCP connector share one code path: an API key or MCP token is just another way to resolve “who is this user”, so a machine caller can never do more than the same customer can on screen.
Key engineering decisions
| Decision | Why |
|---|---|
| Money rules live in Postgres, not app code | “Never charge twice” and “never double-grant a redelivered webhook” must hold across concurrent serverless instances. A unique index holds; an if in TypeScript doesn’t. |
| Idempotent paid actions | Unlocks are keyed on (user, business) and credit grants on the Stripe session, so retries, double-clicks and redeliveries are no-ops. |
| Expensive checks at unlock, not at search | A search can return 500 businesses. Only the few that are opened pay for phone and mailbox verification. |
| Owned business index for big metros | Discovery from our own table takes 2.6–5.1 s against about 11 s for a rate-limited public API. |
| Stripe webhook is the only source of truth | It re-reads the purchase from Stripe rather than trusting the payload. A valid signature proves who sent it, not that the session exists. |
| Fail closed on spend, fail open on limits | Anything that spends money refuses when in doubt. A rate limiter that can’t reach the database lets the request through. |
Built for AI agents: the MCP connector
Customers can connect Fresh Leads to Claude, ChatGPT or Cursor and ask, “find me 20 dentists in Austin with no website and open the best 5.” Sign-in uses a stateless OAuth flow (HMAC-signed clients and codes, the token is an ordinary revocable API key). Because an AI reading business websites can be prompt-injected, an AI can spend at most 30 credits per action, checked before it runs and failing closed, and it can never pay on its own. Slow searches return a ticket immediately and keep running in the background.
Security
- Two-factor sign-in is required for every account: authenticator app, email or SMS code, or a passkey.
- Customer data is isolated with Postgres row-level security, not just hidden in the UI.
- Passwords and API keys are stored hashed. Cards are handled by Stripe only.
- Nonce-based Content Security Policy, and every staff action on an account is logged.
A lesson from production
The crawler reported about 14% of websites as “down” when they were really blocking datacentre IP addresses. Measuring the retry stage showed it recovered zero of them while costing 22% of every search, so I deleted it. The fix was to keep the network error code and make “reachable” three-valued: proven down, up, or unknown. Full write-up on dev.to (opens in new tab).
Testing
Every Vercel build runs a guard, typecheck, lint and the unit suite (1,590+ tests covering scoring, deduplication, access rules, pricing, TOTP against RFC vectors, passkey attacks, the MCP protocol and the OAuth rules). Separate SQL tests run the credit functions against a throwaway Postgres to prove double unlocks, redelivered webhooks and parallel spend are safe.