Skip to main content

System Architecture Diagram

Core Services

1. Agent Service (Service/AgentService.py)

Responsibilities:
  • Create and manage AI agents
  • Configure system prompts and behavior
  • Handle agent lifecycle (create, update, delete)
  • Manage conversation context
Key Classes:
Features:
  • Multi-provider AI support (Gemini, OpenAI, Hume)
  • Custom system prompts
  • Tool/function calling
  • Context management

2. Call Service (Service/CallService.py)

Responsibilities:
  • Manage voice call lifecycle
  • Handle call routing and connection
  • Process call recordings
  • Track call metadata
Key Methods:
Call Flow:
  1. Create call request
  2. Initialize call connection
  3. Stream audio to AI agent
  4. Process agent responses
  5. Return audio to caller
  6. Log call metadata

3. Organization Service (Service/OrganizationService.py)

Responsibilities:
  • Manage multi-tenant organizations
  • Handle credentials per organization
  • Manage API keys and authentication
  • Organization billing and usage
Features:
  • Organization creation
  • Member management
  • API key generation
  • Usage tracking

4. Scheduler Service (scheduler/scheduler.py)

Responsibilities:
  • Schedule calls at specific times
  • Manage recurring call patterns
  • Trigger batch operations
  • Handle call execution
Implementation:
  • Uses APScheduler for scheduling
  • Stores schedule in Supabase
  • Supports cron expressions

5. Batch Call Service (Service/BatchCallService.py)

Responsibilities:
  • Process multiple calls in bulk
  • Handle CSV upload and parsing
  • Manage batch execution progress
  • Generate batch reports
Workflow:
  1. Upload call list (CSV/JSON)
  2. Validate phone numbers
  3. Schedule calls
  4. Monitor progress
  5. Generate results report

AI Bridges

AI bridges abstract the different AI provider APIs into a common interface.

Supported Providers

Bridge Interface

Communication Layer

Telephony Providers

Twilio:
  • Incoming call handling via webhooks
  • TwiML response generation
  • Real-time media streaming
  • Call recording
Plivo:
  • Similar to Twilio
  • Alternative provider for redundancy
  • REST API for outbound calls

LiveKit Integration

For real-time communication:
  • WebRTC media streaming
  • Low-latency audio processing
  • Video support
  • Room-based communication

MCP Integration Layer

Model Context Protocol services enable integration with external platforms:

Service Architecture

Supported Integrations

Data Layer

Supabase Database Schema

Request Flow Examples

Outbound Call Flow

Outbound Call Flow Diagram

Incoming WebSocket Stream

Scaling Considerations

Horizontal Scaling

  • Stateless API servers (multiple instances)
  • Load balancer (nginx, AWS ALB)
  • Shared database (Supabase)
  • Message queue for async tasks (optional: Redis/RabbitMQ)

Vertical Scaling

  • Increase server resources (CPU, memory)
  • Database connection pooling
  • Caching layer (Redis)
  • CDN for media files

Security Architecture

Authentication

Data Protection

  • Encryption at rest (Supabase)
  • TLS/SSL for transport
  • API key rotation
  • Audit logging

Technology Stack

Next Steps

AI Agents

Learn how to create and configure AI agents.

Call Management

Understand call routing and handling.

Services

Explore available services.

Integrations

Integrate external platforms.