Design Rationale

Explanation of
Choices

Here's the architecture and decisions I made, hope they make sense! For the ranking, I chose to filter and then batch candidates by company rather than scoring individually. This lets the model compare peers directly to find the true decision-makers, balancing contextual accuracy with token costs. For the prompt optimization, I implemented a size-aware subsampling strategy—optimizing against a diverse subset of companies to prevent overfitting while keeping the feedback loop fast.

Persona-Driven Ranking Strategy

I built the rubric to adapt based on company size. At a 10-person startup, the CEO is your buyer. At a 500-person company, you're looking for the VP of Sales Development instead.

I score on department_fit, seniority_fit, & size_fit, then assign explicit ranks (1, 2, 3...). No ties allowed.

Gemini & Groq Support

I set Gemini as the default because it's fast, reliable, and highly cost-effective. For flexibility, you can swap to any model on the Groq API to handle specific scale or latency requirements.

Company-Batched Ranking

I group leads by company so the LLM can compare them head-to-head. This guarantees I find the best N contacts per company with clear, relative rankings.

Size-Aware Deterministic Gate

I filter out HR, Finance, and Legal upfront—saving 30-50% of LLM calls. It's context aware too: CTOs pass the gate at startups but get filtered at big enterprises.

Async Agent Pattern

Large lists timeout on Vercel (10-60s limit). I use Trigger.dev to handle this with durable execution and auto-retries. Keeps the UI responsive while the agents work in the background.

Supabase Realtime

Supabase streams live updates as companies get processed. You can literally watch the agent work in real-time—no custom WebSockets or polling needed.

Batch Upserts Over Row-by-Row

Writing 50 leads one-by-one means 50 database calls. I do batch upserts instead—one atomic transaction. 10x faster and no partial failures.

Basically: I built this in a few hours. And definitely is not perfect! Hope you like though!

System Architecture

Inside the Engine

From raw CSV to ranked intelligence. A breakdown of the autonomous agentic workflow that transforms lead lists into prioritized outreach targets.

CSV Ingestion & Normalization

Step 01

Upload your lead database as a CSV file. The system automatically ingests data, normalizes company names, titles, and employee ranges, then deduplicates using canonical keys to prevent double-processing.

Technology
Next.js + Supabase

Company Batching & Context Enrichment

Step 02

Leads are grouped by company and enriched with web intelligence. The Scout Agent scrapes company websites to extract signals like funding announcements, hiring patterns, and go-to-market strategies.

Technology
Trigger.dev + Cheerio

Deterministic Pre-filtering

Step 03

Before ranking, a rules-based gate excludes obvious non-targets: HR, Finance, Legal, Advisors, and Interns. Dynamic exceptions apply based on company size (e.g., CTOs allowed at startups under 10 employees).

Technology
TypeScript + Zod

Multi-Model LLM Ranking

Step 04

The system defaults to Gemini Flash for industry-leading speed and accuracy. Users can also select any model from the Groq API to optimize for specific latency or reasoning requirements.

Technology
Gemini (Default) + Groq

Persona-Aware Scoring

Step 05

The LLM evaluates each lead against a detailed persona rubric (department fit, seniority fit, size context fit). It classifies roles as decision_maker, champion, or irrelevant and assigns explicit ranks within each company.

Technology
LLM + Structured JSON

Batch Database Persistence

Step 06

All rankings, scores, reasoning, and rubric data are persisted to Supabase in batch operations. Progress updates trigger real-time UI changes via Supabase Realtime subscriptions.

Technology
Supabase Realtime

Live Leaderboard & Export

Step 07

As leads are ranked, they stream into an animated leaderboard with expandable rows showing AI reasoning. Export your top N leads per company to CSV for immediate outreach.

Technology
React Table + CSV Export

Automatic Prompt Optimization

Additional

The system uses AI to optimize its own prompts. It evaluates performance on a pre-ranked eval set, generates natural language gradients from errors, and iteratively refines the prompt to improve F1 score and ranking accuracy.

Technology
APO/ProTeGi Algorithm

It basically does this

From raw spreadsheet to prioritized inbox.

Raw Data
leads.csv
Name
Title
Company
Size
J. Smith
Recruiter
Acme Corp
5000+
A. Chen
CTO
Nexus AI
12
B. Davis
Intern
Nexus AI
12
Ranking Logic
J. SmithDiscard
Title Match: 'Recruiter'
Department: HR
A. ChenMatch
Role: Tech Decision Maker
Context: Small Team
High Signal Leads
1
Alex Chen
CTO • Nexus AI
Company Scouted
Hierarchy Mapped
Email Generated

Ready to see it in action?

Upload your lead CSV and watch the autonomous ranking system in real-time.

Launch Ranker
lead.ranker
Powered by Gemini + Groq + Trigger.devBuilt with Next.js