Skip to main content
← Wednesday's Workflows

Sales Enablement System Architecture 🏗️

From 10 to 10,000 deals/month with AI agents and CRM sync

June 12, 2025
18 min read
💼 Sales🏗️ Architecture📊 Scalable🔒 SOC2
🎯This Week's Journey

From prompts to production sales platform.

Monday: 3 core prompts for deal intelligence, email enrichment, and pipeline analysis. Tuesday: automated code with Salesforce sync. Wednesday: team workflows across sales, ops, and leadership. Thursday: complete technical architecture with AI agents, real-time CRM integration, and enterprise-grade security. Scale from 10 to 10,000 deals/month.

📋

Key Assumptions

1
Track 10-10,000 deals/month across multiple sales teams
2
Integrate with Salesforce, HubSpot, or Pipedrive CRM
3
Real-time email enrichment from Gmail/Outlook APIs
4
SOC2 Type II compliance required for enterprise customers
5
Multi-tenant with org-level data isolation

System Requirements

Functional

  • Deal intelligence: score deals, identify risks, suggest next actions
  • Email enrichment: extract contacts, companies, sentiment from threads
  • Pipeline analysis: forecast close dates, revenue, and churn risk
  • CRM sync: bidirectional updates with conflict resolution
  • Analytics: dashboards for win rates, deal velocity, rep performance
  • Notifications: Slack/email alerts for high-value deals and risks
  • Search: semantic search across deals, emails, and notes

Non-Functional (SLOs)

latency p95 ms500
freshness min5
availability percent99.9
deal scoring latency ms2000
crm sync latency sec30

💰 Cost Targets: {"per_deal_usd":0.15,"per_email_enrichment_usd":0.05,"per_user_per_month_usd":50}

Agent Layer

planner

L4

Decomposes sales tasks into subtasks, selects appropriate agents and tools

🔧 CRM metadata API, User permission service, Task decomposition LLM

⚡ Recovery: If decomposition fails, fall back to single-agent execution, If tool unavailable, suggest manual workflow, Retry with simplified plan (max 2 retries)

deal_scorer

L3

Scores deals based on historical data, engagement signals, and market context

🔧 ML scoring model (gradient boosting), Feature store (deal velocity, engagement score), Salesforce API (historical win rates)

⚡ Recovery: If ML model fails, fall back to rule-based scoring, If feature store unavailable, use cached features (max 1 hour old), If confidence < 0.6, flag for human review

email_enricher

L2

Extracts contacts, companies, sentiment, and action items from email threads

🔧 Gmail/Outlook API, NER model (spaCy + custom), Sentiment classifier, Clearbit API (company enrichment)

⚡ Recovery: If NER fails, extract emails via regex, If sentiment model unavailable, default to neutral (0), If Clearbit rate-limited, queue for later enrichment

pipeline_forecaster

L3

Predicts quarterly revenue, close dates, and churn risk using time-series models

🔧 Time-series model (Prophet or ARIMA), Feature store (deal velocity, stage duration), Salesforce reports API

⚡ Recovery: If model training fails, use last known good model, If data insufficient (<3 months), return wide confidence interval, If prediction outlier, flag for manual review

evaluator

L3

Validates outputs from other agents, checks quality, detects hallucinations

🔧 Validation rules engine, Cross-reference with CRM data, Hallucination detector (consistency checks)

⚡ Recovery: If validation fails, route to human review queue, If ground truth unavailable, use heuristic checks, If quality < 0.7, block output and retry

guardrail

L4

Enforces policies, redacts PII, checks for sensitive data leakage

🔧 PII detection (AWS Comprehend or custom NER), Policy engine (OPA or custom rules), Audit logger

⚡ Recovery: If PII detection fails, block output entirely (fail-safe), If policy check times out, apply strictest policy, If audit log unavailable, queue for later write

ML Layer

Feature Store

Update: Real-time for engagement metrics, daily batch for historical aggregates

  • deal_velocity (days in current stage)
  • engagement_score (email replies, meeting attendance)
  • contact_seniority (VP+, C-level, IC)
  • company_size (employees, revenue)
  • historical_win_rate (by rep, by industry)
  • email_sentiment_trend (last 30 days)
  • competitor_mentions (count, sentiment)
  • stage_duration_percentile (vs historical)

Model Registry

Strategy: Semantic versioning with A/B testing (10% traffic to new model)

  • deal_scorer_v3
  • email_sentiment_classifier
  • pipeline_forecaster

Observability Stack

Real-time monitoring, tracing & alerting

0 active
SOURCES
Apps, Services, Infra
COLLECTION
10 Metrics
PROCESSING
Aggregate & Transform
DASHBOARDS
5 Views
ALERTS
Enabled
📊Metrics(10)
📝Logs(Structured)
🔗Traces(Distributed)
deal_scoring_latency_p95_ms
email_enrichment_success_rate
crm_sync_errors_per_hour
agent_execution_time_by_type
llm_token_usage_per_request
feature_store_cache_hit_rate

Deployment Variants

🚀

Startup Architecture

Fast to deploy, cost-efficient, scales to 100 competitors

Infrastructure

Vercel for frontend
Serverless functions (Lambda/Cloud Run)
Managed PostgreSQL (RDS/Cloud SQL)
Managed Redis (ElastiCache/Memorystore)
Single region (US-East or EU-West)
OpenAI API for LLMs
No Kubernetes (too complex)
Single-tenant architecture
Manual deployments via CI/CD
Basic monitoring (CloudWatch/Stackdriver)
SOC2 compliance prep (not certified yet)
Cost: $200-800/mo for 10-1K deals/month

Risks & Mitigations

⚠️ LLM hallucinations lead to incorrect deal scores

Medium

✓ Mitigation: 4-layer validation (confidence, cross-reference, consistency, human review). Shadow mode testing before production. Hallucination rate <1%.

⚠️ Salesforce API rate limits exceeded during peak hours

High

✓ Mitigation: Request queue with priority (high-value deals first). Retry with exponential backoff. Cache frequently accessed data in Redis. Negotiate higher rate limits with Salesforce.

⚠️ PII leakage to LLM providers

Low

✓ Mitigation: PII detection before every LLM call (fail-safe). Redaction service with 99.9% precision. Audit logs for all LLM requests. BYO keys for enterprise customers.

⚠️ Model drift reduces scoring accuracy over time

High

✓ Mitigation: Weekly drift monitoring (KL divergence, rolling RMSE). Automated retraining pipeline. A/B testing before rollout. Human review for low-confidence predictions.

⚠️ Multi-tenant data leakage (Org A sees Org B's deals)

Low

✓ Mitigation: Org-level sharding in database. Row-level security (RLS) policies. API gateway enforces org_id filtering. Quarterly penetration testing. Dedicated VPCs for enterprise.

⚠️ Email sync fails silently, missing critical deal updates

Medium

✓ Mitigation: Webhook health checks every 5 minutes. Alerting if no emails received in 1 hour. Manual re-sync option in UI. Backup polling mechanism (hourly) if webhooks fail.

⚠️ Cost overruns from excessive LLM API calls

Medium

✓ Mitigation: Per-org monthly token budget. Rate limiting (10 scores/min per user). Cache LLM responses (1-hour TTL). Cost dashboard with alerts at 80% of budget.

🧬

Evolution Roadmap

Progressive transformation from MVP to scale

🌱
Phase 1Q2 2025

Phase 1: MVP (0-3 months)

1
Launch core features: deal scoring, email enrichment, CRM sync
2
Onboard 10 pilot customers (100 deals/month each)
3
Achieve 95% uptime SLA
Complexity Level
🌿
Phase 2Q3 2025

Phase 2: Scale (3-6 months)

1
Scale to 100 customers (1K deals/month each)
2
Add pipeline forecasting and analytics
3
Achieve 99% uptime SLA
Complexity Level
🌳
Phase 3Q4 2025 - Q1 2026

Phase 3: Enterprise (6-12 months)

1
Scale to 1,000 customers (10K deals/month total)
2
Add multi-region deployment and data residency
3
Achieve 99.9% uptime SLA
Complexity Level
🚀Production Ready
🏗️

Complete Systems Architecture

9-layer architecture from presentation to security

1
🌐

Presentation

4 components

Web Dashboard
Mobile App
Slack Bot
Chrome Extension
2
⚙️

API Gateway

4 components

Load Balancer
Rate Limiter
Auth (OIDC/SAML)
API Versioning
3
💾

Agent Layer

6 components

Planner Agent
Deal Scorer Agent
Email Enrichment Agent
Pipeline Forecaster Agent
Evaluator Agent
Guardrail Agent
4
🔌

ML Layer

6 components

Feature Store
Model Registry
Offline Training
Online Inference
Evaluation Loop
Prompt Store
5
📊

Integration

4 components

Salesforce Adapter
Gmail/Outlook Sync
Slack API
Webhook Manager
6
🌐

Data

4 components

PostgreSQL (deals, users)
Redis (cache, queue)
S3 (emails, attachments)
Elasticsearch (search)
7
⚙️

External

4 components

Salesforce API
Gmail/Outlook API
Clearbit API
OpenAI/Anthropic
8
💾

Observability

4 components

Metrics (Prometheus)
Logs (CloudWatch)
Traces (Jaeger)
Dashboards (Grafana)
9
🔌

Security

4 components

KMS (secrets)
WAF
PII Redaction
Audit Logger
🔄

Sequence Diagram - Deal Scoring Flow

Automated data flow every hour

Step 0 of 10
Sales RepAPI GatewayPlanner AgentDeal Scorer AgentEvaluator AgentGuardrail AgentSalesforceML InferencePOST /deals/{id}/scoreRoute to scoring workflowFetch deal + contact historyScore deal with contextRun scoring modelReturn score + confidenceValidate score qualityCheck for PII leakageUpdate deal score field200 OK + score breakdown

Data Flow - Deal Scoring Workflow

Sales rep request → Salesforce update in 2.1 seconds

1
Sales Rep0s
Clicks 'Score Deal' buttonDeal ID
2
API Gateway0.05s
Authenticates and routesJWT token + deal ID
3
Planner Agent0.2s
Decomposes task, selects toolsExecution plan
4
Salesforce Adapter0.4s
Fetches deal + contact historyDeal object + emails
5
Feature Store0.5s
Retrieves computed features8 features (velocity, engagement, etc.)
6
Deal Scorer Agent2.0s
Runs ML model + LLM explanationScore + risk factors
7
Evaluator Agent2.5s
Validates score qualityQuality score (0.92)
8
Guardrail Agent2.8s
Checks for PII leakageRedacted output
9
Salesforce Adapter3.1s
Updates deal score fieldPATCH request
10
Audit Logger3.2s
Logs action for complianceAudit entry
11
Sales Rep3.3s
Sees updated score in UIScore + breakdown
1
Volume
10-100 deals/month
Pattern
Monolith + Serverless
🏗️
Architecture
Next.js app on Vercel
Serverless functions (Lambda/Cloud Run)
PostgreSQL (managed)
Redis (managed)
Cost & Performance
$200/mo
per month
2-3s p95
2
Volume
100-1,000 deals/month
Pattern
Queue + Workers
🏗️
Architecture
App server (ECS/Cloud Run)
Message queue (SQS/Pub/Sub)
Worker pool (auto-scaling)
PostgreSQL + read replicas
Redis cluster
Cost & Performance
$800/mo
per month
1-2s p95
3
Volume
1,000-10,000 deals/month
Pattern
Multi-Agent Orchestration
🏗️
Architecture
Load balancer (ALB/Cloud Load Balancing)
Agent framework (LangGraph/CrewAI)
Event bus (Kafka/EventBridge)
Distributed cache (Redis Cluster)
Sharded PostgreSQL
Elasticsearch for search
Cost & Performance
$3,000/mo
per month
500ms p95
Recommended
4
Volume
10,000+ deals/month
Pattern
Enterprise Multi-Region
🏗️
Architecture
Kubernetes (EKS/GKE)
Multi-region deployment
Global load balancer
Kafka for event streaming
Multi-LLM failover (OpenAI + Anthropic + Azure)
Replicated databases (primary + 2 replicas)
Dedicated VPC per tenant
Cost & Performance
$10,000+/mo
per month
300ms p95

Key Integrations

Salesforce CRM

Protocol: REST API (v58.0)
User authorizes via OAuth
System fetches access token
Bidirectional sync: read opportunities, contacts, accounts
Write back: deal scores, risk factors, next actions
Webhook listener for real-time updates

Gmail/Outlook Email APIs

Protocol: Gmail API v1 / Microsoft Graph API
User grants email read permission
System watches mailbox for new threads
Webhook triggers email enrichment agent
Extracted data synced to CRM
Attachments stored in S3 with encryption

Slack Notifications

Protocol: Slack Web API + Webhooks
High-value deal scored → Slack message to #sales channel
Risk detected → DM to account owner
Pipeline forecast ready → Post to #leadership
Interactive buttons for quick actions

Clearbit Enrichment

Protocol: REST API
Email domain extracted → Clearbit company lookup
Enrich with company size, industry, funding
Cache results in Redis (7-day TTL)
Fall back to LinkedIn scraping if Clearbit unavailable

Security & Compliance

Failure Modes & Fallbacks

FailureFallbackImpactSLA
Salesforce API downQueue updates in Redis, retry with exponential backoff (max 5 attempts)Delayed sync (up to 30 min), no data loss99.5%
LLM API rate limit exceededSwitch to backup LLM provider (Anthropic → OpenAI → Azure), queue requests if all exhaustedIncreased latency (2-5s), no functionality loss99.9%
Deal scoring model returns low confidence (<0.6)Route to human review queue, use rule-based scoring as interimManual review required, slower turnaround (hours vs seconds)95%
Email enrichment fails (NER model error)Extract emails via regex, skip company enrichment, flag for manual reviewReduced data quality, no blocking errors99%
Database primary node failurePromote read replica to primary (30s failover), redirect traffic30s downtime, read-only mode during failover99.95%
PII detection service unavailableBlock all LLM calls (fail-safe), queue requests for later processingDegraded functionality, no PII leakage risk100% (safety first)
Feature store cache miss (Redis down)Query PostgreSQL directly (slower), rebuild cache on recoveryIncreased latency (500ms → 2s), no data loss99%

RAG vs Fine-Tuning

Hallucination Detection

LLMs hallucinate fake contacts, inflated deal amounts, or nonexistent companies
L1
Confidence scores (<0.7 = flag for review)
L2
Cross-reference with Salesforce data (contact exists? deal amount matches?)
L3
Logical consistency (close date before create date? negative deal amount?)
L4
Human review queue for flagged outputs
0.8% hallucination rate, 98% caught before production

Evaluation Framework

Deal Scoring RMSE
12.3target: <15
Email Sentiment F1
0.89target: >0.85
Pipeline Forecast MAPE
8.2%target: <10%
Hallucination Rate
0.8%target: <1%
Testing: Shadow mode: 500 deals scored in parallel with manual scoring, compare accuracy weekly

Dataset Curation

1
Collect: 50K deals - Export from Salesforce
2
Clean: 42K usable - Remove duplicates, test deals, incomplete records
3
Label: 42K labeled - ($$21K)
4
Augment: +8K synthetic - Edge case generation (high-value deals, churn risks)
50K high-quality examples (Cohen's Kappa: 0.88)

Agentic RAG

Agent iteratively retrieves based on reasoning
Deal mentions 'enterprise contract' → RAG retrieves similar deals → Agent reasons 'need legal review timeline' → RAG retrieves legal approval data → Scoring adjusted with full context
💡 Not one-shot retrieval. Agent decides what else it needs to know, improving accuracy by 15%.

Model Drift Detection

Tech Stack Summary

LLMs
OpenAI GPT-4, Anthropic Claude, Azure OpenAI
Orchestration
LangGraph for agent workflows, Temporal for long-running jobs
Database
PostgreSQL (primary), Elasticsearch (search), Redis (cache/queue)
Compute
Kubernetes (EKS/GKE) for enterprise, Lambda/Cloud Run for startup
ML Infra
XGBoost, Prophet, HuggingFace Transformers, Pinecone (vector DB)
Monitoring
Prometheus (metrics), Jaeger (traces), CloudWatch/Stackdriver (logs), Grafana (dashboards)
Security
AWS KMS/Google Secret Manager, AWS Comprehend (PII), OPA (policies), WAF
Integrations
Salesforce REST API, Gmail API, Microsoft Graph, Slack API, Clearbit
🏗️

Need a Custom Sales Enablement System?

We'll architect, build, and deploy a production-grade sales platform tailored to your CRM, workflows, and compliance needs.

©

2026 Randeep Bhatia. All Rights Reserved.

No part of this content may be reproduced, distributed, or transmitted in any form without prior written permission.