# techwithtim/livekit-ai-car-call-centre architecture

> Architecture diagram of the GitHub repository techwithtim/livekit-ai-car-call-centre, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/techwithtim/livekit-ai-car-call-centre
- Repository: https://github.com/techwithtim/livekit-ai-car-call-centre

## Overview

#### 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: [`backend/agent.py`](https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/backend/agent.py) (Call-Centre Agent), [`frontend/src/App.jsx`](https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/frontend/src/App.jsx) (Application Shell), [`backend/server.py`](https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/backend/server.py) (Backend Server), [`frontend/src/main.jsx`](https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/frontend/src/main.jsx) (Frontend Bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React Voice Client"]
  node_frontend_main["Frontend Bootstrap<br/>React entry point<br/>[main.jsx]"]
  node_frontend_app["Application Shell<br/>React app<br/>[App.jsx]"]
  node_livekit_modal["LiveKit Session UI<br/>voice session component<br/>[LiveKitModal.jsx]"]
  node_voice_assistant["Voice Assistant UI<br/>in-call component"]
  node_frontend_runtime["Vite Runtime<br/>frontend tooling<br/>[vite.config.js]"]
end

subgraph group_backend["Python Backend"]
  node_backend_server["Backend Server<br/>Python runtime host<br/>[server.py]"]
  node_backend_api["API Boundary<br/>application API<br/>[api.py]"]
  node_agent{{"Call-Centre Agent<br/>AI orchestration<br/>[agent.py]"}}
  node_prompts["Prompt Policy<br/>prompt definitions<br/>[prompts.py]"]
  node_db_driver["Data Access Driver<br/>database adapter<br/>[db_driver.py]"]
  node_backend_dependencies["Python Dependencies<br/>runtime dependencies<br/>[requirements.txt]"]
end

subgraph group_external["External Services"]
  node_livekit(("LiveKit<br/>real-time voice service"))
  node_database[("Customer &amp; Vehicle Data<br/>database")]
end

node_frontend_main -->|"renders"| node_frontend_app
node_frontend_runtime -->|"serves"| node_frontend_main
node_frontend_app -->|"hosts session UI"| node_livekit_modal
node_frontend_app -->|"hosts call UI"| node_voice_assistant
node_livekit_modal -->|"connects session"| node_livekit
node_voice_assistant -->|"sends and receives voice"| node_livekit
node_backend_dependencies -.->|"provides runtime"| node_backend_server
node_backend_server -->|"hosts"| node_backend_api
node_backend_server -->|"runs agent runtime"| node_agent
node_backend_api -->|"routes requests"| node_agent
node_agent -->|"applies instructions"| node_prompts
node_agent -->|"retrieves call context"| node_db_driver
node_db_driver -->|"queries"| node_database
node_livekit -->|"carries live voice traffic"| node_agent

click node_frontend_main "https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/frontend/src/main.jsx"
click node_frontend_app "https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/frontend/src/App.jsx"
click node_livekit_modal "https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/frontend/src/components/LiveKitModal.jsx"
click node_voice_assistant "https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/frontend/src/components/SimpleVoiceAssistant.jsx"
click node_frontend_runtime "https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/frontend/vite.config.js"
click node_backend_server "https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/backend/server.py"
click node_backend_api "https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/backend/api.py"
click node_agent "https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/backend/agent.py"
click node_prompts "https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/backend/prompts.py"
click node_db_driver "https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/backend/db_driver.py"
click node_backend_dependencies "https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/backend/requirements.txt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend_main,node_frontend_app,node_livekit_modal,node_voice_assistant,node_frontend_runtime toneBlue
class node_backend_server,node_backend_api,node_agent,node_prompts,node_db_driver,node_backend_dependencies toneAmber
class node_livekit,node_database toneMint
```

## Components

### React Voice Client

- [Frontend Bootstrap](https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/frontend/src/main.jsx): React entry point · `frontend/src/main.jsx`
- [Application Shell](https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/frontend/src/App.jsx): React app · `frontend/src/App.jsx`
- [LiveKit Session UI](https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/frontend/src/components/LiveKitModal.jsx): voice session component · `frontend/src/components/LiveKitModal.jsx`
- [Voice Assistant UI](https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/frontend/src/components/SimpleVoiceAssistant.jsx): in-call component · `frontend/src/components/SimpleVoiceAssistant.jsx`
- [Vite Runtime](https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/frontend/vite.config.js): frontend tooling · `frontend/vite.config.js`

### Python Backend

- [Backend Server](https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/backend/server.py): Python runtime host · `backend/server.py`
- [API Boundary](https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/backend/api.py): application API · `backend/api.py`
- [Call-Centre Agent](https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/backend/agent.py): AI orchestration · `backend/agent.py`
- [Prompt Policy](https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/backend/prompts.py): prompt definitions · `backend/prompts.py`
- [Data Access Driver](https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/backend/db_driver.py): database adapter · `backend/db_driver.py`
- [Python Dependencies](https://github.com/techwithtim/livekit-ai-car-call-centre/blob/main/backend/requirements.txt): runtime dependencies · `backend/requirements.txt`

### External Services

- **LiveKit**: real-time voice service
- **Customer & Vehicle Data**: database · Configured through backend environment variables.

## Connections

- 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
