# utkarsh-chauhannn/voice-assistant-doctor architecture

> Architecture diagram of the GitHub repository utkarsh-chauhannn/voice-assistant-doctor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/utkarsh-chauhannn/voice-assistant-doctor
- Repository: https://github.com/utkarsh-chauhannn/voice-assistant-doctor

## Overview

##### Project type and purpose
- This is a Python-based, full-stack, voice-enabled “AI Doctor” assistant. It uses Gradio as the user interface, custom Python modules for speech-to-text (STT), an LLM-based “brain” for generating responses, and text-to-speech (TTS) engines to speak back to the user. It is containerized with Docker.

##### File structure
- Top-level files:
- `gradio_app.py` – entry point for the Gradio UI (frontend)
- `brain_of_the_doctor.py` – core logic invoking the LLM
- `voice_of_the_patient.py` – speech recognition / STT wrapper
- `voice_of_the_doctor.py` – TTS wrapper (ElevenLabs, gTTS)
- `requirements.txt` / `Pipfile` – dependency specs
- `Dockerfile` – container orchestration
- `.gradio/` directory holds session data, flagged inputs, and uploaded media.
- Assets: several `.mp3` test files show usage of ElevenLabs and gTTS.

##### README
- Title “Voice-Assistant-Doctor” / “AI-Doctor” confirms the purpose: a conversational doctor assistant that takes voice input, reasons with AI, and answers with a synthesized voice.

##### Main components and interactions (to include
a. Frontend (Gradio UI)
– gradio_app.py serves a web interface where patients “Speak Your Symptoms” or upload an image/audio.
b. Audio Ingestion & STT
– voice_of_the_patient.py listens to uploaded or live audio, calls a speech-to-text engine (e.g., OpenAI Whisper or a third-party API), produces a text transcript.
c. AI Brain
– brain_of_the_doctor.py receives the transcript, formats a prompt, calls the OpenAI (or similar) API, and gets a text response.
d. TTS
– voice_of_the_doctor.py feeds the text response to ElevenLabs or Google TTS, producing an audio file.
e. Data Storage & Logging
– .gradio/ holds session files, flagged content, and CSV logs (`dataset1.csv`, `dataset2.csv`).
f. External Services
– OpenAI API (LLM calls)
– ElevenLabs / gTTS APIs (TTS)
g. Deployment
– Docker container built from Dockerfile, running all modules in a single service.

##### Architectural patterns & design principles
- Pipeline pattern: clear separation of STT → NLP → TTS.
- Modular design: each concern lives in its own Python module.
- Stateless UI: Gradio serves requests, all state logged to disk.
- External-service integration: LLM and TTS engines are treated as downstream services.

##### Detail is key
- Every Python script as its own component.
- `.gradio/` as a persistent storage block.
- Configuration files (Pipfile, requirements.txt, Dockerfile) in a “Deployment & Config” section.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Layer
    UserBrowser["User Browser"]:::external

    %% Docker Container Boundary
    subgraph "Docker Container"
        direction TB
        gradio_app["Gradio UI (gradio_app.py)"]:::ui
        voice_of_patient["STT Service (voice_of_the_patient.py)"]:::business
        brain["AI Brain (brain_of_the_doctor.py)"]:::business
        voice_of_doctor["TTS Service (voice_of_the_doctor.py)"]:::business

        subgraph "Storage (Session & Logs)"
            gradio_storage[".gradio/"]:::storage
        end

        subgraph "Deployment & Config"
            dockerfile["Dockerfile"]:::config
            requirements["requirements.txt"]:::config
            pipfile["Pipfile"]:::config
        end
    end

    %% External Services
    OpenAI["OpenAI API (LLM)"]:::external
    TTSapi["ElevenLabs / gTTS APIs"]:::external

    %% Data Flow
    UserBrowser -->|"Speak or Upload"| gradio_app
    gradio_app -->|"Audio Input"| voice_of_patient
    voice_of_patient -->|"Transcript"| brain
    brain -->|"Response Text"| voice_of_doctor
    voice_of_doctor -->|"Audio Output"| gradio_app

    %% Storage Logging
    gradio_app --> gradio_storage
    voice_of_patient --> gradio_storage
    brain --> gradio_storage
    voice_of_doctor --> gradio_storage

    %% External Integrations
    voice_of_patient -->|"STT Call"| OpenAI
    brain -->|"LLM Call"| OpenAI
    voice_of_doctor -->|"TTS Call"| TTSapi

    %% Deployment Links
    dockerfile -.->|builds| gradio_app
    dockerfile -.->|builds| voice_of_patient
    dockerfile -.->|builds| brain
    dockerfile -.->|builds| voice_of_doctor
    requirements -.->|deps| gradio_app
    pipfile -.->|deps| gradio_app

    %% Click Events
    click gradio_app "https://github.com/utkarsh-chauhannn/voice-assistant-doctor/blob/main/gradio_app.py"
    click voice_of_patient "https://github.com/utkarsh-chauhannn/voice-assistant-doctor/blob/main/voice_of_the_patient.py"
    click brain "https://github.com/utkarsh-chauhannn/voice-assistant-doctor/blob/main/brain_of_the_doctor.py"
    click voice_of_doctor "https://github.com/utkarsh-chauhannn/voice-assistant-doctor/blob/main/voice_of_the_doctor.py"
    click gradio_storage "https://github.com/utkarsh-chauhannn/voice-assistant-doctor/tree/main/.gradio/"
    click dockerfile "https://github.com/utkarsh-chauhannn/voice-assistant-doctor/tree/main/Dockerfile"
    click requirements "https://github.com/utkarsh-chauhannn/voice-assistant-doctor/blob/main/requirements.txt"
    click pipfile "https://github.com/utkarsh-chauhannn/voice-assistant-doctor/tree/main/Pipfile"

    %% Styles
    classDef ui fill:#AEDFF7,stroke:#0288D1,color:#000
    classDef business fill:#D0F0C0,stroke:#228B22,color:#000
    classDef external fill:#FFF7AA,stroke:#DAA520,color:#000
    classDef storage fill:#E0E0E0,stroke:#A9A9A9,color:#000
    classDef config fill:#FFD1DC,stroke:#C71585,color:#000
```
