How techwithtim/livekit-ai-car-call-centre works
Purpose
A full-stack AI car call-centre application. The frontend provides a browser voice-assistant experience; the Python backend exposes API/server entry points, runs an AI agent, and persists or retrieves supporting data.
Entry Points
• Backend service startup: backend/server.py
• Backend API surface: backend/api.py
• Agent orchestration: backend/agent.py
• Frontend bootstrap: frontend/src/main.jsx
• Frontend application shell: frontend/src/App.jsx
Backend Service Layer
backend/server.py is the runtime host for the backend and likely composes HTTP/API and agent capabilities. backend/api.py defines the application-facing request boundary, separating browser/client interactions from agent and database implementation details.
Paths:
• backend/server.py
• backend/api.py
• backend/requirements.txt
AI Agent and Prompt Boundary
backend/agent.py contains the call-centre agent behavior and is the main integration point for conversational/voice AI logic. backend/prompts.py centralizes prompt content or prompt construction, allowing conversation policy to evolve independently from server routing.
Paths:
• backend/agent.py
• backend/prompts.py
Persistence and Data Access
backend/db_driver.py isolates database connectivity and queries behind a driver boundary. Agent/API code should use this layer rather than directly coupling to storage, making customer, vehicle, or call-context data services replaceable.
Paths:
• backend/db_driver.py
• backend/sample.env
Voice Client and LiveKit Integration
The React frontend is structured around a voice-assistant UI. LiveKitModal.jsx is the likely connection/session UI boundary for LiveKit, while SimpleVoiceAssistant.jsx owns the in-call interaction experience. This separates real-time media/session lifecycle from visible assistant controls.
Paths:
• frontend/src/components/LiveKitModal.jsx
• frontend/src/components/SimpleVoiceAssistant.jsx
• frontend/src/App.jsx
Primary Flow
1. The browser starts from frontend/src/main.jsx and renders App.jsx.
2. The user opens or uses the LiveKit voice interface through the frontend components.
3. LiveKit carries real-time voice/session traffic between the client and the agent runtime.
4. Backend API/server code routes application requests into backend/agent.py.
5. The agent applies instructions from backend/prompts.py and accesses domain data through backend/db_driver.py.
6. Agent responses are returned through the real-time voice path and reflected in the frontend UI.
Runtime and Infrastructure Boundaries
• Frontend: Vite-based React application, configured by frontend/vite.config.js and dependencies in frontend/package.json.
• Backend: Python environment with dependencies declared in backend/requirements.txt.
• External services: LiveKit for real-time voice/media; an unspecified database configured through backend environment variables.
• Environment separation is explicit through backend/sample.env and frontend/sample.env, indicating distinct backend credentials/service configuration versus browser-exposed configuration.
Main entry points: agent.py Call-Centre Agent · App.jsx Application Shell · server.py Backend Server · main.jsx Frontend Bootstrap
Components 13
React Voice Client
- Frontend Bootstrap
frontend/src/main.jsx - Application Shell
frontend/src/App.jsx - LiveKit Session UI
frontend/src/components/LiveKitModal.jsx - Voice Assistant UI
frontend/src/components/SimpleVoiceAssistant.jsx - Vite Runtime
frontend/vite.config.js
Python Backend
- Backend Server
backend/server.py - API Boundary
backend/api.py - Call-Centre Agent
backend/agent.py - Prompt Policy
backend/prompts.py - Data Access Driver
backend/db_driver.py - Python Dependencies
backend/requirements.txt
External Services
- LiveKit
- Customer & Vehicle Data · Configured through backend environment variables.
Connections 14
- Frontend Bootstrap → Application Shell: renders
- Vite Runtime → Frontend Bootstrap: serves
- Application Shell → LiveKit Session UI: hosts session UI
- Application Shell → Voice Assistant UI: hosts call UI
- LiveKit Session UI → LiveKit: connects session
- Voice Assistant UI → LiveKit: sends and receives voice
- Python Dependencies → Backend Server: provides runtime
- Backend Server → API Boundary: hosts
- Backend Server → Call-Centre Agent: runs agent runtime
- API Boundary → Call-Centre Agent: routes requests
- Call-Centre Agent → Prompt Policy: applies instructions
- Call-Centre Agent → Data Access Driver: retrieves call context
- Data Access Driver → Customer & Vehicle Data: queries
- LiveKit → Call-Centre Agent: carries live voice traffic