# yar-malik/saudi-insurance-voice-agent architecture

> Architecture diagram of the GitHub repository yar-malik/saudi-insurance-voice-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yar-malik/saudi-insurance-voice-agent
- Repository: https://github.com/yar-malik/saudi-insurance-voice-agent

## Overview

This is a self-hostable Saudi insurance voice-agent example: scripted Najdi Arabic conversations for first notice of loss, claim status, and renewals, with recorded tool results until real integrations are registered. On the phone path, Twilio supplies speech transcripts to the Flask server; the server drives the conversation engine, which loads scenario flows and invokes tools, while Voho synthesizes spoken replies. The README also documents speech demos and optional STT and insurer-system integration points. Evidence is limited to the README and sampled Python files; the example clients and flow data were not inspected.

Main entry points: [`server.py`](https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/server.py) (Phone webhook), [`agent.py`](https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/agent.py) (Conversation engine), [`tools.py`](https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/tools.py) (Tool registry and replay), [`voho.py`](https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/voho.py) (Speech API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_telephony["Phone interface"]
  node_server["Phone webhook<br/>[server.py]"]
  node_clips["Audio clip delivery<br/>[server.py]"]
end

subgraph group_conversation["Conversation runtime"]
  node_agent["Conversation engine<br/>[agent.py]"]
end

subgraph group_integrations["Speech and integrations"]
  node_stt["Speech recognition options<br/>[stt.py]"]
  node_tools["Tool registry and replay<br/>[tools.py]"]
  node_voho["Speech API client<br/>[voho.py]"]
  node_python_demo["Python speech demo<br/>[main.py]"]
  node_node_demo["Node speech demo<br/>[index.mjs]"]
end

subgraph group_scenarios["Insurance scenarios"]
  node_flows["Insurance scenario catalog<br/>[flows.json]"]
  node_play_demo["Scenario playback<br/>[play.py]"]
end

node_caller(("Caller"))
node_twilio["Twilio telephony"]
node_voho_api["Voho Speech API"]
node_enterprise["Insurer systems"]

node_caller -->|"calls"| node_twilio
node_twilio -->|"posts speech"| node_server
node_server -->|"starts and replies"| node_agent
node_agent -->|"loads scenarios"| node_flows
node_agent -->|"runs tools"| node_tools
node_server -->|"lists stubs"| node_tools
node_server -->|"synthesizes replies"| node_voho
node_voho -->|"requests speech"| node_voho_api
node_server -->|"serves audio"| node_clips
node_clips -->|"plays audio"| node_twilio
node_twilio -->|"plays replies"| node_caller
node_stt -.->|"optional recognition"| node_server
node_tools -.->|"custom actions"| node_enterprise
node_python_demo -.->|"speaks or replies"| node_voho_api
node_node_demo -.->|"speaks or replies"| node_voho_api
node_play_demo -.->|"plays scenarios"| node_flows

click node_server "https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/server.py"
click node_clips "https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/server.py"
click node_agent "https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/agent.py"
click node_stt "https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/stt.py"
click node_tools "https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/tools.py"
click node_voho "https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/voho.py"
click node_flows "https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/flows.json"
click node_python_demo "https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/examples/python/main.py"
click node_node_demo "https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/examples/node/index.mjs"
click node_play_demo "https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/examples/play.py"

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_server,node_clips toneBlue
class node_agent toneAmber
class node_stt,node_tools,node_voho,node_python_demo,node_node_demo,node_voho_api toneMint
class node_flows,node_play_demo toneRose
class node_caller,node_twilio,node_enterprise toneIndigo
```

## Components

### Phone interface

- [Phone webhook](https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/server.py): `server.py`
- [Audio clip delivery](https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/server.py): `server.py`

### Conversation runtime

- [Conversation engine](https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/agent.py): `agent.py`

### Speech and integrations

- [Speech recognition options](https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/stt.py): `stt.py`
- [Tool registry and replay](https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/tools.py): `tools.py`
- [Speech API client](https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/voho.py): `voho.py`
- [Python speech demo](https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/examples/python/main.py): `examples/python/main.py`
- [Node speech demo](https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/examples/node/index.mjs): `examples/node/index.mjs`

### Insurance scenarios

- [Insurance scenario catalog](https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/flows.json): `flows.json`
- [Scenario playback](https://github.com/yar-malik/saudi-insurance-voice-agent/blob/main/examples/play.py): `examples/play.py`

### Other components

- **Caller**
- **Twilio telephony**
- **Voho Speech API**
- **Insurer systems**

## Connections

- Caller → Twilio telephony: calls (evidence: `README.md`)
- Twilio telephony → Phone webhook: posts speech (evidence: `README.md`)
- Phone webhook → Conversation engine: starts and replies (evidence: `server.py`)
- Conversation engine → Insurance scenario catalog: loads scenarios (evidence: `agent.py`)
- Conversation engine → Tool registry and replay: runs tools (evidence: `agent.py`)
- Phone webhook → Tool registry and replay: lists stubs (evidence: `server.py`)
- Phone webhook → Speech API client: synthesizes replies (evidence: `server.py`)
- Speech API client → Voho Speech API: requests speech (evidence: `voho.py`)
- Phone webhook → Audio clip delivery: serves audio (evidence: `server.py`)
- Audio clip delivery → Twilio telephony: plays audio (evidence: `server.py`)
- Twilio telephony → Caller: plays replies (evidence: `README.md`)
- Speech recognition options → Phone webhook: optional recognition (evidence: `README.md`)
- Tool registry and replay → Insurer systems: custom actions (evidence: `README.md`)
- Python speech demo → Voho Speech API: speaks or replies (evidence: `README.md`)
- Node speech demo → Voho Speech API: speaks or replies (evidence: `README.md`)
- Scenario playback → Insurance scenario catalog: plays scenarios (evidence: `README.md`)
