How saurabhjdsingh/sales-ai-crm works
Purpose and entry points
Sales AI CRM is a white-label sales CRM combining operational CRM records, AI prospecting, Twilio calling, and local call transcription. The Angular SPA boots at frontend/src/main.ts and routes from frontend/src/app/app.routes.ts. Django exposes REST endpoints through backend/config/urls.py; ASGI/WebSocket execution starts at backend/config/asgi.py. Container orchestration is defined in docker-compose.yml.
Client application and API boundary
Angular feature views call the Django API through shared authenticated services. JWT/token handling and route protection reside in frontend/src/app/core/auth/auth.service.ts, frontend/src/app/core/auth/auth.interceptor.ts, and frontend/src/app/core/auth/auth.guard.ts. Feature-local services/stores mediate UI state for CRM entities, e.g. frontend/src/app/features/companies/services/company.service.ts and frontend/src/app/features/deals/services/deal.store.ts.
Core CRM domain
Django apps own persistent business domains and expose the conventional model/serializer/service/view/URL boundary. Companies, contacts, deals, tasks, notes, activities, imports, reports, search, and dashboard form the operational CRM layer. Principal paths include backend/apps/companies/models.py, backend/apps/contacts/models.py, backend/apps/deals/models.py, and backend/apps/tasks/services.py. These records supply the context used by AI, calling, and follow-up workflows.
Accounts, tenancy, and branding
Accounts manages users, invitations, organization branding, and configurable SMTP. It delegates branding behavior through backend/apps/accounts/services/branding.py, while encryption and branded email concerns sit in backend/apps/common/encryption.py and backend/apps/common/email.py. This is a security and tenant-customization boundary: invite/onboarding and email credentials should remain isolated from CRM and AI domain logic.
AI engine and agent orchestration
The AI engine abstracts LLM providers and prompt assembly, supporting OpenAI and Claude via backend/apps/ai_engine/services/providers/openai.py, backend/apps/ai_engine/services/providers/claude.py, and backend/apps/ai_engine/services/context_builder.py. The agent layer orchestrates tool-driven prospect research and sales actions through backend/apps/agent/services/orchestrator.py, backend/apps/agent/services/tool_router.py, and backend/apps/agent/tools/registry.py. Tools access CRM context, research sources, LinkedIn/browser automation, outreach, and ICP/sales-strategy analysis; provider calls are a distinct external-service boundary.
Telephony and conversation intelligence
Telephony encapsulates Twilio integration behind a provider factory and provider interface: backend/apps/telephony/providers/factory.py, backend/apps/telephony/providers/twilio.py, and backend/apps/telephony/services.py. The Angular softphone and call state live in frontend/src/app/features/telephony/twilio-voice.service.ts and frontend/src/app/features/telephony/call-state.service.ts.
During calls, the frontend independently streams local and remote audio over WebSockets using frontend/src/app/features/conversation-intelligence/conversation-intelligence.service.ts. Django Channels consumers in backend/apps/conversation_intelligence/websocket/consumers.py send audio to the provider-independent transcription layer, currently backend/apps/conversation_intelligence/providers/whisper_docker.py. Post-call analysis runs through backend/apps/conversation_intelligence/tasks/ai_analysis.py, persists results, and can generate CRM follow-up actions.
Async processing and infrastructure
Celery provides deferred imports, reminders, AI work, and domain background jobs, configured by backend/config/celery.py; Redis is the broker/scheduler dependency. PostgreSQL is the system of record. Daphne/Channels provides ASGI WebSockets. Docker Compose runs frontend, Django, Celery, PostgreSQL, Redis, and a local faster-whisper-server container. External integrations include OpenAI/Anthropic, Twilio, optional SMTP providers, and LinkedIn/browser automation.
Main entry points: docker-compose.yml Container stack · models.py CRM domain · urls.py REST API · orchestrator.py Sales agent
Components 21
Angular client
- Angular SPA · Routes CRM and sales workflows.
frontend/src/main.ts - Auth boundary · JWT handling, interceptor, and route guard.
frontend/src/app/core/auth/auth.service.ts - CRM feature state · Feature services and stores mediate CRM UI state.
frontend/src/app/features/companies/services/company.service.ts - Softphone state · Twilio voice and call-state client.
frontend/src/app/features/telephony/twilio-voice.service.ts - Audio streaming · Streams local and remote call audio.
frontend/src/app/features/conversation-intelligence/conversation-intelligence.service.ts
Django application
- REST API · HTTP API entry boundary.
backend/config/urls.py - CRM domain · Companies, contacts, deals, tasks, and operational records.
backend/apps/companies/models.py - Accounts & tenancy · Users, invitations, organization branding, and SMTP settings.
backend/apps/accounts/services/branding.py - Secure branded email · Encrypts credentials and sends branded email.
backend/apps/common/encryption.py - AI engine · Builds prompts and selects LLM providers.
backend/apps/ai_engine/services/context_builder.py - Sales agent · Routes tools for research and sales actions.
backend/apps/agent/services/orchestrator.py
Calling intelligence
- Telephony service · Provider factory encapsulates Twilio calling.
backend/apps/telephony/services.py - WebSocket consumers · Receives streamed call audio.
backend/apps/conversation_intelligence/websocket/consumers.py - Transcription provider · Provider-independent local Whisper integration.
backend/apps/conversation_intelligence/providers/whisper_docker.py - Post-call analysis · Persists analysis and generates CRM follow-ups.
backend/apps/conversation_intelligence/tasks/ai_analysis.py
Async & infrastructure
- ASGI runtime · WebSocket application entry point.
backend/config/asgi.py - Celery workers · Runs imports, reminders, AI, and domain work.
backend/config/celery.py - PostgreSQL
- Redis
- Container stack · Runs application services and local Whisper server.
docker-compose.yml
Other components
- External providers · OpenAI, Anthropic, Twilio, SMTP, LinkedIn, and browser automation.
Connections 28
- Angular SPA → Auth boundary: protects routes
- Angular SPA → CRM feature state: uses
- Auth boundary → REST API: authenticated requests
- CRM feature state → REST API: CRM API calls
- Softphone state → Telephony service: call control
- Audio streaming → ASGI runtime: audio WebSockets
- REST API → CRM domain: serves
- REST API → Accounts & tenancy: serves
- CRM domain → PostgreSQL: persists records
- Accounts & tenancy → Secure branded email: branding and SMTP
- Secure branded email → External providers: SMTP
- Sales agent → CRM domain: reads and acts on context
- Sales agent → AI engine: requests reasoning
- Sales agent → External providers: research and automation
- AI engine → External providers: LLM providers
- Telephony service → External providers: Twilio
- ASGI runtime → WebSocket consumers: routes sockets
- WebSocket consumers → Transcription provider: streams audio
- Transcription provider → Post-call analysis: transcript
- Post-call analysis → CRM domain: follow-up actions
- Celery workers → Redis: broker and scheduler
- Celery workers → CRM domain: background jobs
- Container stack → Angular SPA: runs
- Container stack → ASGI runtime: runs
- Container stack → Celery workers: runs
- Container stack → PostgreSQL: runs
- Container stack → Redis: runs
- Container stack → Transcription provider: runs Whisper server