# pavaner2007/admissioncallagent architecture

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

- Interactive diagram: https://gitdiagram.com/pavaner2007/admissioncallagent
- Repository: https://github.com/pavaner2007/admissioncallagent

## Overview

#### Purpose and Entry Points
MindBloom AI is a real-time mental-health voice companion for telephone calls. Its primary runtime is an async FastAPI service, started from `app/main.py`, that accepts Twilio call/media events through `app/api/call_handler.py`. Container deployment is defined by `Dockerfile`; `render.yaml` indicates managed-host deployment support.

#### Telephony and Session Boundary
Twilio is the external call-control and bidirectional media-stream provider. The call handler is the ingress boundary for incoming webhooks and WebSocket audio; Twilio-specific operations are isolated in `app/services/twilio_service.py`. Per-call handling must preserve conversation context, language, sentiment, and crisis state while keeping media processing asynchronous.
- `app/api/call_handler.py`
- `app/services/twilio_service.py`
- `app/main.py`

#### Audio Processing Pipeline
Caller audio arrives as Twilio μ-law/8 kHz media. Audio utilities perform the format boundary needed for speech processing, while synthesized output is converted back to telephony-compatible audio before return over the stream. FFmpeg is a material runtime dependency per the project design.
- `app/utils/audio_utils.py`
- `app/services/twilio_service.py`
- `app/services/sarvam_service.py`

#### Speech AI Stage
Sarvam AI provides multilingual speech-to-text and text-to-speech. The orchestration flow is inbound audio → transcription → response text → synthesized audio. This service is the provider boundary for API credentials, request/response formats, language selection, and speech latency.
- `app/services/sarvam_service.py`
- `app/utils/audio_utils.py`

#### Conversational Intelligence and Safety
The intelligence service owns Groq-backed LLM interaction and conversation behavior: empathetic responses, guided breathing, mood/sentiment handling, crisis detection, and appointment-booking intent. It consumes transcribed text plus session history and returns response text and actionable safety/integration signals rather than directly owning telephony transport.
- `app/services/intelligence_service.py`
- `app/api/call_handler.py`

#### Notification and External Actions
Crisis escalation and session-summary notifications cross an SMTP/email boundary via the email service. Google Forms is an external scheduling target surfaced by booking intent; the repository tree does not show a dedicated Google Forms adapter, so this likely remains URL/intent-driven logic in intelligence orchestration.
- `app/services/email_service.py`
- `app/services/intelligence_service.py`

#### Operational Shape and Legacy Surface
The supported application package is under `app/`, with Python 3.11+, FastAPI/ASGI, Docker, Twilio, Sarvam, Groq, SMTP, and optional public tunneling for local webhook development. Root-level `prototype.py`, `rag_service.py`, `twilio_handler.py`, and `test_call.py` appear to be prototype or alternate integration surfaces; avoid treating them as the primary production path without validating usage.
- `pyproject.toml`
- `requirements.txt`
- `Dockerfile`

Main entry points: [`app/api/call_handler.py`](https://github.com/pavaner2007/admissioncallagent/blob/main/app/api/call_handler.py) (Call Handler), [`app/services/intelligence_service.py`](https://github.com/pavaner2007/admissioncallagent/blob/main/app/services/intelligence_service.py) (Intelligence Service), [`app/utils/audio_utils.py`](https://github.com/pavaner2007/admissioncallagent/blob/main/app/utils/audio_utils.py) (Audio Utilities), [`app/main.py`](https://github.com/pavaner2007/admissioncallagent/blob/main/app/main.py) (FastAPI Application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application Runtime"]
  node_main["FastAPI Application<br/>ASGI entry point<br/>[main.py]"]
  node_call_handler["Call Handler<br/>webhook and media ingress<br/>[call_handler.py]"]
  node_twilio_service["Twilio Service<br/>telephony adapter<br/>[twilio_service.py]"]
  node_email_service["Email Service<br/>notification adapter<br/>[email_service.py]"]
  node_docker["Container Deployment<br/>deployment definition"]
end

subgraph group_pipeline["Voice &amp; Intelligence Pipeline"]
  node_audio_utils["Audio Utilities<br/>audio format adapter<br/>[audio_utils.py]"]
  node_sarvam_service["Sarvam Service<br/>speech AI adapter<br/>[sarvam_service.py]"]
  node_intelligence_service["Intelligence Service<br/>conversation orchestration"]
  node_ffmpeg["FFmpeg<br/>audio runtime dependency"]
end

subgraph group_external["External Providers"]
  node_twilio{{"Twilio<br/>telephony provider"}}
  node_sarvam{{"Sarvam AI<br/>speech provider"}}
  node_groq{{"Groq<br/>LLM provider"}}
  node_smtp{{"SMTP Email<br/>notification provider"}}
  node_google_forms{{"Google Forms<br/>scheduling target"}}
end

node_twilio -->|"webhooks and media stream"| node_call_handler
node_main -->|"mounts routes"| node_call_handler
node_call_handler -->|"call control and stream I/O"| node_twilio_service
node_call_handler -->|"inbound and outbound audio"| node_audio_utils
node_audio_utils -->|"speech-ready audio"| node_sarvam_service
node_audio_utils -->|"format conversion"| node_ffmpeg
node_sarvam_service -->|"STT and TTS requests"| node_sarvam
node_call_handler -->|"transcript and session history"| node_intelligence_service
node_intelligence_service -->|"LLM interaction"| node_groq
node_intelligence_service -->|"crisis and summary notifications"| node_email_service
node_email_service -->|"sends email"| node_smtp
node_intelligence_service -.->|"booking intent"| node_google_forms
node_twilio_service -->|"call and media responses"| node_twilio
node_docker -->|"runs service"| node_main

click node_main "https://github.com/pavaner2007/admissioncallagent/blob/main/app/main.py"
click node_call_handler "https://github.com/pavaner2007/admissioncallagent/blob/main/app/api/call_handler.py"
click node_twilio_service "https://github.com/pavaner2007/admissioncallagent/blob/main/app/services/twilio_service.py"
click node_audio_utils "https://github.com/pavaner2007/admissioncallagent/blob/main/app/utils/audio_utils.py"
click node_sarvam_service "https://github.com/pavaner2007/admissioncallagent/blob/main/app/services/sarvam_service.py"
click node_intelligence_service "https://github.com/pavaner2007/admissioncallagent/blob/main/app/services/intelligence_service.py"
click node_email_service "https://github.com/pavaner2007/admissioncallagent/blob/main/app/services/email_service.py"
click node_docker "https://github.com/pavaner2007/admissioncallagent/blob/main/Dockerfile"

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_main,node_call_handler,node_twilio_service,node_email_service,node_docker toneBlue
class node_audio_utils,node_sarvam_service,node_intelligence_service,node_ffmpeg toneAmber
class node_twilio,node_sarvam,node_groq,node_smtp,node_google_forms toneMint
```

## Components

### Application Runtime

- [FastAPI Application](https://github.com/pavaner2007/admissioncallagent/blob/main/app/main.py): ASGI entry point · `app/main.py`
- [Call Handler](https://github.com/pavaner2007/admissioncallagent/blob/main/app/api/call_handler.py): webhook and media ingress · Maintains asynchronous per-call session state. · `app/api/call_handler.py`
- [Twilio Service](https://github.com/pavaner2007/admissioncallagent/blob/main/app/services/twilio_service.py): telephony adapter · `app/services/twilio_service.py`
- [Email Service](https://github.com/pavaner2007/admissioncallagent/blob/main/app/services/email_service.py): notification adapter · `app/services/email_service.py`
- [Container Deployment](https://github.com/pavaner2007/admissioncallagent/blob/main/Dockerfile): deployment definition · `Dockerfile`

### Voice & Intelligence Pipeline

- [Audio Utilities](https://github.com/pavaner2007/admissioncallagent/blob/main/app/utils/audio_utils.py): audio format adapter · Converts Twilio μ-law/8 kHz audio for speech processing and return. · `app/utils/audio_utils.py`
- [Sarvam Service](https://github.com/pavaner2007/admissioncallagent/blob/main/app/services/sarvam_service.py): speech AI adapter · Handles multilingual transcription and synthesis. · `app/services/sarvam_service.py`
- [Intelligence Service](https://github.com/pavaner2007/admissioncallagent/blob/main/app/services/intelligence_service.py): conversation orchestration · Produces empathetic responses and safety or booking signals. · `app/services/intelligence_service.py`
- **FFmpeg**: audio runtime dependency

### External Providers

- **Twilio**: telephony provider · Call control and bidirectional media streams.
- **Sarvam AI**: speech provider
- **Groq**: LLM provider
- **SMTP Email**: notification provider
- **Google Forms**: scheduling target · Booking intent is URL or intent driven.

## Connections

- Twilio → Call Handler: webhooks and media stream
- FastAPI Application → Call Handler: mounts routes
- Call Handler → Twilio Service: call control and stream I/O
- Call Handler → Audio Utilities: inbound and outbound audio
- Audio Utilities → Sarvam Service: speech-ready audio
- Audio Utilities → FFmpeg: format conversion
- Sarvam Service → Sarvam AI: STT and TTS requests
- Call Handler → Intelligence Service: transcript and session history
- Intelligence Service → Groq: LLM interaction
- Intelligence Service → Email Service: crisis and summary notifications
- Email Service → SMTP Email: sends email
- Intelligence Service → Google Forms: booking intent
- Twilio Service → Twilio: call and media responses
- Container Deployment → FastAPI Application: runs service
