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
- 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
- Create call request
- Initialize call connection
- Stream audio to AI agent
- Process agent responses
- Return audio to caller
- 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
- 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
- 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
- Upload call list (CSV/JSON)
- Validate phone numbers
- Schedule calls
- Monitor progress
- Generate results report
AI Bridges
AI bridges abstract the different AI provider APIs into a common interface.Supported Providers
| Provider | Module | Features |
|---|---|---|
| Gemini | bridges/gemini_bridge_base.py | Real-time streaming, multi-modal |
| OpenAI | bridges/open_ai.py | GPT-4, function calling, vision |
| Hume AI | bridges/hume_bridge.py | Emotional intelligence, empathy |
Bridge Interface
Communication Layer
Telephony Providers
Twilio:- Incoming call handling via webhooks
- TwiML response generation
- Real-time media streaming
- Call recording
- 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
| Service | Port | Tools |
|---|---|---|
| Telegram | 8100 | send_message, read_message |
| Gmail | 8101 | send_email, read_email |
| 8102 | send_message, read_message |
Data Layer
Supabase Database Schema
Request Flow Examples
Outbound Call Flow

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
| Layer | Technologies |
|---|---|
| API Framework | FastAPI, Uvicorn, Pydantic |
| Real-time | WebSocket, LiveKit |
| AI/LLM | Gemini, OpenAI, Hume |
| Telephony | Twilio, Plivo, Silero VAD |
| Integrations | MCP, Telethon, OAuth2 |
| Database | PostgreSQL (via Supabase) |
| Deployment | Docker, Docker Compose |
| Task Scheduling | APScheduler |
| Async Processing | asyncio, aiohttp |