# tekessence/ar-hosted-calling architecture

> Architecture diagram of the GitHub repository tekessence/ar-hosted-calling, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tekessence/ar-hosted-calling
- Repository: https://github.com/tekessence/ar-hosted-calling

## Overview

AR Voice Agent is a self-hosted insurance-claims voice agent with an admin UI. Its main workflow is a Twilio call entering the FastAPI telephony route, running through a per-call conversation, and returning synthesized speech; operators also manage accounts and review calls through the dashboard. The README documents GPU Whisper/vLLM, Redis, telephony, exports and live monitoring. The graph includes those documented capabilities, but omits uncertain UI-to-API links because sampled frontend files do not show them.

Main entry points: [`server/app.py`](https://github.com/tekessence/ar-hosted-calling/blob/main/server/app.py) (FastAPI app), [`server/state.py`](https://github.com/tekessence/ar-hosted-calling/blob/main/server/state.py) (Model and app state), [`server/routes/telephony.py`](https://github.com/tekessence/ar-hosted-calling/blob/main/server/routes/telephony.py) (Telephony routes), [`server/tts.py`](https://github.com/tekessence/ar-hosted-calling/blob/main/server/tts.py) (TTS orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_voice["Voice runtime"]
  node_telephony["Telephony routes<br/>[telephony.py]"]
  node_call_session["Call session<br/>[call_session.py]"]
  node_browser_voice["Browser voice test<br/>[browser_ws.py]"]
end

subgraph group_api["Backend API"]
  node_fastapi["FastAPI app<br/>[app.py]"]
  node_accounts["Projects and accounts<br/>[accounts.py]"]
  node_chat["Chat routes<br/>[chat.py]"]
  node_dashboard["Dashboard routes<br/>[dashboard.py]"]
end

subgraph group_admin["Admin experience"]
  node_dashboard_ui["Dashboard UI<br/>[page.tsx]"]
  node_project_ui["Project management UI<br/>[page.tsx]"]
  node_call_ui["Call detail UI<br/>[call-detail.tsx]"]
  node_review_ui["Review UI<br/>[page.tsx]"]
  node_settings_ui["Settings UI<br/>[page.tsx]"]
  node_api_client["Frontend API client<br/>[api.ts]"]
end

subgraph group_speech["Speech and language"]
  node_audio["Audio and VAD<br/>[audio.py]"]
  node_prompts["Claim prompts<br/>[prompts.py]"]
  node_tts["TTS orchestration<br/>[tts.py]"]
  node_tts_text["TTS text processing<br/>[tts_plain.py]"]
  node_tts_common["Speech text transforms<br/>[tts_common.py]"]
end

subgraph group_state["State and integrations"]
  node_state["Model and app state<br/>[state.py]"]
  node_redis[("Redis")]
  node_whisper{{"Faster-Whisper"}}
  node_vllm{{"vLLM LLM"}}
  node_chatterbox["Chatterbox service<br/>[app.py]"]
end

node_caller(("Insurance caller"))
node_twilio{{"Twilio Media Streams"}}
node_voice_ui(("Admin operator"))

node_caller -->|"calls via PSTN"| node_twilio
node_twilio -->|"streams audio"| node_telephony
node_fastapi -->|"registers routes"| node_telephony
node_fastapi -->|"registers routes"| node_browser_voice
node_telephony -->|"creates session"| node_call_session
node_call_session -->|"uses codec"| node_audio
node_call_session -->|"uses prompts"| node_prompts
node_telephony -->|"uses speech output"| node_tts
node_browser_voice -->|"transcribes audio"| node_audio
node_browser_voice -->|"streams reply audio"| node_tts
node_tts -->|"delegates plain mode"| node_tts_text
node_tts_text -->|"uses transforms"| node_tts_common
node_tts -->|"requests synthesis"| node_chatterbox
node_fastapi -->|"loads models"| node_state
node_state -->|"connects"| node_redis
node_state -->|"loads model"| node_whisper
node_state -->|"configures client"| node_vllm
node_accounts -->|"stores account data"| node_redis
node_fastapi -->|"registers routes"| node_accounts
node_fastapi -->|"registers routes"| node_chat
node_fastapi -->|"registers routes"| node_dashboard
node_dashboard_ui -.->|"presents dashboard"| node_voice_ui
node_voice_ui -.->|"manages projects"| node_project_ui
node_voice_ui -.->|"reviews calls"| node_call_ui
node_voice_ui -.->|"reviews outcomes"| node_review_ui
node_voice_ui -.->|"configures service"| node_settings_ui
node_api_client -.->|"supports API access"| node_dashboard_ui

click node_fastapi "https://github.com/tekessence/ar-hosted-calling/blob/main/server/app.py"
click node_telephony "https://github.com/tekessence/ar-hosted-calling/blob/main/server/routes/telephony.py"
click node_call_session "https://github.com/tekessence/ar-hosted-calling/blob/main/call_session.py"
click node_browser_voice "https://github.com/tekessence/ar-hosted-calling/blob/main/server/routes/browser_ws.py"
click node_audio "https://github.com/tekessence/ar-hosted-calling/blob/main/audio.py"
click node_prompts "https://github.com/tekessence/ar-hosted-calling/blob/main/prompts.py"
click node_tts "https://github.com/tekessence/ar-hosted-calling/blob/main/server/tts.py"
click node_tts_text "https://github.com/tekessence/ar-hosted-calling/blob/main/server/tts_plain.py"
click node_tts_common "https://github.com/tekessence/ar-hosted-calling/blob/main/tts_common.py"
click node_state "https://github.com/tekessence/ar-hosted-calling/blob/main/server/state.py"
click node_chatterbox "https://github.com/tekessence/ar-hosted-calling/blob/main/chatterbox_service/app.py"
click node_accounts "https://github.com/tekessence/ar-hosted-calling/blob/main/server/routes/accounts.py"
click node_chat "https://github.com/tekessence/ar-hosted-calling/blob/main/server/routes/chat.py"
click node_dashboard "https://github.com/tekessence/ar-hosted-calling/blob/main/server/routes/dashboard.py"
click node_dashboard_ui "https://github.com/tekessence/ar-hosted-calling/blob/main/frontend/app/(main)/page.tsx"
click node_project_ui "https://github.com/tekessence/ar-hosted-calling/blob/main/frontend/app/(main)/projects/page.tsx"
click node_call_ui "https://github.com/tekessence/ar-hosted-calling/blob/main/frontend/components/call-detail.tsx"
click node_review_ui "https://github.com/tekessence/ar-hosted-calling/blob/main/frontend/app/(main)/review/page.tsx"
click node_settings_ui "https://github.com/tekessence/ar-hosted-calling/blob/main/frontend/app/(main)/settings/page.tsx"
click node_api_client "https://github.com/tekessence/ar-hosted-calling/blob/main/frontend/lib/api.ts"

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_telephony,node_call_session,node_browser_voice toneBlue
class node_fastapi,node_accounts,node_chat,node_dashboard toneAmber
class node_dashboard_ui,node_project_ui,node_call_ui,node_review_ui,node_settings_ui,node_api_client toneMint
class node_audio,node_prompts,node_tts,node_tts_text,node_tts_common toneRose
class node_state,node_redis,node_whisper,node_vllm,node_chatterbox,node_caller,node_twilio,node_voice_ui toneIndigo
```

## Components

### Voice runtime

- [Telephony routes](https://github.com/tekessence/ar-hosted-calling/blob/main/server/routes/telephony.py): `server/routes/telephony.py`
- [Call session](https://github.com/tekessence/ar-hosted-calling/blob/main/call_session.py): `call_session.py`
- [Browser voice test](https://github.com/tekessence/ar-hosted-calling/blob/main/server/routes/browser_ws.py): `server/routes/browser_ws.py`

### Backend API

- [FastAPI app](https://github.com/tekessence/ar-hosted-calling/blob/main/server/app.py): `server/app.py`
- [Projects and accounts](https://github.com/tekessence/ar-hosted-calling/blob/main/server/routes/accounts.py): `server/routes/accounts.py`
- [Chat routes](https://github.com/tekessence/ar-hosted-calling/blob/main/server/routes/chat.py): `server/routes/chat.py`
- [Dashboard routes](https://github.com/tekessence/ar-hosted-calling/blob/main/server/routes/dashboard.py): `server/routes/dashboard.py`

### Admin experience

- [Dashboard UI](https://github.com/tekessence/ar-hosted-calling/blob/main/frontend/app/(main)/page.tsx): `frontend/app/(main)/page.tsx`
- [Project management UI](https://github.com/tekessence/ar-hosted-calling/blob/main/frontend/app/(main)/projects/page.tsx): `frontend/app/(main)/projects/page.tsx`
- [Call detail UI](https://github.com/tekessence/ar-hosted-calling/blob/main/frontend/components/call-detail.tsx): `frontend/components/call-detail.tsx`
- [Review UI](https://github.com/tekessence/ar-hosted-calling/blob/main/frontend/app/(main)/review/page.tsx): `frontend/app/(main)/review/page.tsx`
- [Settings UI](https://github.com/tekessence/ar-hosted-calling/blob/main/frontend/app/(main)/settings/page.tsx): `frontend/app/(main)/settings/page.tsx`
- [Frontend API client](https://github.com/tekessence/ar-hosted-calling/blob/main/frontend/lib/api.ts): `frontend/lib/api.ts`

### Speech and language

- [Audio and VAD](https://github.com/tekessence/ar-hosted-calling/blob/main/audio.py): `audio.py`
- [Claim prompts](https://github.com/tekessence/ar-hosted-calling/blob/main/prompts.py): `prompts.py`
- [TTS orchestration](https://github.com/tekessence/ar-hosted-calling/blob/main/server/tts.py): `server/tts.py`
- [TTS text processing](https://github.com/tekessence/ar-hosted-calling/blob/main/server/tts_plain.py): `server/tts_plain.py`
- [Speech text transforms](https://github.com/tekessence/ar-hosted-calling/blob/main/tts_common.py): `tts_common.py`

### State and integrations

- [Model and app state](https://github.com/tekessence/ar-hosted-calling/blob/main/server/state.py): `server/state.py`
- **Redis**
- **Faster-Whisper**
- **vLLM LLM**
- [Chatterbox service](https://github.com/tekessence/ar-hosted-calling/blob/main/chatterbox_service/app.py): `chatterbox_service/app.py`

### Other components

- **Insurance caller**
- **Twilio Media Streams**
- **Admin operator**

## Connections

- Insurance caller → Twilio Media Streams: calls via PSTN
- Twilio Media Streams → Telephony routes: streams audio
- FastAPI app → Telephony routes: registers routes (evidence: `server/app.py`)
- FastAPI app → Browser voice test: registers routes (evidence: `server/app.py`)
- Telephony routes → Call session: creates session (evidence: `server/routes/telephony.py`)
- Call session → Audio and VAD: uses codec (evidence: `call_session.py`)
- Call session → Claim prompts: uses prompts (evidence: `call_session.py`)
- Telephony routes → TTS orchestration: uses speech output (evidence: `server/routes/telephony.py`)
- Browser voice test → Audio and VAD: transcribes audio (evidence: `server/routes/browser_ws.py`)
- Browser voice test → TTS orchestration: streams reply audio (evidence: `server/routes/browser_ws.py`)
- TTS orchestration → TTS text processing: delegates plain mode (evidence: `server/tts.py`)
- TTS text processing → Speech text transforms: uses transforms (evidence: `server/tts_plain.py`)
- TTS orchestration → Chatterbox service: requests synthesis (evidence: `server/tts.py`)
- FastAPI app → Model and app state: loads models (evidence: `server/app.py`)
- Model and app state → Redis: connects (evidence: `server/state.py`)
- Model and app state → Faster-Whisper: loads model (evidence: `server/state.py`)
- Model and app state → vLLM LLM: configures client (evidence: `server/state.py`)
- Projects and accounts → Redis: stores account data (evidence: `server/routes/accounts.py`)
- FastAPI app → Projects and accounts: registers routes (evidence: `server/app.py`)
- FastAPI app → Chat routes: registers routes (evidence: `server/app.py`)
- FastAPI app → Dashboard routes: registers routes (evidence: `server/app.py`)
- Dashboard UI → Admin operator: presents dashboard
- Admin operator → Project management UI: manages projects
- Admin operator → Call detail UI: reviews calls
- Admin operator → Review UI: reviews outcomes
- Admin operator → Settings UI: configures service
- Frontend API client → Dashboard UI: supports API access
