File size: 8,021 Bytes
bd28470
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# πŸ€– AI Client Acquisition System

> Enterprise-grade, hyper-intelligent lead discovery, profiling, and scoring pipeline.  
> Built with production AI engineering practices β€” not n8n-style hype.

[![Phase](https://img.shields.io/badge/Phase-1%20Finding-blue)]()
[![Models](https://img.shields.io/badge/AI-MiniMax%20M2.7%20%2B%20LLaMA-green)]()
[![Cost](https://img.shields.io/badge/LLM%20Cost-%240%2Fday-brightgreen)]()
[![Trigger.dev](https://img.shields.io/badge/Orchestration-Trigger.dev-purple)]()

---

## What This System Does

Automatically discovers, qualifies, and profiles potential clients for an AI automation agency.

```
Every day at 9 AM PKT:
  1. Pick next territory (city Γ— industry) β†’ 27 cities, auto-rotation
  2. Search Google for companies β†’ Serper API
  3. Scrape each website β†’ Playwright (headless)
  4. Detect pain signals β†’ "no chatbot", "phone booking only", etc.
  5. Gate 2: Skip if < 2 pain signals
  6. Find decision-maker emails β†’ Hunter.io + Pattern Generation + SMTP
  7. Verify emails β†’ 7-layer verification (FREE)
  8. Find personal LinkedIn + social profiles
  9. AI profiling β†’ MiniMax M2.7 (chain-of-thought reasoning)
  10. Deterministic scoring β†’ 100-point scale, zero hallucination
  11. Alert on Slack β†’ hot leads (85+) instant, daily digest for all
```

## Architecture

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ CRON: daily-lead-discovery (4 AM UTC = 9 AM PKT)   β”‚
β”‚   β†’ Territory Manager β†’ Google Search β†’ Queue       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
                       β–Ό (max 3 concurrent)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ TASK: process-company                               β”‚
β”‚   β†’ Scrape β†’ Pain Signals β†’ Gate 2                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ TASK: enrich-and-profile                            β”‚
β”‚   β†’ Hunter β†’ Pattern Gen β†’ SMTP β†’ LinkedIn         β”‚
β”‚   β†’ Python AI Service β†’ Save β†’ Slack Alert          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

## Model Chain (All FREE on NVIDIA NIM)

| Priority | Model | Parameters | Use Case |
|----------|-------|-----------|----------|
| 1st | MiniMax M2.7 | ~100B+ | Profiling, scoring, complex reasoning |
| 2nd | LLaMA 3.3 70B | 70B | Reliable fallback |
| 3rd | LLaMA 3.1 8B | 8B | Email classification, simple tasks |
| 4th | Deterministic | β€” | Zero hallucination fallback |

**Single API key. Single endpoint. $0/day.**

## Scoring System (100 points, fully deterministic)

```
Company Fit:      25 pts   (industry + size match)
AI Readiness:     20 pts   (tech stack + AI jobs)
Service Match:    20 pts   (pain signals β†’ our services)
Decision Maker:   20 pts   (verified email + LinkedIn + authority)
Timing:           15 pts   (growth signals + active website)

Tiers: hot (85+) | warm (70-84) | nurture (50-69) | archive (<50)
```

## Tech Stack

| Layer | Technology | Purpose |
|-------|-----------|---------|
| Orchestration | Trigger.dev | CRON, task chaining, retry, queuing |
| Database | Supabase (PostgreSQL) | Data storage, config, state |
| LLM | NVIDIA NIM (MiniMax + LLaMA) | AI profiling & analysis |
| Web Scraping | Playwright | Headless browser |
| Email | Hunter.io + SMTP | Finding & verification |
| Notifications | Slack Bot | Alerts, commands, digest |
| AI Service | Python FastAPI | Profiling, scoring, hallucination guard |
| Language | TypeScript + Python | Core logic |

## Project Structure

```
src/
β”œβ”€β”€ discovery/                    # Phase 1: Finding pipeline
β”‚   β”œβ”€β”€ lib/                      # Core logic
β”‚   β”‚   β”œβ”€β”€ contact-enricher.ts   # 6-step email pipeline
β”‚   β”‚   β”œβ”€β”€ email-classifier.ts   # Tier 1/2/3 classification
β”‚   β”‚   β”œβ”€β”€ email-verifier.ts     # 7-layer verification
β”‚   β”‚   β”œβ”€β”€ email-pattern-generator.ts  # FREE Snov replacement
β”‚   β”‚   β”œβ”€β”€ linkedin-person-finder.ts   # Personal LinkedIn
β”‚   β”‚   β”œβ”€β”€ social-finder.ts      # Instagram, Facebook, Twitter
β”‚   β”‚   β”œβ”€β”€ pain-signal-detector.ts     # Heuristic + LLM
β”‚   β”‚   β”œβ”€β”€ territory-manager.ts  # CityΓ—industry grid
β”‚   β”‚   └── web-scraper.ts        # Playwright scraper
β”‚   β”œβ”€β”€ providers/                # External APIs
β”‚   β”‚   β”œβ”€β”€ hunter.ts             # Hunter.io integration
β”‚   β”‚   β”œβ”€β”€ serper.ts             # Google search
β”‚   β”‚   └── reoon.ts              # Email verification
β”‚   └── trigger-tasks/            # Trigger.dev tasks
β”‚       β”œβ”€β”€ auto-discovery.ts     # 5 chained tasks
β”‚       └── manual-discovery.ts   # Slack-triggered runs
β”œβ”€β”€ profiling/                    # AI profiling service
β”‚   └── python-service/           # FastAPI
β”‚       β”œβ”€β”€ main.py               # /profile endpoint
β”‚       β”œβ”€β”€ profiler.py           # Chain-of-thought profiling
β”‚       β”œβ”€β”€ scorer.py             # Signal extraction + deterministic math
β”‚       β”œβ”€β”€ hallucination_guard.py # Evidence-based cross-check
β”‚       β”œβ”€β”€ nvidia_client.py      # Multi-model LLM client
β”‚       └── config.py             # Settings
β”œβ”€β”€ shared/                       # Shared utilities
β”‚   β”œβ”€β”€ config/env.ts             # Environment validation (Zod)
β”‚   β”œβ”€β”€ llm/nvidia-client.ts      # Multi-model LLM (MiniMax primary)
β”‚   β”œβ”€β”€ llm/prompts.ts            # Production prompts
β”‚   β”œβ”€β”€ llm/grounding.ts          # Evidence-based verification
β”‚   β”œβ”€β”€ observability/tracer.ts   # Trace IDs + token tracking
β”‚   β”œβ”€β”€ pipeline/checkpoint.ts    # Crash recovery
β”‚   β”œβ”€β”€ supabase/client.ts        # DB client
β”‚   └── utils/                    # Retry, rate limiter, logger
└── slack/                        # Slack integration
    β”œβ”€β”€ slack-service.ts          # 3-layer delivery
    └── slack-commands.ts         # /discover, /leads, /status, etc.
```

## Quick Start

See [Setup Guide](docs/setup-guide.md) for detailed instructions.

```bash
# 1. Clone
git clone https://github.com/iDevBuddy/ai-client-acquisition.git
cd ai-client-acquisition

# 2. Install
npm install
cd src/profiling/python-service && pip install -r requirements.txt && cd ../../..

# 3. Configure
cp .env.example .env
# Fill in your API keys (see docs/setup-guide.md)

# 4. Database
# Run supabase/migrations/*.sql on your Supabase project

# 5. Run
npm run trigger:dev          # Start Trigger.dev (task orchestration)
cd src/profiling/python-service && python main.py  # Start AI service
```

## API Keys Required

| Service | Cost | What It Does |
|---------|------|-------------|
| NVIDIA NIM | FREE | AI models (MiniMax + LLaMA) |
| Serper.dev | FREE (2500/mo) | Google search |
| Hunter.io | FREE (25/mo) | Email finding |
| Reoon | FREE (20/day) | Email verification |
| Supabase | FREE | Database |
| Slack | FREE | Notifications |
| Trigger.dev | FREE (50K runs/mo) | Job orchestration |

**Total cost: $0/month**

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

## License

Private β€” All rights reserved.