# jbrazy480/ai-receptionist architecture

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

- Interactive diagram: https://gitdiagram.com/jbrazy480/ai-receptionist
- Repository: https://github.com/jbrazy480/ai-receptionist

## Overview

This is a self-hosted inbound AI phone receptionist, configured from YAML and built around Twilio voice and OpenAI Realtime. A caller’s audio enters the FastAPI/Twilio stream handler, passes through the realtime bridge, and may invoke business tools for FAQs, hours, messages, appointments, transfers, or ending a call. A separate offline text simulator exercises the same tools. The README documents these capabilities; some runtime paths are visible only in excerpts, so the graph omits uncertain links.

Main entry points: [`receptionist/realtime_bridge.py`](https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/realtime_bridge.py) (Media bridge), [`receptionist/tools.py`](https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/tools.py) (Business tools), [`receptionist/twilio_app.py`](https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/twilio_app.py) (Voice web app), [`receptionist/config.py`](https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/config.py) (Config loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_voice["Live voice"]
  node_voice_app["Voice web app<br/>[twilio_app.py]"]
  node_bridge["Media bridge<br/>[realtime_bridge.py]"]
end

subgraph group_business["Business logic"]
  node_prompt["System prompt<br/>[prompt.py]"]
  node_tools["Business tools<br/>[tools.py]"]
  node_hours["Hours rules<br/>[hours.py]"]
end

subgraph group_offline["Offline simulator"]
  node_simulator["Text simulator<br/>[simulate.py]"]
  node_brain["Conversation brain<br/>[brain.py]"]
end

subgraph group_state["Configuration and records"]
  node_config["Config loader<br/>[config.py]"]
  node_business_yaml["Business YAML"]
  node_call_log["Call logging<br/>[logging_utils.py]"]
  node_jsonl[("Local JSONL files")]
end

node_caller(("Phone caller"))
node_twilio{{"Twilio voice"}}
node_openai{{"OpenAI Realtime"}}
node_webhook{{"Configured webhook"}}

node_caller -->|"places call"| node_twilio
node_twilio -->|"posts voice"| node_voice_app
node_twilio -->|"streams audio"| node_voice_app
node_voice_app -->|"loads config"| node_config
node_config -->|"reads YAML"| node_business_yaml
node_voice_app -->|"opens realtime socket"| node_openai
node_voice_app -->|"creates bridge"| node_bridge
node_bridge -->|"sends audio and events"| node_openai
node_bridge -->|"forwards audio"| node_twilio
node_bridge -->|"builds session prompt"| node_prompt
node_prompt -->|"checks hours"| node_hours
node_bridge -->|"dispatches tool calls"| node_tools
node_bridge -->|"records tool calls"| node_call_log
node_tools -->|"checks open status"| node_hours
node_tools -->|"uses business settings"| node_config
node_tools -->|"writes records"| node_jsonl
node_call_log -->|"writes call logs"| node_jsonl
node_tools -.->|"posts configured data"| node_webhook
node_bridge -.->|"requests transfer"| node_twilio
node_simulator -->|"loads config"| node_config
node_simulator -->|"runs conversation"| node_brain
node_brain -->|"dispatches business actions"| node_tools
node_brain -->|"uses business settings"| node_config

click node_voice_app "https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/twilio_app.py"
click node_bridge "https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/realtime_bridge.py"
click node_prompt "https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/prompt.py"
click node_tools "https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/tools.py"
click node_hours "https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/hours.py"
click node_simulator "https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/simulate.py"
click node_brain "https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/brain.py"
click node_config "https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/config.py"
click node_business_yaml "https://github.com/jbrazy480/ai-receptionist/blob/main/business.example.yaml"
click node_call_log "https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/logging_utils.py"
click node_jsonl "https://github.com/jbrazy480/ai-receptionist/tree/main/data"

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_voice_app,node_bridge toneBlue
class node_prompt,node_tools,node_hours toneAmber
class node_simulator,node_brain,node_webhook toneMint
class node_config,node_business_yaml,node_call_log,node_jsonl toneRose
class node_caller,node_twilio,node_openai toneIndigo
```

## Components

### Live voice

- [Voice web app](https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/twilio_app.py): `receptionist/twilio_app.py`
- [Media bridge](https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/realtime_bridge.py): `receptionist/realtime_bridge.py`

### Business logic

- [System prompt](https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/prompt.py): `receptionist/prompt.py`
- [Business tools](https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/tools.py): `receptionist/tools.py`
- [Hours rules](https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/hours.py): `receptionist/hours.py`

### Offline simulator

- [Text simulator](https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/simulate.py): `receptionist/simulate.py`
- [Conversation brain](https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/brain.py): `receptionist/brain.py`

### Configuration and records

- [Config loader](https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/config.py): `receptionist/config.py`
- [Business YAML](https://github.com/jbrazy480/ai-receptionist/blob/main/business.example.yaml): `business.example.yaml`
- [Call logging](https://github.com/jbrazy480/ai-receptionist/blob/main/receptionist/logging_utils.py): `receptionist/logging_utils.py`
- [Local JSONL files](https://github.com/jbrazy480/ai-receptionist/tree/main/data): `data`

### Other components

- **Phone caller**
- **Twilio voice**
- **OpenAI Realtime**
- **Configured webhook**

## Connections

- Phone caller → Twilio voice: places call (evidence: `README.md`)
- Twilio voice → Voice web app: posts voice (evidence: `receptionist/twilio_app.py`)
- Twilio voice → Voice web app: streams audio (evidence: `README.md`)
- Voice web app → Config loader: loads config (evidence: `receptionist/twilio_app.py`)
- Config loader → Business YAML: reads YAML (evidence: `receptionist/config.py`)
- Voice web app → OpenAI Realtime: opens realtime socket (evidence: `receptionist/twilio_app.py`)
- Voice web app → Media bridge: creates bridge (evidence: `receptionist/twilio_app.py`)
- Media bridge → OpenAI Realtime: sends audio and events (evidence: `receptionist/realtime_bridge.py`)
- Media bridge → Twilio voice: forwards audio (evidence: `receptionist/realtime_bridge.py`)
- Media bridge → System prompt: builds session prompt (evidence: `receptionist/realtime_bridge.py`)
- System prompt → Hours rules: checks hours (evidence: `receptionist/prompt.py`)
- Media bridge → Business tools: dispatches tool calls (evidence: `receptionist/realtime_bridge.py`)
- Media bridge → Call logging: records tool calls (evidence: `receptionist/realtime_bridge.py`)
- Business tools → Hours rules: checks open status (evidence: `receptionist/tools.py`)
- Business tools → Config loader: uses business settings (evidence: `receptionist/tools.py`)
- Business tools → Local JSONL files: writes records (evidence: `receptionist/tools.py`)
- Call logging → Local JSONL files: writes call logs (evidence: `receptionist/logging_utils.py`)
- Business tools → Configured webhook: posts configured data (evidence: `receptionist/tools.py`)
- Media bridge → Twilio voice: requests transfer (evidence: `README.md`)
- Text simulator → Config loader: loads config (evidence: `receptionist/simulate.py`)
- Text simulator → Conversation brain: runs conversation (evidence: `receptionist/simulate.py`)
- Conversation brain → Business tools: dispatches business actions (evidence: `receptionist/brain.py`)
- Conversation brain → Config loader: uses business settings (evidence: `receptionist/brain.py`)
