- Campaign created
- Leads enrolled β CampaignLead entries
- Celery scheduler queries: WHERE status='ACTIVE' AND next_execution_time <= now()
- Worker processes step
- AI content generated
- Message dispatched
- Event logged
- State updated
- Next step scheduled
Organization User Lead LeadTag Campaign SequenceStep CampaignLead (state machine) Message MessageEvent Unsubscribe WebhookLog AnalyticsSnapshot AuditLog
Queue Types:
- dispatch_queue
- webhook_queue
- import_queue
- ai_queue
- analytics_queue
Prevents bottlenecks.
build_prompt() β inject lead context β call Gemini β sanitize output β store generated content β dispatch
Add:
- Rate limiting
- Retry strategy
- Timeout fallback
Used only for:
- Live dashboard updates
- Campaign status streaming
- Realtime notification system
Not used as primary database.
- Idempotency key per Message
- Unique constraint on campaign_id + lead_id
- Soft deletes
- Retry with exponential backoff
- Dead letter queue
- Throttling per sender
- Random dispatch jitter
- Bounce threshold auto-pause
- Domain verification checks
- Global suppression pre-dispatch validation
Phase 1:
- Single server + workers
Phase 2:
- Dedicated worker machines
- Load balanced web nodes
Phase 3:
- Messaging microservice separation
- Event streaming architecture