# chaitanya-rajendra/ai-medical-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/chaitanya-rajendra/ai-medical-chatbot
- Repository: https://github.com/chaitanya-rajendra/ai-medical-chatbot

## Overview

This is a Gradio medical-image consultation app with voice input and spoken output. The user submits a question and image; the app transcribes the audio, encodes and analyzes the image with the question, then generates speech from the response and returns text and audio. The README documents Groq speech-to-text, AI image analysis, and ElevenLabs or gTTS speech output. The excerpts show the app’s orchestration and provider calls; no separate storage layer is evident.

Main entry points: [`gradio_app.py`](https://github.com/chaitanya-rajendra/ai-medical-chatbot/blob/main/gradio_app.py) (Gradio app), [`brain_of_the_doctor.py`](https://github.com/chaitanya-rajendra/ai-medical-chatbot/blob/main/brain_of_the_doctor.py) (Image analysis), [`voice_of_the_patient.py`](https://github.com/chaitanya-rajendra/ai-medical-chatbot/blob/main/voice_of_the_patient.py) (Speech transcription), [`voice_of_the_doctor.py`](https://github.com/chaitanya-rajendra/ai-medical-chatbot/blob/main/voice_of_the_doctor.py) (gTTS synthesis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Consultation interface"]
  node_gradio["Gradio app<br/>[gradio_app.py]"]
end

subgraph group_analysis["Consultation processing"]
  node_image_encoding["Image encoding"]
  node_image_analysis["Image analysis"]
end

subgraph group_voice["Voice services"]
  node_transcription["Speech transcription"]
  node_gtts["gTTS synthesis"]
  node_elevenlabs["ElevenLabs synthesis"]
end

node_patient(("Patient"))
node_groq_stt{{"Groq STT"}}
node_groq_vision{{"Groq vision model"}}
node_groq_api{{"Groq API"}}
node_elevenlabs_service{{"ElevenLabs API"}}
node_gtts_service{{"gTTS service"}}

node_patient -->|"submits inputs"| node_gradio
node_gradio -->|"transcribes audio"| node_transcription
node_transcription -->|"requests transcription"| node_groq_api
node_gradio -->|"encodes image"| node_image_encoding
node_gradio -->|"requests analysis"| node_image_analysis
node_image_analysis -->|"requests vision analysis"| node_groq_vision
node_gradio -->|"generates speech"| node_elevenlabs
node_gradio -->|"fallback speech"| node_gtts
node_elevenlabs -->|"synthesizes speech"| node_elevenlabs_service
node_gtts -->|"synthesizes speech"| node_gtts_service

click node_gradio "https://github.com/chaitanya-rajendra/ai-medical-chatbot/blob/main/gradio_app.py"
click node_transcription "https://github.com/chaitanya-rajendra/ai-medical-chatbot/blob/main/voice_of_the_patient.py"
click node_image_encoding "https://github.com/chaitanya-rajendra/ai-medical-chatbot/blob/main/brain_of_the_doctor.py"
click node_image_analysis "https://github.com/chaitanya-rajendra/ai-medical-chatbot/blob/main/brain_of_the_doctor.py"
click node_gtts "https://github.com/chaitanya-rajendra/ai-medical-chatbot/blob/main/voice_of_the_doctor.py"
click node_elevenlabs "https://github.com/chaitanya-rajendra/ai-medical-chatbot/blob/main/voice_of_the_doctor.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_gradio toneBlue
class node_image_encoding,node_image_analysis toneAmber
class node_transcription,node_gtts,node_elevenlabs,node_groq_api,node_elevenlabs_service toneMint
class node_patient,node_groq_stt,node_groq_vision,node_gtts_service toneIndigo
```

## Components

### Consultation interface

- [Gradio app](https://github.com/chaitanya-rajendra/ai-medical-chatbot/blob/main/gradio_app.py): `gradio_app.py`

### Consultation processing

- [Image encoding](https://github.com/chaitanya-rajendra/ai-medical-chatbot/blob/main/brain_of_the_doctor.py): `brain_of_the_doctor.py`
- [Image analysis](https://github.com/chaitanya-rajendra/ai-medical-chatbot/blob/main/brain_of_the_doctor.py): `brain_of_the_doctor.py`

### Voice services

- [Speech transcription](https://github.com/chaitanya-rajendra/ai-medical-chatbot/blob/main/voice_of_the_patient.py): `voice_of_the_patient.py`
- [gTTS synthesis](https://github.com/chaitanya-rajendra/ai-medical-chatbot/blob/main/voice_of_the_doctor.py): `voice_of_the_doctor.py`
- [ElevenLabs synthesis](https://github.com/chaitanya-rajendra/ai-medical-chatbot/blob/main/voice_of_the_doctor.py): `voice_of_the_doctor.py`

### Other components

- **Patient**
- **Groq STT**
- **Groq vision model**
- **Groq API**
- **ElevenLabs API**
- **gTTS service**

## Connections

- Patient → Gradio app: submits inputs (evidence: `README.md`)
- Gradio app → Speech transcription: transcribes audio (evidence: `gradio_app.py`)
- Speech transcription → Groq API: requests transcription (evidence: `voice_of_the_patient.py`)
- Gradio app → Image encoding: encodes image (evidence: `gradio_app.py`)
- Gradio app → Image analysis: requests analysis (evidence: `gradio_app.py`)
- Image analysis → Groq vision model: requests vision analysis (evidence: `brain_of_the_doctor.py`)
- Gradio app → ElevenLabs synthesis: generates speech (evidence: `gradio_app.py`)
- Gradio app → gTTS synthesis: fallback speech (evidence: `gradio_app.py`)
- ElevenLabs synthesis → ElevenLabs API: synthesizes speech (evidence: `voice_of_the_doctor.py`)
- gTTS synthesis → gTTS service: synthesizes speech (evidence: `voice_of_the_doctor.py`)
