# yar-malik/voho-hospital-voice-agent architecture

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

## Overview

This is a hospital voice-assistant demo: callers speak or type, the server transcribes audio when needed, and the turn handler sends the conversation to Voho. The Voho adapter interprets tool markers and dispatches hospital tools; the answer is then synthesized and returned to the browser. The main domain stages are emergency handling, appointment operations, clinic transfer, and information delivery, supported by hospital configuration and a factual knowledge base. Several tool implementations and UI details were not excerpted, so their internal calls are omitted; documented capabilities remain represented.

Main entry points: [`components/VoiceDemo.tsx`](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/components/VoiceDemo.tsx) (Voice demo), [`lib/tools/index.ts`](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/tools/index.ts) (Tool registry), [`config/hospital.ts`](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/config/hospital.ts) (Hospital configuration), [`app/api/voice/turn/route.ts`](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/app/api/voice/turn/route.ts) (Turn endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Caller experience"]
  node_demo_page["Demo page<br/>[page.tsx]"]
  node_voice_demo["Voice demo<br/>[VoiceDemo.tsx]"]
  node_audio_capture["Audio capture<br/>[record.ts]"]
  node_transcript["Transcript view<br/>[Transcript.tsx]"]
  node_tool_log["Tool log<br/>[ToolLog.tsx]"]
end

subgraph group_conversation["Conversation server"]
  node_turn_route["Turn endpoint<br/>[route.ts]"]
  node_transcribe_route["Transcription endpoint<br/>[route.ts]"]
  node_status_route["Status endpoint<br/>[route.ts]"]
  node_agent_prompt["Agent brief<br/>[agentPrompt.ts]"]
end

subgraph group_hospital["Hospital capabilities"]
  node_knowledge["Hospital knowledge<br/>[index.ts]"]
  node_hospital_config["Hospital configuration<br/>[hospital.ts]"]
  node_tool_registry["Tool registry<br/>[index.ts]"]
  node_emergency["Emergency escalation"]
  node_appointments["Appointments<br/>[appointments.ts]"]
  node_clinic_transfer["Clinic transfer"]
  node_information["Information delivery<br/>[sendInformation.ts]"]
end

subgraph group_voho["Voho integration"]
  node_voho_adapter["Tool-call adapter<br/>[tools.ts]"]
  node_voho_agents["Agent replies<br/>[agents.ts]"]
  node_voho_speech["Speech synthesis<br/>[speech.ts]"]
  node_voho_transcribe["Speech recognition<br/>[transcribe.ts]"]
  node_voho_client["API client<br/>[client.ts]"]
end

node_caller(("Caller"))
node_voho_service{{"Voho service"}}

node_caller -->|"speaks or types"| node_voice_demo
node_demo_page -->|"renders"| node_voice_demo
node_voice_demo -->|"records audio"| node_audio_capture
node_voice_demo -->|"posts audio"| node_transcribe_route
node_voice_demo -->|"posts turn"| node_turn_route
node_voice_demo -->|"renders"| node_transcript
node_voice_demo -->|"renders"| node_tool_log
node_turn_route -->|"handles turn"| node_voho_adapter
node_turn_route -->|"loads brief"| node_agent_prompt
node_turn_route -->|"uses settings"| node_hospital_config
node_transcribe_route -->|"transcribes audio"| node_voho_transcribe
node_status_route -->|"reports settings"| node_hospital_config
node_status_route -->|"checks demo data"| node_knowledge
node_status_route -->|"lists tools"| node_tool_registry
node_voho_adapter -->|"requests replies"| node_voho_agents
node_voho_adapter -->|"runs requested tool"| node_tool_registry
node_voho_adapter -->|"synthesizes answer"| node_voho_speech
node_voho_agents -->|"makes API calls"| node_voho_client
node_voho_speech -->|"makes API calls"| node_voho_client
node_voho_transcribe -->|"uploads audio"| node_voho_client
node_voho_client -->|"calls API"| node_voho_service
node_tool_registry -->|"dispatches"| node_emergency
node_tool_registry -->|"dispatches"| node_appointments
node_tool_registry -->|"dispatches"| node_clinic_transfer
node_tool_registry -->|"dispatches"| node_information
node_agent_prompt -->|"uses facts"| node_knowledge
node_agent_prompt -->|"describes tools"| node_tool_registry
node_knowledge -->|"reads hospital facts"| node_hospital_config
node_emergency -->|"uses emergency settings"| node_hospital_config
node_appointments -->|"checks clinic rules"| node_hospital_config

click node_demo_page "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/app/page.tsx"
click node_voice_demo "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/components/VoiceDemo.tsx"
click node_audio_capture "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/audio/record.ts"
click node_transcript "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/components/Transcript.tsx"
click node_tool_log "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/components/ToolLog.tsx"
click node_turn_route "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/app/api/voice/turn/route.ts"
click node_transcribe_route "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/app/api/voice/transcribe/route.ts"
click node_status_route "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/app/api/status/route.ts"
click node_agent_prompt "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/agentPrompt.ts"
click node_knowledge "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/knowledge/index.ts"
click node_hospital_config "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/config/hospital.ts"
click node_tool_registry "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/tools/index.ts"
click node_emergency "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/tools/escalateEmergency.ts"
click node_appointments "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/tools/appointments.ts"
click node_clinic_transfer "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/tools/transferToClinic.ts"
click node_information "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/tools/sendInformation.ts"
click node_voho_adapter "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/voho/tools.ts"
click node_voho_agents "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/voho/agents.ts"
click node_voho_speech "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/voho/speech.ts"
click node_voho_transcribe "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/voho/transcribe.ts"
click node_voho_client "https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/voho/client.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_demo_page,node_voice_demo,node_audio_capture,node_transcript,node_tool_log toneBlue
class node_turn_route,node_transcribe_route,node_status_route,node_agent_prompt toneAmber
class node_knowledge,node_hospital_config,node_tool_registry,node_emergency,node_appointments,node_clinic_transfer,node_information toneMint
class node_voho_adapter,node_voho_agents,node_voho_speech,node_voho_transcribe,node_voho_client toneRose
class node_caller,node_voho_service toneIndigo
```

## Components

### Caller experience

- [Demo page](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/app/page.tsx): `app/page.tsx`
- [Voice demo](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/components/VoiceDemo.tsx): `components/VoiceDemo.tsx`
- [Audio capture](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/audio/record.ts): `lib/audio/record.ts`
- [Transcript view](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/components/Transcript.tsx): `components/Transcript.tsx`
- [Tool log](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/components/ToolLog.tsx): `components/ToolLog.tsx`

### Conversation server

- [Turn endpoint](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/app/api/voice/turn/route.ts): `app/api/voice/turn/route.ts`
- [Transcription endpoint](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/app/api/voice/transcribe/route.ts): `app/api/voice/transcribe/route.ts`
- [Status endpoint](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/app/api/status/route.ts): `app/api/status/route.ts`
- [Agent brief](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/agentPrompt.ts): `lib/agentPrompt.ts`

### Hospital capabilities

- [Hospital knowledge](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/knowledge/index.ts): `lib/knowledge/index.ts`
- [Hospital configuration](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/config/hospital.ts): `config/hospital.ts`
- [Tool registry](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/tools/index.ts): `lib/tools/index.ts`
- [Emergency escalation](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/tools/escalateEmergency.ts): `lib/tools/escalateEmergency.ts`
- [Appointments](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/tools/appointments.ts): `lib/tools/appointments.ts`
- [Clinic transfer](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/tools/transferToClinic.ts): `lib/tools/transferToClinic.ts`
- [Information delivery](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/tools/sendInformation.ts): `lib/tools/sendInformation.ts`

### Voho integration

- [Tool-call adapter](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/voho/tools.ts): `lib/voho/tools.ts`
- [Agent replies](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/voho/agents.ts): `lib/voho/agents.ts`
- [Speech synthesis](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/voho/speech.ts): `lib/voho/speech.ts`
- [Speech recognition](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/voho/transcribe.ts): `lib/voho/transcribe.ts`
- [API client](https://github.com/yar-malik/voho-hospital-voice-agent/blob/main/lib/voho/client.ts): `lib/voho/client.ts`

### Other components

- **Caller**
- **Voho service**

## Connections

- Caller → Voice demo: speaks or types (evidence: `components/VoiceDemo.tsx`)
- Demo page → Voice demo: renders (evidence: `app/page.tsx`)
- Voice demo → Audio capture: records audio (evidence: `components/VoiceDemo.tsx`)
- Voice demo → Transcription endpoint: posts audio (evidence: `components/VoiceDemo.tsx`)
- Voice demo → Turn endpoint: posts turn (evidence: `components/VoiceDemo.tsx`)
- Voice demo → Transcript view: renders (evidence: `components/VoiceDemo.tsx`)
- Voice demo → Tool log: renders (evidence: `components/VoiceDemo.tsx`)
- Turn endpoint → Tool-call adapter: handles turn (evidence: `app/api/voice/turn/route.ts`)
- Turn endpoint → Agent brief: loads brief (evidence: `app/api/voice/turn/route.ts`)
- Turn endpoint → Hospital configuration: uses settings (evidence: `app/api/voice/turn/route.ts`)
- Transcription endpoint → Speech recognition: transcribes audio (evidence: `app/api/voice/transcribe/route.ts`)
- Status endpoint → Hospital configuration: reports settings (evidence: `app/api/status/route.ts`)
- Status endpoint → Hospital knowledge: checks demo data (evidence: `app/api/status/route.ts`)
- Status endpoint → Tool registry: lists tools (evidence: `app/api/status/route.ts`)
- Tool-call adapter → Agent replies: requests replies (evidence: `lib/voho/tools.ts`)
- Tool-call adapter → Tool registry: runs requested tool (evidence: `lib/voho/tools.ts`)
- Tool-call adapter → Speech synthesis: synthesizes answer (evidence: `lib/voho/tools.ts`)
- Agent replies → API client: makes API calls (evidence: `lib/voho/agents.ts`)
- Speech synthesis → API client: makes API calls (evidence: `lib/voho/speech.ts`)
- Speech recognition → API client: uploads audio (evidence: `lib/voho/transcribe.ts`)
- API client → Voho service: calls API (evidence: `lib/voho/client.ts`)
- Tool registry → Emergency escalation: dispatches (evidence: `lib/tools/index.ts`)
- Tool registry → Appointments: dispatches (evidence: `lib/tools/index.ts`)
- Tool registry → Clinic transfer: dispatches (evidence: `lib/tools/index.ts`)
- Tool registry → Information delivery: dispatches (evidence: `lib/tools/index.ts`)
- Agent brief → Hospital knowledge: uses facts (evidence: `README.md`)
- Agent brief → Tool registry: describes tools (evidence: `README.md`)
- Hospital knowledge → Hospital configuration: reads hospital facts (evidence: `lib/knowledge/index.ts`)
- Emergency escalation → Hospital configuration: uses emergency settings (evidence: `lib/tools/escalateEmergency.ts`)
- Appointments → Hospital configuration: checks clinic rules (evidence: `lib/tools/appointments.ts`)
