LeadGen Pro, Multi-Tenant LinkedIn Automation SaaS Platform
Production multi-tenant SaaS platform that lets agencies run LinkedIn outreach across many client accounts safely. True rolling-window rate limits, distributed locking, circuit breaker on LinkedIn 422 errors, working-hours scheduling, JWT auth, Fernet-encrypted credentials, full agency dashboard.
TL;DR
A production multi-tenant SaaS platform that lets B2B agencies run LinkedIn outreach across many client accounts safely. True rolling-window rate limits (not calendar-based), distributed locking prevents duplicate task execution, circuit breaker on LinkedIn 422 errors, working-hours scheduling, JWT auth, Fernet-encrypted credentials, and a full agency dashboard with campaign wizard, prospect grid, and template library.
The Problem
Agencies running LinkedIn outreach across many client accounts hit the same wall:
- Calendar-based rate limits silently overspend at midnight. Most automation tools reset counters at 00:00 UTC, which means a tool sending 25 invites at 23:59 sends another 25 at 00:01. LinkedIn’s anti-abuse looks at rolling windows.
- Single accounts get restricted when working-hours, cooldowns, and per-action limits are not enforced together.
- No consolidated dashboard. Agency owners cannot see invites accepted, messages sent, and acceptance-rate trends across their entire book of clients.
- Apify scraping does not integrate cleanly with outreach automation, leaving the operator pasting CSVs between tools.
LeadGen Pro fixes all four at production grade.
Outcome
Specific production wins:
- Per-client rate enforcement. Each LinkedIn account inside an agency holds its own daily and weekly ceilings (25 invites/day, 100/week, 50 messages/day, 5 InMails/day). All independent.
- True rolling-window rate limits. Every action timestamp is logged. Eligibility check runs a 24-hour-back SQL query, so the system never overspends at calendar boundaries.
- Circuit breaker on LinkedIn rate-limit errors. On any LinkedIn 422, the system enters an 8-hour client-wide cooldown. All pending tasks pause. Tasks resume automatically.
- Apify webhook auto-import. Apify run completion fires a webhook into LeadGen Pro that bulk-imports the prospects into the right campaign with provider-IDs resolved.
- Fernet-encrypted LinkedIn credentials at rest. JWT for user auth, bcrypt for password hashing, Fernet for stored LinkedIn session credentials.
- Working-hours and timezone-aware scheduling. Each client has its own timezone and configured business hours. The worker only acts during those hours.
Tech Stack
| Component | Technology | Purpose |
|---|---|---|
| Frontend | Next.js 15 App Router + TypeScript (Vercel) | Agency dashboard, campaign wizard, prospect grid |
| Backend API | FastAPI + SQLAlchemy (Vercel) | Auth, CRUD, webhook receivers |
| Worker | Celery + Python (Render) | Background task processing |
| Scheduler | Celery Beat (Render) | Periodic task scheduling (campaign processing every minute) |
| Database | PostgreSQL (Supabase) | Primary data store with multi-tenant isolation |
| Cache and Queue | Redis (Render) | Message broker, result backend, distributed locking |
| LinkedIn API | Unipile | Professional-grade LinkedIn automation provider |
| Prospect Discovery | Apify | Search-result scraping with webhook completion |
Key Functionality
- Multi-account client management with Unipile hosted authentication and per-client rate limits, working hours, and timezone configuration.
- 4-step campaign wizard: basic info, target criteria (keywords, title, company, location), template selection, scheduling. Campaigns auto-complete when all prospects reach terminal state.
- Prospect management with bulk Apify import, CSV import, status tracking, 30-day timeout on unaccepted invites, provider-ID resolution.
- Message templates with dynamic personalisation variables (
{{firstName}},{{company}},{{title}}), 300-character connection-note enforcement, live preview. - Automation engine with human-like random delays (30 to 120 seconds), ETA-based scheduling, working-hours enforcement, graceful recovery after circuit-breaker cooldowns.
- Webhook integration for connection acceptances (triggers auto-message workflow), account-status changes, Apify completion, with full activity log.
- Agency dashboard with total clients, active campaigns, connections, messages, real-time activity feed, campaign cards with progress bars.
Agency dashboard, campaign wizard, prospect grid, rolling-window rate limiter logs
Walkthrough, agency dashboard plus campaign wizard plus rolling-window rate limiter
Building something similar?
If a multi-agent pipeline, voice AI deployment, or production automation system is on your roadmap, let's talk through how this applies to your context.