Skip to content

aiagentwithdhruv/dealpulse

Repository files navigation

DealPulse

Real-Time AI Sales Coaching & Pipeline Intelligence

DealPulse listens to your sales calls in real time, detects objections, coaches reps with AI-generated responses, scores deal probability, and generates post-call analytics — automatically.

Built for B2B sales teams who want to close more deals, faster.

Python FastAPI Next.js TypeScript Supabase License


The Problem

Sales teams lose $1.3M+ annually per 50-rep team to missed objections, inaccurate forecasts, and manual post-call work.

  • Reps miss 40% of buying signals during calls
  • Managers review less than 5% of calls
  • Pipeline forecasts are 40-60% wrong
  • Post-call CRM updates take 30+ minutes per call

How DealPulse Solves It

Rep starts call
    -> Audio streams to Deepgram (real-time transcription)
    -> AI detects objections in transcript (every 3-5 seconds)
    -> GPT-4o generates coaching suggestions (<2 seconds)
    -> Deal score updates live based on call signals
    -> Call ends -> AI generates summary + action items (<30 seconds)

Features

Real-Time Call Coaching

  • Live objection detection with 8 objection types (pricing, timing, authority, need, competition, risk, status quo, integration)
  • AI-generated response suggestions delivered via WebSocket in <2 seconds
  • Playbook-linked coaching templates
  • Suggestion acceptance tracking for continuous improvement

Call Transcription

  • Deepgram Nova-2 streaming with speaker diarization (rep vs prospect)
  • Word-level timestamps and confidence scoring
  • Searchable transcript library
  • Full-text search across all call transcripts

Deal Scoring

  • Heuristic weighted-signal scoring (0-100) with 6 factors:
    • Engagement level, objection handling, next steps commitment
    • Stakeholder involvement, recency, stage progression
  • Factor attribution (what drove the score up/down)
  • Risk factor identification (stalled deals, declining sentiment)
  • Score history tracking per deal

Pipeline Analytics

  • Visual Kanban pipeline by stage
  • Revenue forecasting with confidence bands
  • Stage velocity metrics and conversion rates
  • Stuck deal alerts and at-risk flagging

Post-Call Reports

  • AI-generated call summaries with key discussion points
  • Key moments timeline (objections, commitments, questions)
  • Action items extraction with owners
  • Talk-to-listen ratio and engagement metrics

Lead Scoring

  • Composite scoring: ICP match + engagement + intent + recency
  • Score decay for inactive leads (-2 points/week)
  • Hot lead badges (score > 80)
  • Lead-to-deal conversion tracking

Additional Features

  • Recording Library — S3 storage, transcript-synced playback, bookmarks, shareable clips
  • Playbook Management — Discovery, demo, negotiation, and closing playbooks with objection response scripts
  • Multi-Tenant — Organization-scoped data isolation with PostgreSQL RLS
  • RBAC — Admin, manager, rep, and viewer roles with fine-grained permissions
  • Notifications — Real-time alerts for deal risks, score changes, and coaching feedback

Tech Stack

Layer Technology Purpose
Frontend Next.js 14+, TypeScript, Tailwind CSS Dashboard UI (19 pages, 40+ components)
Backend Python 3.11+, FastAPI, Pydantic v2 REST API + WebSocket (90+ endpoints)
Database Supabase (PostgreSQL + pgvector) 25 tables with RLS, multi-tenant
Cache Redis Suggestion cache, pub/sub, rate limiting
AI (STT) Deepgram Nova-2 Real-time call transcription
AI (LLM) OpenAI GPT-4o + GPT-4o-mini Coaching, summaries, classification
Storage AWS S3 Call recordings
Queue AWS SQS Async post-call analytics
Deployment Docker, AWS ECS Fargate Container orchestration

Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 20+
  • Docker & Docker Compose
  • Supabase project (free tier works)
  • OpenAI API key
  • Deepgram API key

1. Clone and configure

git clone https://github.com/aiagentwithdhruv/dealpulse.git
cd dealpulse

# Backend config
cp backend/.env.example backend/.env
# Edit backend/.env with your API keys

# Frontend config
cp frontend/.env.local.example frontend/.env.local
# Edit frontend/.env.local with your Supabase keys

2. Run with Docker (recommended)

docker-compose up
Service URL
Frontend http://localhost:3000
Backend API http://localhost:8000
API Docs (Swagger) http://localhost:8000/docs
Redis localhost:6379

3. Database setup

# Option A: Supabase CLI
supabase db push

# Option B: Run SQL directly in Supabase Dashboard
# Copy contents of supabase/migrations/001_initial_schema.sql

4. Run without Docker (development)

# Terminal 1: Backend
cd backend
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000

# Terminal 2: Frontend
cd frontend
npm install
npm run dev

# Terminal 3: Redis
docker run -p 6379:6379 redis:7-alpine

Architecture

                    Sales Rep / Manager / Admin
                              |
                         AWS ALB
                    (TLS + WebSocket)
                              |
              +---------------+---------------+
              |                               |
        Next.js 14                     FastAPI Backend
     (Role-gated UI)              (REST + WebSocket API)
              |                               |
              |                    +----------+----------+
              |                    |                     |
              |              Services Layer         Workers
              |           (Call, Coaching,       (Post-call,
              |            Scoring, Analytics)    CRM sync)
              |                    |                     |
              |              Repositories               |
              |                    |                     |
              +---> Supabase (PostgreSQL + pgvector) <--+
                              |
                    +---------+---------+
                    |         |         |
                 Redis    Deepgram   OpenAI
              (cache,     (STT)     (LLM)
               pub/sub)
                    |
                  AWS S3
              (recordings)

Real-Time Call Flow

Audio Stream -> Deepgram WebSocket -> Transcript Chunks (every 1-3s)
                                          |
                                    Objection Detector (GPT-4o-mini, every 3-5s)
                                          |
                                    [If objection detected, confidence > 0.7]
                                          |
                                    Coaching Engine (GPT-4o, <2s)
                                          |
                                    Deal Scoring (heuristic, <100ms)
                                          |
                              WebSocket Push to Frontend
                    (transcript + objection + suggestion + score)

API Overview

Section Endpoints Description
Auth 8 Login, signup, refresh, invite, profile
Calls 16 CRUD, start/end, transcript, analytics, recording
Deals 15 CRUD, pipeline, forecast, scoring, risk factors
Leads 10 CRUD, scoring, conversion, enrichment
Contacts 8 CRUD, interactions, deals, calls
Playbooks 11 CRUD, steps, reorder, effectiveness
Recordings 9 List, playback, bookmarks, share, search
AI/Coaching 9 Suggest, analyze, detect, score, decision logs
Analytics 10 Dashboard, pipeline, reps, objections, forecast
Admin 18 Org, users, teams, AI config, audit, usage
WebSocket 2 Live call stream, dashboard updates
Health 2 Basic + detailed health check

Base URL: /api/v1

Interactive docs at /docs (Swagger) and /redoc (ReDoc) when running locally.


Database Schema

25 tables with multi-tenant isolation (RLS), 10 PostgreSQL enums, 60+ indexes:

Category Tables
Core tenants, users, teams, contacts
Sales deals, deal_scores, deal_history, leads, lead_scores
Calls calls, call_transcripts, call_segments, recordings, recording_bookmarks
AI objection_detections, coaching_suggestions, objection_types (8 seeded)
Content playbooks, playbook_steps, contact_interactions
Analytics call_analytics, analytics_snapshots
Integration crm_connections, crm_sync_logs
System notifications, audit_logs, ai_decision_logs, api_keys

AI Cost Model

Component Model Cost per Call
Transcription Deepgram Nova-2 ~$0.30 (15 min avg)
Objection Detection GPT-4o-mini ~$0.005 (5-10 classifications)
Coaching Suggestions GPT-4o ~$0.10-0.30 (1-3 suggestions)
Post-Call Summary GPT-4o ~$0.05-0.10 (async)
Deal Scoring Heuristic $0.00 (local compute)
Total ~$0.50-$0.80

Project Structure

dealpulse/
├── backend/                    # Python FastAPI
│   ├── app/
│   │   ├── main.py             # App entry + lifespan
│   │   ├── core/               # Config, security, middleware, exceptions
│   │   ├── routes/             # 15 API routers
│   │   ├── services/           # 11 business logic services
│   │   ├── repositories/       # 14 data access repos
│   │   ├── schemas/            # 15 Pydantic model files
│   │   ├── integrations/       # Deepgram, OpenAI, Redis, S3, CRM clients
│   │   ├── prompts/            # AI prompt templates (versioned)
│   │   └── workers/            # Async job processors
│   ├── requirements.txt
│   └── Dockerfile
├── frontend/                   # Next.js 14 TypeScript
│   ├── app/                    # 19 pages (auth, dashboard, manager, admin)
│   ├── components/             # 40+ components (UI primitives + domain)
│   ├── hooks/                  # useAuth, useWebSocket, useLiveCall, useDeals
│   ├── lib/                    # API client, WebSocket, utils
│   ├── services/               # 10 typed API service modules
│   ├── types/                  # Full TypeScript type definitions
│   └── Dockerfile
├── supabase/
│   └── migrations/             # SQL schema (25 tables, RLS, indexes)
├── docs/
│   ├── PRD.md                  # Product requirements (16 modules)
│   ├── ARCHITECTURE.md         # System architecture + data flows
│   ├── API_SPEC.md             # Full API specification (13 sections)
│   ├── DB_SCHEMA.md            # Database schema documentation
│   ├── DEPLOYMENT.md           # AWS ECS deployment guide
│   └── PROMPTS.md              # AI prompt templates with cost tracking
├── docker-compose.yml
├── CLAUDE.md                   # AI coding instructions
└── README.md

Environment Variables

Backend (backend/.env)

SUPABASE_URL=https://xxx.supabase.co
SUPABASE_ANON_KEY=eyJ...
SUPABASE_SERVICE_ROLE_KEY=eyJ...
DATABASE_URL=postgresql://...

DEEPGRAM_API_KEY=dg-xxx
OPENAI_API_KEY=sk-xxx

REDIS_URL=redis://localhost:6379

AWS_S3_BUCKET=dealpulse-recordings
AWS_ACCESS_KEY_ID=AKIA...
AWS_SECRET_ACCESS_KEY=xxx
AWS_REGION=us-east-1

APP_ENV=development
FRONTEND_URL=http://localhost:3000
JWT_SECRET=change-me

Frontend (frontend/.env.local)

NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_WS_URL=ws://localhost:8000
NEXT_PUBLIC_SUPABASE_URL=https://xxx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ...

Documentation

Document Description
Product Requirements 16 feature modules, user flows, milestones, pricing
Architecture System design, data flows, AI pipeline, key decisions
API Specification 90+ endpoints, WebSocket events, request/response schemas
Database Schema 25 tables, indexes, RLS policies, relationship diagram
Deployment Guide Docker, AWS ECS Fargate, CI/CD, monitoring
AI Prompts All prompt templates with versioning and cost tracking

Roadmap

  • Real-time call transcription (Deepgram)
  • Objection detection (8 types)
  • AI coaching suggestions (GPT-4o)
  • Heuristic deal scoring (6 factors)
  • Post-call analytics (summary, action items)
  • Pipeline analytics (Kanban, forecast)
  • Lead scoring
  • Playbook management
  • Recording library
  • Multi-tenant RBAC
  • CRM integration (Salesforce, HubSpot, Zoho)
  • ML deal scoring (XGBoost)
  • Conversation intelligence (topic extraction, buying signals)
  • Team performance leaderboards
  • Slack/email notification integrations
  • Mobile app

Key Learnings

Architecture decisions and production insights from building this system.

  1. Heuristic scoring beats ML when you have no training data. Weighted signal scoring (6 factors) ships immediately and is explainable to sales managers. ML can be layered on top once you have 10K+ scored deals.
  2. Dual-LLM cost optimization is mandatory for real-time. GPT-4o-mini for classification ($0.005/call) vs GPT-4o for coaching ($0.25/call) — a 50x cost difference. Always classify first, reason second.
  3. WebSocket fan-out via Redis pub/sub scales better than in-process event emitters. One transcription stream can feed multiple consumers (coaching, scoring, analytics) without coupling.
  4. Deepgram Nova-2 interim results give you 1-3s latency for objection detection. Wait for final results only for the recording library (accuracy > speed).
  5. Multi-tenant RLS at the database level means you can never accidentally leak data between orgs, even if service code has a bug. Defense in depth.

Screenshots


Social Snippets

LinkedIn Post

Just shipped DealPulse — a production-grade AI sales coaching platform.

It listens to sales calls in real-time and:
- Detects objections across 8 categories
- Generates AI coaching responses in <2 seconds
- Scores deal probability with 6-factor heuristic model
- Auto-generates post-call summaries + action items

The cost? ~$0.50-$0.80 per call (Deepgram STT + GPT-4o coaching).

Built with FastAPI + Next.js 14 + Supabase + Deepgram + OpenAI.
25 tables, 90+ API endpoints, real-time WebSocket coaching.

Full code: github.com/aiagentwithdhruv/dealpulse

#AI #SalesIntelligence #ProductEngineering #AiwithDhruv

Twitter/X Thread

1/ Just built a production AI sales coaching engine from scratch.

Not a demo. Not a notebook. A real system with 200 files, 25 DB tables, and 90+ API endpoints.

Here's the architecture:

2/ Audio streams to Deepgram Nova-2 → transcript chunks every 1-3s
→ GPT-4o-mini classifies objections (8 types, $0.005/call)
→ GPT-4o generates coaching suggestions (<2s)
→ Heuristic deal scoring updates live (6 weighted signals)

3/ Cost per call: ~$0.50-$0.80. A human sales coach costs $200/hour.

That's a 500x cost reduction for real-time coaching.

4/ Code: github.com/aiagentwithdhruv/dealpulse

Contributing

  1. Fork the repo
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Credits

Built during Euron's Zero-to-Production: AI Product Engineering course.

Production-grade implementation by @AiwithDhruv.


License

MIT License. See LICENSE for details.


Built by Dhruv | LinkedIn | YouTube

About

Real-Time AI Sales Coaching & Pipeline Intelligence - Live call transcription, objection detection, AI coaching suggestions, deal scoring, and pipeline analytics. Built with FastAPI + Next.js + Supabase + Deepgram + OpenAI.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors