# yar-malik/saudi-financial-services-voice-agent architecture

> Architecture diagram of the GitHub repository yar-malik/saudi-financial-services-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-financial-services-voice-agent
- Repository: https://github.com/yar-malik/saudi-financial-services-voice-agent

## Overview

This is a self-hosted Saudi financial-services voice agent: it runs scripted Najdi Arabic conversations for onboarding, lead qualification, and account questions, with scenario-recorded tool results available until real integrations are registered. The phone workflow starts at Twilio, whose speech webhook reaches the Flask server; the server advances an Agent scenario, dispatches tools, synthesizes spoken turns with Voho, and returns audio for playback. Terminal examples and reference scenarios are documented capabilities too. The graph reflects sampled Python modules and README claims; unsampled scenario data and example implementations are represented only where their roles are documented.

Main entry points: [`server.py`](https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/server.py) (Phone Webhook), [`flows.json`](https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/flows.json) (Scenario Flows), [`agent.py`](https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/agent.py) (Conversation Agent), [`voho.py`](https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/voho.py) (Voho Speech)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Ways to Run"]
  node_phone_server["Phone Webhook<br/>[server.py]"]
  node_terminal_play["Terminal Runner<br/>[play.py]"]
  node_node_example["Node Example<br/>[index.mjs]"]
  node_python_example["Python Example<br/>[main.py]"]
end

subgraph group_conversation["Conversation Engine"]
  node_scenario_engine["Conversation Agent<br/>[agent.py]"]
end

subgraph group_domain["Finance Scenarios"]
  node_scenario_data["Scenario Flows<br/>[flows.json]"]
  node_onboarding["Client Onboarding<br/>[flows.json]"]
  node_qualification["Lead Qualification<br/>[flows.json]"]
  node_statements["Statement Questions<br/>[flows.json]"]
  node_reference_scenarios["Reference Scenarios<br/>[flows.json]"]
end

subgraph group_integrations["Voice and Tools"]
  node_tool_dispatch["Tool Registry<br/>[tools.py]"]
  node_speech_client["Voho Speech<br/>[voho.py]"]
  node_stt_options["STT Options<br/>[stt.py]"]
end

node_caller(("Caller"))
node_twilio(("Twilio Phone"))
node_voho_api["Voho Speech API"]

node_caller -->|"calls"| node_twilio
node_twilio -->|"posts speech"| node_phone_server
node_phone_server -->|"starts and replies"| node_scenario_engine
node_scenario_engine -->|"loads flows"| node_scenario_data
node_scenario_engine -->|"calls tools"| node_tool_dispatch
node_phone_server -->|"lists stubbed tools"| node_tool_dispatch
node_phone_server -->|"synthesizes turns"| node_speech_client
node_speech_client -->|"requests speech"| node_voho_api
node_phone_server -->|"returns playback instructions"| node_twilio
node_terminal_play -.->|"runs scenarios"| node_scenario_engine
node_node_example -.->|"requests speech"| node_voho_api
node_python_example -.->|"requests speech"| node_voho_api
node_scenario_data -->|"defines"| node_onboarding
node_scenario_data -->|"defines"| node_qualification
node_scenario_data -->|"defines"| node_statements
node_scenario_data -->|"records"| node_reference_scenarios
node_caller -.->|"audio input"| node_stt_options

click node_phone_server "https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/server.py"
click node_terminal_play "https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/examples/play.py"
click node_node_example "https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/examples/node/index.mjs"
click node_python_example "https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/examples/python/main.py"
click node_scenario_engine "https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/agent.py"
click node_scenario_data "https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/flows.json"
click node_onboarding "https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/flows.json"
click node_qualification "https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/flows.json"
click node_statements "https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/flows.json"
click node_reference_scenarios "https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/flows.json"
click node_tool_dispatch "https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/tools.py"
click node_speech_client "https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/voho.py"
click node_stt_options "https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/stt.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_phone_server,node_terminal_play,node_node_example,node_python_example toneBlue
class node_scenario_engine toneAmber
class node_scenario_data,node_onboarding,node_qualification,node_statements,node_reference_scenarios,node_voho_api toneMint
class node_tool_dispatch,node_speech_client,node_stt_options toneRose
class node_caller,node_twilio toneIndigo
```

## Components

### Ways to Run

- [Phone Webhook](https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/server.py): `server.py`
- [Terminal Runner](https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/examples/play.py): `examples/play.py`
- [Node Example](https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/examples/node/index.mjs): `examples/node/index.mjs`
- [Python Example](https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/examples/python/main.py): `examples/python/main.py`

### Conversation Engine

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

### Finance Scenarios

- [Scenario Flows](https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/flows.json): `flows.json`
- [Client Onboarding](https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/flows.json): `flows.json`
- [Lead Qualification](https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/flows.json): `flows.json`
- [Statement Questions](https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/flows.json): `flows.json`
- [Reference Scenarios](https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/flows.json): `flows.json`

### Voice and Tools

- [Tool Registry](https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/tools.py): `tools.py`
- [Voho Speech](https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/voho.py): `voho.py`
- [STT Options](https://github.com/yar-malik/saudi-financial-services-voice-agent/blob/main/stt.py): `stt.py`

### Other components

- **Caller**
- **Twilio Phone**
- **Voho Speech API**

## Connections

- Caller → Twilio Phone: calls (evidence: `README.md`)
- Twilio Phone → Phone Webhook: posts speech (evidence: `README.md`)
- Phone Webhook → Conversation Agent: starts and replies (evidence: `server.py`)
- Conversation Agent → Scenario Flows: loads flows (evidence: `agent.py`)
- Conversation Agent → Tool Registry: calls tools (evidence: `agent.py`)
- Phone Webhook → Tool Registry: lists stubbed tools (evidence: `server.py`)
- Phone Webhook → Voho Speech: synthesizes turns (evidence: `server.py`)
- Voho Speech → Voho Speech API: requests speech (evidence: `voho.py`)
- Phone Webhook → Twilio Phone: returns playback instructions (evidence: `README.md`)
- Terminal Runner → Conversation Agent: runs scenarios (evidence: `README.md`)
- Node Example → Voho Speech API: requests speech (evidence: `README.md`)
- Python Example → Voho Speech API: requests speech (evidence: `README.md`)
- Scenario Flows → Client Onboarding: defines (evidence: `README.md`)
- Scenario Flows → Lead Qualification: defines (evidence: `README.md`)
- Scenario Flows → Statement Questions: defines (evidence: `README.md`)
- Scenario Flows → Reference Scenarios: records (evidence: `README.md`)
- Caller → STT Options: audio input (evidence: `README.md`)
