# shakthiswaran-m/voice-calling-agent architecture

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

- Interactive diagram: https://gitdiagram.com/shakthiswaran-m/voice-calling-agent
- Repository: https://github.com/shakthiswaran-m/voice-calling-agent

## Overview

This is a customer-support assistant for browser chat and phone calls, sharing an LLM-backed agent with customer, appointment, service, consultation, FAQ, case-study, and website-search tools. In web chat, a user submits a message through the React chat UI and FastAPI chat route; the agent obtains a response and conversation data is persisted. Browser voice adds audio transcription and speech playback. Phone calling uses Exotel with STT and TTS as communication services. The phone-to-agent orchestration and chat-route implementation were not sampled, so those documented connections are marked unverified.

Main entry points: [`backend/app/api/voice.py`](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/api/voice.py) (Voice API), [`frontend/src/App.tsx`](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/App.tsx) (App shell), [`backend/app/providers/llm.py`](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/providers/llm.py) (LLM response engine), [`backend/app/database.py`](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/database.py) (Conversation and content store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_app["App shell<br/>[App.tsx]"]
  node_chat_ui["Chat interface<br/>[ChatArea.tsx]"]
  node_thread_nav["Thread navigation<br/>[ThreadNav.tsx]"]
  node_voice_ui["Browser voice"]
  node_shared_page["Shared conversations"]
  node_chat_state["Chat state<br/>[useChatStore.ts]"]
  node_frontend_api["API client<br/>[api.ts]"]
  node_speech_service["Browser speech"]
end

subgraph group_backend["Agent backend"]
  node_chat_route["Chat API<br/>[chat.py]"]
  node_llm["LLM response engine<br/>[llm.py]"]
  node_prompts["Agent instructions<br/>[prompts.py]"]
  node_tools["Agent tools<br/>[tools.py]"]
  node_server["API startup<br/>[main.py]"]
end

subgraph group_voice["Voice services"]
  node_voice_api["Voice API<br/>[voice.py]"]
  node_stt["Speech recognition<br/>[stt.py]"]
  node_tts["Speech generation<br/>[tts.py]"]
  node_exotel["Exotel adapter<br/>[exotel.py]"]
end

subgraph group_data["Knowledge and persistence"]
  node_scraper["Website scraper<br/>[website_scraper.py]"]
  node_database[("Conversation and content store<br/>[database.py]")]
end

node_user(("Chat user"))
node_llm_service{{"LLM provider"}}
node_postgres[("PostgreSQL")]
node_phone_user(("Phone caller"))
node_exotel_service{{"Exotel telephony"}}

node_user -->|"opens"| node_app
node_app -->|"renders"| node_chat_ui
node_app -->|"renders"| node_thread_nav
node_app -->|"reads state"| node_chat_state
node_voice_ui -->|"uses state"| node_chat_state
node_voice_ui -->|"calls"| node_frontend_api
node_voice_ui -->|"uses fallback"| node_speech_service
node_frontend_api -.->|"sends chat"| node_chat_route
node_chat_route -.->|"requests response"| node_llm
node_llm -.->|"calls"| node_llm_service
node_llm -->|"uses instructions"| node_prompts
node_llm -->|"dispatches tools"| node_tools
node_tools -->|"queries data"| node_database
node_chat_route -.->|"persists conversations"| node_database
node_server -->|"registers"| node_chat_route
node_server -->|"registers"| node_voice_api
node_server -->|"connects"| node_database
node_server -->|"schedules"| node_scraper
node_scraper -->|"saves content"| node_database
node_database -->|"stores records"| node_postgres
node_voice_ui -.->|"submits audio"| node_voice_api
node_voice_api -->|"transcribes"| node_stt
node_voice_api -->|"streams speech"| node_tts
node_voice_api -->|"initiates call"| node_exotel
node_phone_user -->|"calls through"| node_exotel_service
node_exotel_service -.->|"streams audio"| node_voice_api
node_voice_api -.->|"forwards recognized speech"| node_llm
node_tts -.->|"returns audio"| node_exotel_service
node_app -->|"routes shared links"| node_shared_page

click node_app "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/App.tsx"
click node_chat_ui "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/components/chat/ChatArea.tsx"
click node_thread_nav "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/components/chat/ThreadNav.tsx"
click node_voice_ui "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/components/chat/SpeechToSpeechMode.tsx"
click node_shared_page "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/components/chat/SharedConversationPage.tsx"
click node_chat_state "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/store/useChatStore.ts"
click node_frontend_api "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/lib/api.ts"
click node_speech_service "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/lib/speechSynthesisService.ts"
click node_chat_route "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/api/chat.py"
click node_llm "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/providers/llm.py"
click node_prompts "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/agent/prompts.py"
click node_tools "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/agent/tools.py"
click node_voice_api "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/api/voice.py"
click node_stt "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/providers/stt.py"
click node_tts "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/providers/tts.py"
click node_exotel "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/providers/exotel.py"
click node_scraper "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/website_scraper.py"
click node_database "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/database.py"
click node_server "https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/main.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_app,node_chat_ui,node_thread_nav,node_voice_ui,node_shared_page,node_chat_state,node_frontend_api,node_speech_service,node_user toneBlue
class node_chat_route,node_llm,node_prompts,node_tools,node_server,node_postgres toneAmber
class node_voice_api,node_stt,node_tts,node_exotel toneMint
class node_scraper,node_database toneRose
class node_llm_service,node_phone_user,node_exotel_service toneIndigo
```

## Components

### Web experience

- [App shell](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Chat interface](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/components/chat/ChatArea.tsx): `frontend/src/components/chat/ChatArea.tsx`
- [Thread navigation](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/components/chat/ThreadNav.tsx): `frontend/src/components/chat/ThreadNav.tsx`
- [Browser voice](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/components/chat/SpeechToSpeechMode.tsx): `frontend/src/components/chat/SpeechToSpeechMode.tsx`
- [Shared conversations](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/components/chat/SharedConversationPage.tsx): `frontend/src/components/chat/SharedConversationPage.tsx`
- [Chat state](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/store/useChatStore.ts): `frontend/src/store/useChatStore.ts`
- [API client](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [Browser speech](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/frontend/src/lib/speechSynthesisService.ts): `frontend/src/lib/speechSynthesisService.ts`

### Agent backend

- [Chat API](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/api/chat.py): `backend/app/api/chat.py`
- [LLM response engine](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/providers/llm.py): `backend/app/providers/llm.py`
- [Agent instructions](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/agent/prompts.py): `backend/app/agent/prompts.py`
- [Agent tools](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/agent/tools.py): `backend/app/agent/tools.py`
- [API startup](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/main.py): `backend/app/main.py`

### Voice services

- [Voice API](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/api/voice.py): `backend/app/api/voice.py`
- [Speech recognition](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/providers/stt.py): `backend/app/providers/stt.py`
- [Speech generation](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/providers/tts.py): `backend/app/providers/tts.py`
- [Exotel adapter](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/providers/exotel.py): `backend/app/providers/exotel.py`

### Knowledge and persistence

- [Website scraper](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/website_scraper.py): `backend/app/website_scraper.py`
- [Conversation and content store](https://github.com/shakthiswaran-m/voice-calling-agent/blob/main/backend/app/database.py): `backend/app/database.py`

### Other components

- **Chat user**
- **LLM provider**
- **PostgreSQL**
- **Phone caller**
- **Exotel telephony**

## Connections

- Chat user → App shell: opens (evidence: `README.md`)
- App shell → Chat interface: renders (evidence: `frontend/src/App.tsx`)
- App shell → Thread navigation: renders (evidence: `frontend/src/App.tsx`)
- App shell → Chat state: reads state (evidence: `frontend/src/App.tsx`)
- Browser voice → Chat state: uses state (evidence: `frontend/src/components/chat/SpeechToSpeechMode.tsx`)
- Browser voice → API client: calls (evidence: `frontend/src/components/chat/SpeechToSpeechMode.tsx`)
- Browser voice → Browser speech: uses fallback (evidence: `frontend/src/components/chat/SpeechToSpeechMode.tsx`)
- API client → Chat API: sends chat (evidence: `README.md`)
- Chat API → LLM response engine: requests response (evidence: `README.md`)
- LLM response engine → LLM provider: calls (evidence: `README.md`)
- LLM response engine → Agent instructions: uses instructions (evidence: `backend/app/providers/llm.py`)
- LLM response engine → Agent tools: dispatches tools (evidence: `backend/app/providers/llm.py`)
- Agent tools → Conversation and content store: queries data (evidence: `backend/app/agent/tools.py`)
- Chat API → Conversation and content store: persists conversations (evidence: `README.md`)
- API startup → Chat API: registers (evidence: `backend/app/main.py`)
- API startup → Voice API: registers (evidence: `backend/app/main.py`)
- API startup → Conversation and content store: connects (evidence: `backend/app/main.py`)
- API startup → Website scraper: schedules (evidence: `backend/app/main.py`)
- Website scraper → Conversation and content store: saves content (evidence: `backend/app/website_scraper.py`)
- Conversation and content store → PostgreSQL: stores records (evidence: `README.md`)
- Browser voice → Voice API: submits audio (evidence: `README.md`)
- Voice API → Speech recognition: transcribes (evidence: `backend/app/api/voice.py`)
- Voice API → Speech generation: streams speech (evidence: `backend/app/api/voice.py`)
- Voice API → Exotel adapter: initiates call (evidence: `backend/app/api/voice.py`)
- Phone caller → Exotel telephony: calls through (evidence: `README.md`)
- Exotel telephony → Voice API: streams audio (evidence: `README.md`)
- Voice API → LLM response engine: forwards recognized speech (evidence: `README.md`)
- Speech generation → Exotel telephony: returns audio (evidence: `README.md`)
- App shell → Shared conversations: routes shared links (evidence: `frontend/src/App.tsx`)
