# sanjay-adtani/ai-healthbot-voice-agent architecture

> Architecture diagram of the GitHub repository sanjay-adtani/ai-healthbot-voice-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sanjay-adtani/ai-healthbot-voice-agent
- Repository: https://github.com/sanjay-adtani/ai-healthbot-voice-agent

## Overview

##### Project type and purpose
- This is a single‐page, voice-enabled frontend application built with React, TypeScript, and Vite.
- It serves as a virtual “General Physician AI” chat interface, using speech‐to‐text (AssemblyAI) and AI responses (Google Gemini) via Vapi.ai.

##### File structure
- Top-level files:
- package.json / package-lock.json → npm dependencies
- vite.config.ts, tsconfig*.json → build & TypeScript config
- index.html → application entry point
- env.example → environment variables for API keys
- public/ → static assets (e.g., favicon, images)
- src/ → application source
- main.tsx → React app bootstrap
- App.tsx / App.css → root component & styles
- components/AiCall.tsx → handles the voice API integration
- assets/ → images/fonts, etc.
- index.css → global styles

##### Extract insights from the README
- Core tech: React + TypeScript + Vite
- External services: Vapi.ai (voice agent), AssemblyAI (STT), Google Gemini (LLM)
- Flow: user speaks → AssemblyAI transcribes → Vapi.ai routes to Google Gemini → response back to user

a. Main components
1. Browser / React SPA
2. Audio‐capture & UI module
3. AssemblyAI Speech-to-Text service
4. Vapi.ai Voice Agent Platform
5. Google Gemini LLM
6. Environment Variable Store (VITE_VAPI_API_KEY, VITE_VAPI_ASSISTANT_ID)
7. Vite Dev/Build Server (for local development)
b. Relationships & data flows
- User speaks into microphone → React Audio Module
- Audio Blob → AssemblyAI API → returns transcript
- Transcript + context → Vapi.ai REST/WebSocket → Vapi routes to Google Gemini
- Google Gemini returns text response → Vapi.ai → React UI
- (Optional) Text response → Browser TTS engine → user hears reply
c. Architectural patterns & design principles
- Single‐Page Application (SPA) pattern
- Separation of concerns: UI vs. external AI services
- Config via environment variables (no secrets in code)
- Lightweight, API‐driven micro‐service integration
d. Key technologies & libraries
- React, TypeScript, Vite (frontend framework & build tool)
- AssemblyAI SDK / REST API (speech‐to‐text)
- Vapi.ai SDK / REST or WebSocket (voice agent orchestration)
- Google Gemini API (LLM responses)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Development Environment Layer
    subgraph "Development Environment"
        direction TB
        Vite["Vite Dev/Build Server"]:::config
    end

    %% Client-Side Application
    subgraph "Client (Browser)"
        direction TB
        User["User"]:::external
        Browser["React SPA"]:::client

        subgraph "SPA Modules"
            direction TB
            Entry["index.html"]:::config
            Main["main.tsx"]:::client
            AppComp["App.tsx"]:::client
            AudioModule["AiCall.tsx"]:::client
            StylesGlobal["index.css"]:::client
            StylesApp["App.css"]:::client
            Assets["Static Assets (public/)"]:::client
        end

        EnvVars["Env Variables Store"]:::config
    end

    %% External AI Services
    subgraph "External AI Services"
        direction TB
        AssemblyAI["AssemblyAI STT"]:::external
        VapiAI["Vapi.ai Voice Agent"]:::external
        Gemini["Google Gemini LLM"]:::external
    end

    %% Data Flows
    User -->|"speaks into mic"| AudioModule
    AudioModule -->|"Audio Blob"| AssemblyAI
    AssemblyAI -->|"Transcript"| AudioModule
    AudioModule -->|"Transcript + context"| VapiAI
    VapiAI -->|"Route to LLM"| Gemini
    Gemini -->|"Response text"| VapiAI
    VapiAI -->|"AI response"| AudioModule
    AudioModule -->|"Render text & TTS"| Browser

    %% Env and Dev Server connections
    Vite --> Browser
    EnvVars --> AudioModule
    EnvVars --> Browser

    %% Click Events
    click Main "https://github.com/sanjay-adtani/ai-healthbot-voice-agent/blob/main/src/main.tsx"
    click AppComp "https://github.com/sanjay-adtani/ai-healthbot-voice-agent/blob/main/src/App.tsx"
    click AudioModule "https://github.com/sanjay-adtani/ai-healthbot-voice-agent/blob/main/src/components/AiCall.tsx"
    click StylesApp "https://github.com/sanjay-adtani/ai-healthbot-voice-agent/blob/main/src/App.css"
    click StylesGlobal "https://github.com/sanjay-adtani/ai-healthbot-voice-agent/blob/main/src/index.css"
    click Assets "https://github.com/sanjay-adtani/ai-healthbot-voice-agent/tree/main/public/"
    click EnvVars "https://github.com/sanjay-adtani/ai-healthbot-voice-agent/blob/main/env.example"
    click Vite "https://github.com/sanjay-adtani/ai-healthbot-voice-agent/blob/main/vite.config.ts"
    click Entry "https://github.com/sanjay-adtani/ai-healthbot-voice-agent/blob/main/index.html"
    click Vite "https://github.com/sanjay-adtani/ai-healthbot-voice-agent/blob/main/tsconfig.app.json"
    click Vite "https://github.com/sanjay-adtani/ai-healthbot-voice-agent/blob/main/tsconfig.json"
    click Vite "https://github.com/sanjay-adtani/ai-healthbot-voice-agent/blob/main/tsconfig.node.json"
    click Vite "https://github.com/sanjay-adtani/ai-healthbot-voice-agent/blob/main/package.json"
    click Vite "https://github.com/sanjay-adtani/ai-healthbot-voice-agent/blob/main/package-lock.json"

    %% Styles
    classDef client fill:#E3F2FD,stroke:#90CAF9,stroke-width:1px;
    classDef external fill:#E8F5E9,stroke:#66BB6A,stroke-width:1px;
    classDef config fill:#EEEEEE,stroke:#BDBDBD,stroke-width:1px;
```
