# sushiv0722/infocallhub architecture

> Architecture diagram of the GitHub repository sushiv0722/infocallhub, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sushiv0722/infocallhub
- Repository: https://github.com/sushiv0722/infocallhub

## Overview

1. **What this repo is**
   - This is an AI-assisted telephony platform called **InfoCallHub**.
   - The system combines **outbound/interactive calling**, **SMS**, **call recording**, and **call analytics** with an **LLM-backed response layer**.
   - The runtime boundary is split between a local Python app, Twilio telephony services, and external AI services.

2. **User-facing entry points**
   - The README indicates the app is deployed with **Streamlit** and **Flask**.
   - Streamlit is likely the operator console for starting calls, viewing stats, and managing interactions.
   - Flask is the network-facing backend that receives webhook callbacks from Twilio and serves request/response endpoints.

3. **Telephony orchestration layer**
   - `make_calls.py` is the outbound-call orchestrator.
   - This module is likely responsible for initiating calls through **Twilio**, attaching the correct webhook URLs, and driving the “100+ simultaneous queries” behavior described in the README.
   - It acts as the bridge between the UI/automation layer and the telephony provider.

4. **Call handling / AI response server**
   - `serverAI.py` appears to be the main backend service for live call handling.
   - This is probably where Twilio webhook requests land during an active call.
   - It likely coordinates speech/text exchange, session state, and the AI response pipeline before sending replies back to Twilio.

5. **LLM / reasoning subsystem**
   - `gemini.py` is the dedicated AI integration module.
   - The README mentions **LangChain** and **OpenAI API**, while the file name suggests a Gemini connector; the repo likely abstracts model access behind this module.
   - This subsystem is the “brain” of the system: it receives a caller’s query, enriches or routes it through LangChain-style orchestration, and returns a generated answer.

6. **Messaging subsystem**
   - `sms.py` is the SMS channel.
   - It likely sends transactional messages or follow-ups through Twilio SMS, independent of live voice calls.
   - This is a separate communication path from voice, but it probably shares the same identity/configuration layer and possibly the same user/session data.

7. **Recording subsystem**
   - `recordings.py` handles call recording metadata or retrieval.
   - Twilio likely records the call and posts recording events or URLs back to the backend.
   - This module probably stores, lists, or processes recording references for later review.

8. **Statistics / observability subsystem**
   - `call_statistics.py` is the analytics layer for call volume, duration, outcomes, and other performance metrics.
   - The README explicitly mentions **SQL**, so this module likely reads/writes aggregated call data to a database.
   - This is the reporting boundary of the system: it summarizes the telephony workflow rather than participating in live call response.

9. **External services and infrastructure**
   - **Twilio** is the core communications provider for voice calls, SMS, and likely recordings.
   - **Flask** exposes public webhook endpoints, while **ngrok** makes the local Flask service reachable from Twilio during development/deployment.
   - **Streamlit** provides the operational UI.
   - **OpenAI API / LangChain / Gemini** provide the AI layer.
   - **SQL** is the persistence layer for call records, stats, and possibly conversation/session data.

10. **Configuration and secrets**
   - `.env` suggests runtime configuration is centralized in environment variables.
   - This likely includes Twilio credentials, AI API keys, webhook URLs, and database connection settings.
   - The architecture depends on external-service credentials rather than hardcoded settings.

11. **Primary runtime data flow**
   - A user/operator starts or manages a call from the UI.
   - `make_calls.py` requests Twilio to place the call.
   - Twilio connects to the caller and invokes Flask webhooks on `serverAI.py`.
   - `serverAI.py` forwards the caller’s input to the AI layer in `gemini.py`.
   - The generated answer is returned to Twilio to continue the live conversation.
   - In parallel, call metadata can be recorded, messaged, and written into SQL for later analytics.

12. **Key architectural boundary**
   - The most important boundary is between **real-time telephony callbacks** and **supporting services**.
   - Live call handling must be low-latency and webhook-driven.
   - Recording, statistics, and SMS are secondary workflows that consume the same call/session context but do not drive the conversation itself.

13. **How to think about the diagram**
   - Place **Streamlit** at the operator edge.
   - Place **Flask/serverAI** as the webhook/backend core.
   - Place **Twilio** between the backend and external callers.
   - Place **gemini.py / LangChain / OpenAI** as the AI engine behind the backend.
   - Place **SQL** underneath analytics/storage.
   - Place **sms.py**, **recordings.py**, and **call_statistics.py** as sidecar subsystems branching from the main call flow.

Main entry points: [`serverAI.py`](https://github.com/sushiv0722/infocallhub/blob/main/serverAI.py) (Call Server), [`make_calls.py`](https://github.com/sushiv0722/infocallhub/blob/main/make_calls.py) (Call Orchestrator), [`README.md`](https://github.com/sushiv0722/infocallhub/blob/main/README.md) (README), [`gemini.py`](https://github.com/sushiv0722/infocallhub/blob/main/gemini.py) (AI Layer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operator["Operator Edge"]
  node_readme["README<br/>docs/entry<br/>[README.md]"]
  node_streamlit["Streamlit UI<br/>operator console"]
end

subgraph group_runtime["Runtime Core"]
  node_make_calls["Call Orchestrator<br/>outbound calling<br/>[make_calls.py]"]
  node_server_ai["Call Server<br/>webhook backend<br/>[serverAI.py]"]
  node_gemini{{"AI Layer<br/>llm integration<br/>[gemini.py]"}}
end

subgraph group_services["External Services"]
  node_twilio(("Twilio<br/>telephony provider"))
  node_flask["Flask<br/>web server"]
  node_streamlit_runtime["Streamlit<br/>ui runtime"]
  node_ngrok["ngrok<br/>tunnel"]
  node_langchain{{"LangChain<br/>llm orchestration"}}
  node_openai{{"OpenAI/Gemini<br/>ai api"}}
end

subgraph group_sidecars["Supporting Workflows"]
  node_sms["SMS Channel<br/>messaging<br/>[sms.py]"]
  node_recordings["Recordings<br/>call media<br/>[recordings.py]"]
  node_stats["Call Stats<br/>analytics<br/>[call_statistics.py]"]
end

subgraph group_storage["Data Layer"]
  node_sql[("SQL Store<br/>persistence")]
end

node_readme -.->|"describes"| node_streamlit
node_readme -.->|"describes"| node_flask
node_streamlit -->|"starts"| node_make_calls
node_make_calls -->|"places calls"| node_twilio
node_twilio -->|"webhooks"| node_server_ai
node_server_ai -->|"queries"| node_gemini
node_gemini -->|"orchestrates"| node_langchain
node_langchain -->|"generates"| node_openai
node_server_ai -.->|"triggers"| node_sms
node_server_ai -.->|"tracks"| node_recordings
node_server_ai -.->|"logs"| node_stats
node_recordings -.->|"stores"| node_sql
node_stats -->|"reads/writes"| node_sql
node_make_calls -.->|"exposes"| node_ngrok
node_ngrok -->|"forwards"| node_flask
node_flask -->|"hosts"| node_server_ai
node_streamlit_runtime -.->|"runs"| node_streamlit

click node_readme "https://github.com/sushiv0722/infocallhub/blob/main/README.md"
click node_make_calls "https://github.com/sushiv0722/infocallhub/blob/main/make_calls.py"
click node_server_ai "https://github.com/sushiv0722/infocallhub/blob/main/serverAI.py"
click node_gemini "https://github.com/sushiv0722/infocallhub/blob/main/gemini.py"
click node_sms "https://github.com/sushiv0722/infocallhub/blob/main/sms.py"
click node_recordings "https://github.com/sushiv0722/infocallhub/blob/main/recordings.py"
click node_stats "https://github.com/sushiv0722/infocallhub/blob/main/call_statistics.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_readme,node_streamlit toneBlue
class node_make_calls,node_server_ai,node_gemini toneAmber
class node_twilio,node_flask,node_streamlit_runtime,node_ngrok,node_langchain,node_openai toneMint
class node_sms,node_recordings,node_stats toneRose
class node_sql toneIndigo
```

## Components

### Operator Edge

User-facing control and deployment entry points

- [README](https://github.com/sushiv0722/infocallhub/blob/main/README.md): docs/entry · Project overview and deployment notes · `README.md`
- **Streamlit UI**: operator console · Operator-facing app for starting and monitoring calls

### Runtime Core

Live call orchestration and webhook handling

- [Call Orchestrator](https://github.com/sushiv0722/infocallhub/blob/main/make_calls.py): outbound calling · Starts outbound calls and attaches webhook callbacks · `make_calls.py`
- [Call Server](https://github.com/sushiv0722/infocallhub/blob/main/serverAI.py): webhook backend · Receives Twilio callbacks and manages live call flow · `serverAI.py`
- [AI Layer](https://github.com/sushiv0722/infocallhub/blob/main/gemini.py): llm integration · Model access and response generation · `gemini.py`

### External Services

Telephony, AI, and tunneling dependencies

- **Twilio**: telephony provider · Voice, SMS, and recording infrastructure
- **Flask**: web server · HTTP/webhook runtime for backend endpoints
- **Streamlit**: ui runtime · Local operator app runtime
- **ngrok**: tunnel · Exposes local webhooks to Twilio during development
- **LangChain**: llm orchestration · Reasoning and prompt orchestration layer
- **OpenAI/Gemini**: ai api · External model and generation services

### Supporting Workflows

Secondary channels and post-call processing

- [SMS Channel](https://github.com/sushiv0722/infocallhub/blob/main/sms.py): messaging · Sends text-message follow-ups and notifications · `sms.py`
- [Recordings](https://github.com/sushiv0722/infocallhub/blob/main/recordings.py): call media · Recording metadata and retrieval workflow · `recordings.py`
- [Call Stats](https://github.com/sushiv0722/infocallhub/blob/main/call_statistics.py): analytics · Summarizes call volume, duration, and outcomes · `call_statistics.py`

### Data Layer

Persistent call and analytics data

- **SQL Store**: persistence · Stores call records and analytics data

## Connections

- README → Streamlit UI: describes · Documents the operator console and deployment model
- README → Flask: describes · Documents webhook/backend behavior
- Streamlit UI → Call Orchestrator: starts · Operator actions trigger outbound calls
- Call Orchestrator → Twilio: places calls · Requests Twilio to initiate voice calls
- Twilio → Call Server: webhooks · Routes live call callbacks into the backend
- Call Server → AI Layer: queries · Sends caller input to the response engine
- AI Layer → LangChain: orchestrates · Uses LangChain-style reasoning and routing
- LangChain → OpenAI/Gemini: generates · Calls external model APIs for answers
- Call Server → SMS Channel: triggers · Sends follow-up or transactional messages
- Call Server → Recordings: tracks · Consumes recording events and references
- Call Server → Call Stats: logs · Writes call outcomes for reporting
- Recordings → SQL Store: stores · Persists recording metadata or links
- Call Stats → SQL Store: reads/writes · Aggregates call metrics in SQL
- Call Orchestrator → ngrok: exposes · Makes local webhook endpoints reachable
- ngrok → Flask: forwards · Tunnels public traffic to the local server
- Flask → Call Server: hosts · Runs the live call handling endpoints
- Streamlit → Streamlit UI: runs · Local app runtime for the operator UI
