# arunsagi7/ai-automatic-calling architecture

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

- Interactive diagram: https://gitdiagram.com/arunsagi7/ai-automatic-calling
- Repository: https://github.com/arunsagi7/ai-automatic-calling

## Overview

The product is an AI calling operations system: a React dashboard manages leads, calls, events, and agents through a FastAPI backend; SnapServe performs telephony and the STT/LLM/TTS conversation. The backend stores operational records, synchronizes event details into agent prompts, and supports webhook updates and asynchronous call work. The graph preserves documented dashboard and simulator capabilities; some worker and tool wiring is documented or indexed but not shown in source excerpts, so uncertain links are omitted or dashed.

Main entry points: [`backend/app/db/session.py`](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/db/session.py) (Application database), [`backend/app/main.py`](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/main.py) (API application), [`backend/app/api/routes/calls.py`](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/api/routes/calls.py) (Calls and campaigns), [`backend/app/services/event_sync_service.py`](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/services/event_sync_service.py) (Event synchronization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Operations dashboard"]
  node_dashboard_ui["Dashboard<br/>[App.jsx]"]
  node_dashboard_client["API client<br/>[client.js]"]
end

subgraph group_api["Backend API"]
  node_api_app["API application<br/>[main.py]"]
  node_calls_api["Calls and campaigns<br/>[calls.py]"]
  node_leads_api["Lead management<br/>[leads.py]"]
  node_events_api["Event management<br/>[events.py]"]
  node_admin_api["Agent administration<br/>[admin.py]"]
  node_webhook_api["SnapServe webhooks<br/>[snapserve.py]"]
  node_signature_check["Signature verification"]
end

subgraph group_voice["Calling and agents"]
  node_snapserve["SnapServe voice service"]
  node_event_sync["Event prompt sync"]
  node_booking_tool["Appointment booking"]
  node_order_tool["Order status lookup"]
  node_transfer_tool["Human transfer"]
end

subgraph group_operations["Persistence and jobs"]
  node_database[("Application database<br/>[session.py]")]
  node_call_records["Call records<br/>[call.py]"]
  node_lead_records["Lead records<br/>[lead.py]"]
  node_event_records["Event records<br/>[event.py]"]
  node_transcript_records["Transcript records<br/>[transcript.py]"]
  node_outbound_worker["Campaign dialer<br/>[outbound_dialer.py]"]
  node_post_call_worker["Post-call jobs<br/>[post_call_jobs.py]"]
  node_crm["CRM service<br/>[crm_service.py]"]
  node_notifications["Notifications"]
  node_event_sync_service["Event synchronization"]
end

node_operator(("Operator"))
node_voice_provider{{"SnapServe platform"}}

node_operator -->|"operates"| node_dashboard_ui
node_dashboard_ui -->|"requests data"| node_dashboard_client
node_dashboard_client -.->|"calls backend"| node_api_app
node_api_app -->|"routes calls"| node_calls_api
node_api_app -->|"routes leads"| node_leads_api
node_api_app -->|"routes events"| node_events_api
node_api_app -->|"routes admin"| node_admin_api
node_api_app -->|"routes webhooks"| node_webhook_api
node_calls_api -->|"places and reads calls"| node_snapserve
node_admin_api -->|"manages agents"| node_snapserve
node_snapserve -->|"calls API"| node_voice_provider
node_voice_provider -.->|"returns call results"| node_calls_api
node_webhook_api -->|"verifies signature"| node_signature_check
node_webhook_api -->|"updates records"| node_database
node_calls_api -->|"reads and writes"| node_database
node_leads_api -->|"reads and writes"| node_database
node_events_api -->|"reads and writes"| node_database
node_database -->|"persists"| node_call_records
node_database -->|"persists"| node_lead_records
node_database -->|"persists"| node_event_records
node_database -->|"persists"| node_transcript_records
node_events_api -->|"synchronizes changes"| node_event_sync_service
node_calls_api -->|"syncs before dialing"| node_event_sync_service
node_event_sync_service -->|"reads active events"| node_database
node_event_sync_service -->|"updates agent prompt"| node_snapserve
node_calls_api -.->|"queues campaign dialing"| node_outbound_worker
node_outbound_worker -->|"places outbound calls"| node_snapserve
node_outbound_worker -->|"reads and updates"| node_database
node_outbound_worker -->|"syncs before dialing"| node_event_sync_service
node_post_call_worker -->|"loads call data"| node_database
node_post_call_worker -->|"syncs outcomes"| node_crm
node_post_call_worker -->|"sends updates"| node_notifications
node_voice_provider -.->|"invokes tool"| node_booking_tool
node_voice_provider -.->|"invokes tool"| node_order_tool
node_voice_provider -.->|"invokes tool"| node_transfer_tool

click node_dashboard_ui "https://github.com/arunsagi7/ai-automatic-calling/blob/main/frontend/src/App.jsx"
click node_dashboard_client "https://github.com/arunsagi7/ai-automatic-calling/blob/main/frontend/src/api/client.js"
click node_api_app "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/main.py"
click node_calls_api "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/api/routes/calls.py"
click node_leads_api "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/api/routes/leads.py"
click node_events_api "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/api/routes/events.py"
click node_admin_api "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/api/routes/admin.py"
click node_webhook_api "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/api/routes/webhooks/snapserve.py"
click node_signature_check "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/middleware/webhook_signature.py"
click node_snapserve "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/services/snapserve_service.py"
click node_event_sync "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/services/event_sync_service.py"
click node_booking_tool "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/functions/book_appointment.py"
click node_order_tool "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/functions/check_order_status.py"
click node_transfer_tool "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/functions/transfer_to_human.py"
click node_database "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/db/session.py"
click node_call_records "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/models/call.py"
click node_lead_records "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/models/lead.py"
click node_event_records "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/models/event.py"
click node_transcript_records "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/models/transcript.py"
click node_outbound_worker "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/workers/outbound_dialer.py"
click node_post_call_worker "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/workers/post_call_jobs.py"
click node_crm "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/services/crm_service.py"
click node_notifications "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/services/notification_service.py"
click node_event_sync_service "https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/services/event_sync_service.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_dashboard_ui,node_dashboard_client toneBlue
class node_api_app,node_calls_api,node_leads_api,node_events_api,node_admin_api,node_webhook_api,node_signature_check toneAmber
class node_snapserve,node_event_sync,node_booking_tool,node_order_tool,node_transfer_tool toneMint
class node_database,node_call_records,node_lead_records,node_event_records,node_transcript_records,node_outbound_worker,node_post_call_worker,node_crm,node_notifications,node_event_sync_service toneRose
class node_operator,node_voice_provider toneIndigo
```

## Components

### Operations dashboard

- [Dashboard](https://github.com/arunsagi7/ai-automatic-calling/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [API client](https://github.com/arunsagi7/ai-automatic-calling/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`

### Backend API

- [API application](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/main.py): `backend/app/main.py`
- [Calls and campaigns](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/api/routes/calls.py): `backend/app/api/routes/calls.py`
- [Lead management](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/api/routes/leads.py): `backend/app/api/routes/leads.py`
- [Event management](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/api/routes/events.py): `backend/app/api/routes/events.py`
- [Agent administration](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/api/routes/admin.py): `backend/app/api/routes/admin.py`
- [SnapServe webhooks](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/api/routes/webhooks/snapserve.py): `backend/app/api/routes/webhooks/snapserve.py`
- [Signature verification](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/middleware/webhook_signature.py): `backend/app/middleware/webhook_signature.py`

### Calling and agents

- [SnapServe voice service](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/services/snapserve_service.py): `backend/app/services/snapserve_service.py`
- [Event prompt sync](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/services/event_sync_service.py): `backend/app/services/event_sync_service.py`
- [Appointment booking](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/functions/book_appointment.py): `backend/app/functions/book_appointment.py`
- [Order status lookup](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/functions/check_order_status.py): `backend/app/functions/check_order_status.py`
- [Human transfer](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/functions/transfer_to_human.py): `backend/app/functions/transfer_to_human.py`

### Persistence and jobs

- [Application database](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/db/session.py): `backend/app/db/session.py`
- [Call records](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/models/call.py): `backend/app/models/call.py`
- [Lead records](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/models/lead.py): `backend/app/models/lead.py`
- [Event records](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/models/event.py): `backend/app/models/event.py`
- [Transcript records](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/models/transcript.py): `backend/app/models/transcript.py`
- [Campaign dialer](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/workers/outbound_dialer.py): `backend/app/workers/outbound_dialer.py`
- [Post-call jobs](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/workers/post_call_jobs.py): `backend/app/workers/post_call_jobs.py`
- [CRM service](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/services/crm_service.py): `backend/app/services/crm_service.py`
- [Notifications](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/services/notification_service.py): `backend/app/services/notification_service.py`
- [Event synchronization](https://github.com/arunsagi7/ai-automatic-calling/blob/main/backend/app/services/event_sync_service.py): `backend/app/services/event_sync_service.py`

### Other components

- **Operator**
- **SnapServe platform**

## Connections

- Operator → Dashboard: operates (evidence: `README.md`)
- Dashboard → API client: requests data (evidence: `frontend/src/App.jsx`)
- API client → API application: calls backend (evidence: `README.md`)
- API application → Calls and campaigns: routes calls (evidence: `backend/app/main.py`)
- API application → Lead management: routes leads (evidence: `backend/app/main.py`)
- API application → Event management: routes events (evidence: `backend/app/main.py`)
- API application → Agent administration: routes admin (evidence: `backend/app/main.py`)
- API application → SnapServe webhooks: routes webhooks (evidence: `backend/app/main.py`)
- Calls and campaigns → SnapServe voice service: places and reads calls (evidence: `backend/app/api/routes/calls.py`)
- Agent administration → SnapServe voice service: manages agents (evidence: `backend/app/api/routes/admin.py`)
- SnapServe voice service → SnapServe platform: calls API (evidence: `backend/app/services/snapserve_service.py`)
- SnapServe platform → Calls and campaigns: returns call results (evidence: `README.md`)
- SnapServe webhooks → Signature verification: verifies signature (evidence: `backend/app/api/routes/webhooks/snapserve.py`)
- SnapServe webhooks → Application database: updates records (evidence: `backend/app/api/routes/webhooks/snapserve.py`)
- Calls and campaigns → Application database: reads and writes (evidence: `backend/app/api/routes/calls.py`)
- Lead management → Application database: reads and writes (evidence: `backend/app/api/routes/leads.py`)
- Event management → Application database: reads and writes (evidence: `backend/app/api/routes/events.py`)
- Application database → Call records: persists (evidence: `backend/app/models/call.py`)
- Application database → Lead records: persists (evidence: `backend/app/models/lead.py`)
- Application database → Event records: persists (evidence: `backend/app/models/event.py`)
- Application database → Transcript records: persists (evidence: `backend/app/models/transcript.py`)
- Event management → Event synchronization: synchronizes changes (evidence: `backend/app/api/routes/events.py`)
- Calls and campaigns → Event synchronization: syncs before dialing (evidence: `backend/app/api/routes/calls.py`)
- Event synchronization → Application database: reads active events (evidence: `backend/app/services/event_sync_service.py`)
- Event synchronization → SnapServe voice service: updates agent prompt (evidence: `backend/app/services/event_sync_service.py`)
- Calls and campaigns → Campaign dialer: queues campaign dialing
- Campaign dialer → SnapServe voice service: places outbound calls (evidence: `backend/app/workers/outbound_dialer.py`)
- Campaign dialer → Application database: reads and updates (evidence: `backend/app/workers/outbound_dialer.py`)
- Campaign dialer → Event synchronization: syncs before dialing (evidence: `backend/app/workers/outbound_dialer.py`)
- Post-call jobs → Application database: loads call data (evidence: `backend/app/workers/post_call_jobs.py`)
- Post-call jobs → CRM service: syncs outcomes (evidence: `backend/app/workers/post_call_jobs.py`)
- Post-call jobs → Notifications: sends updates (evidence: `backend/app/workers/post_call_jobs.py`)
- SnapServe platform → Appointment booking: invokes tool
- SnapServe platform → Order status lookup: invokes tool
- SnapServe platform → Human transfer: invokes tool
