# shivshaktisahoo/ai-medical-chatbot architecture

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

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

## Overview

AI Medical Chatbot is a browser-based multimodal health-guidance assistant. A user enters through the landing page, opens chat, selects a doctor voice, and submits text, a recording, and optionally an image. The backend transcribes audio, generates grounded guidance with provider fallbacks, synthesizes speech, and returns text, audio, and any degradation notice for display and playback. The map includes the documented landing, theme, doctor-selection, and rate-limiting capabilities. Backend call details are supported by excerpts; browser-to-API and provider relationships also use README documentation.

Main entry points: [`backend/app/routers/consult.py`](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/routers/consult.py) (Consult endpoint), [`frontend/src/pages/Chat.tsx`](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/pages/Chat.tsx) (Chat page), [`frontend/src/components/ChatPanel.tsx`](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/components/ChatPanel.tsx) (Chat panel), [`frontend/src/pages/Landing.tsx`](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/pages/Landing.tsx) (Landing page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser experience"]
  node_app_routes["App routes<br/>[App.tsx]"]
  node_landing["Landing page<br/>[Landing.tsx]"]
  node_github_mark["GitHub mark<br/>[GithubMark.tsx]"]
  node_chat_page["Chat page<br/>[Chat.tsx]"]
  node_theme["Theme state<br/>[useTheme.ts]"]
end

subgraph group_interaction["Chat interaction"]
  node_doctor_voice["Doctor voice choice<br/>[useDoctorVoice.ts]"]
  node_doctor_art["Doctor illustration"]
  node_chat_panel["Chat panel<br/>[ChatPanel.tsx]"]
  node_composer["Message composer<br/>[Composer.tsx]"]
  node_audio_recorder["Audio recorder"]
  node_api_client["API client<br/>[api.ts]"]
  node_message_bubble["Message bubble<br/>[MessageBubble.tsx]"]
  node_audio_player["Audio player<br/>[AudioPlayer.tsx]"]
end

subgraph group_api["Consult API"]
  node_consult_api["Consult endpoint<br/>[consult.py]"]
  node_schemas["Response schemas<br/>[schemas.py]"]
  node_api_app["FastAPI app<br/>[main.py]"]
end

subgraph group_services["AI and speech"]
  node_stt["Speech transcription<br/>[stt.py]"]
  node_llm["Guidance and vision<br/>[llm.py]"]
  node_tts["Speech synthesis<br/>[tts.py]"]
  node_local_fallback["Local responder<br/>[llm.py]"]
end

subgraph group_safeguards["Configuration and safeguards"]
  node_config["Provider settings<br/>[config.py]"]
  node_rate_limit["IP rate limit<br/>[ratelimit.py]"]
end

node_visitor(("Visitor"))
node_groq["Groq services"]
node_openrouter["OpenRouter"]
node_speech_providers["Speech providers"]

node_visitor -->|"opens"| node_landing
node_app_routes -->|"routes to"| node_landing
node_app_routes -->|"routes to"| node_chat_page
node_landing -->|"starts consultation"| node_chat_page
node_chat_page -->|"returns home"| node_landing
node_landing -->|"renders"| node_github_mark
node_chat_page -->|"uses"| node_theme
node_chat_page -->|"selects voice"| node_doctor_voice
node_chat_page -->|"renders"| node_doctor_art
node_chat_page -->|"renders"| node_chat_panel
node_chat_panel -->|"renders"| node_composer
node_composer -->|"records audio"| node_audio_recorder
node_chat_panel -->|"submits turn"| node_api_client
node_api_client -->|"posts multipart turn"| node_consult_api
node_consult_api -->|"applies limit"| node_rate_limit
node_consult_api -->|"transcribes audio"| node_stt
node_consult_api -->|"generates reply"| node_llm
node_consult_api -->|"synthesizes reply"| node_tts
node_consult_api -->|"returns schema"| node_schemas
node_stt -->|"transcribes with"| node_groq
node_llm -->|"tries first"| node_groq
node_llm -->|"falls back to"| node_openrouter
node_llm -->|"falls back to"| node_local_fallback
node_tts -->|"synthesizes with fallbacks"| node_speech_providers
node_api_app -->|"registers router"| node_consult_api
node_api_app -->|"configures CORS"| node_config
node_api_app -->|"installs middleware"| node_rate_limit
node_consult_api -->|"reads settings"| node_config
node_chat_panel -->|"renders messages"| node_message_bubble
node_message_bubble -->|"renders playback"| node_audio_player
node_message_bubble -->|"renders avatar"| node_doctor_art
node_chat_panel -->|"uses voice choice"| node_doctor_voice
node_doctor_art -->|"uses gender type"| node_doctor_voice
node_chat_panel -->|"receives response"| node_consult_api

click node_app_routes "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/App.tsx"
click node_landing "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/pages/Landing.tsx"
click node_github_mark "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/components/GithubMark.tsx"
click node_chat_page "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/pages/Chat.tsx"
click node_theme "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/hooks/useTheme.ts"
click node_doctor_voice "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/hooks/useDoctorVoice.ts"
click node_doctor_art "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/components/DoctorIllustration.tsx"
click node_chat_panel "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/components/ChatPanel.tsx"
click node_composer "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/components/Composer.tsx"
click node_audio_recorder "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/hooks/useAudioRecorder.ts"
click node_api_client "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/lib/api.ts"
click node_message_bubble "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/components/MessageBubble.tsx"
click node_audio_player "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/components/AudioPlayer.tsx"
click node_consult_api "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/routers/consult.py"
click node_schemas "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/schemas.py"
click node_stt "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/services/stt.py"
click node_llm "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/services/llm.py"
click node_tts "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/services/tts.py"
click node_local_fallback "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/services/llm.py"
click node_config "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/config.py"
click node_rate_limit "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/ratelimit.py"
click node_api_app "https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/main.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_app_routes,node_landing,node_github_mark,node_chat_page,node_theme toneBlue
class node_doctor_voice,node_doctor_art,node_chat_panel,node_composer,node_audio_recorder,node_api_client,node_message_bubble,node_audio_player toneAmber
class node_consult_api,node_schemas,node_api_app,node_openrouter toneMint
class node_stt,node_llm,node_tts,node_local_fallback toneRose
class node_config,node_rate_limit,node_visitor,node_groq,node_speech_providers toneIndigo
```

## Components

### Browser experience

- [App routes](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Landing page](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/pages/Landing.tsx): `frontend/src/pages/Landing.tsx`
- [GitHub mark](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/components/GithubMark.tsx): `frontend/src/components/GithubMark.tsx`
- [Chat page](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/pages/Chat.tsx): `frontend/src/pages/Chat.tsx`
- [Theme state](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/hooks/useTheme.ts): `frontend/src/hooks/useTheme.ts`

### Chat interaction

- [Doctor voice choice](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/hooks/useDoctorVoice.ts): `frontend/src/hooks/useDoctorVoice.ts`
- [Doctor illustration](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/components/DoctorIllustration.tsx): `frontend/src/components/DoctorIllustration.tsx`
- [Chat panel](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/components/ChatPanel.tsx): `frontend/src/components/ChatPanel.tsx`
- [Message composer](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/components/Composer.tsx): `frontend/src/components/Composer.tsx`
- [Audio recorder](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/hooks/useAudioRecorder.ts): `frontend/src/hooks/useAudioRecorder.ts`
- [API client](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [Message bubble](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/components/MessageBubble.tsx): `frontend/src/components/MessageBubble.tsx`
- [Audio player](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/frontend/src/components/AudioPlayer.tsx): `frontend/src/components/AudioPlayer.tsx`

### Consult API

- [Consult endpoint](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/routers/consult.py): `backend/app/routers/consult.py`
- [Response schemas](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/schemas.py): `backend/app/schemas.py`
- [FastAPI app](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/main.py): `backend/app/main.py`

### AI and speech

- [Speech transcription](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/services/stt.py): `backend/app/services/stt.py`
- [Guidance and vision](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/services/llm.py): `backend/app/services/llm.py`
- [Speech synthesis](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/services/tts.py): `backend/app/services/tts.py`
- [Local responder](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/services/llm.py): `backend/app/services/llm.py`

### Configuration and safeguards

- [Provider settings](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/config.py): `backend/app/config.py`
- [IP rate limit](https://github.com/shivshaktisahoo/ai-medical-chatbot/blob/master/backend/app/ratelimit.py): `backend/app/ratelimit.py`

### Other components

- **Visitor**
- **Groq services**
- **OpenRouter**
- **Speech providers**

## Connections

- Visitor → Landing page: opens (evidence: `README.md`)
- App routes → Landing page: routes to (evidence: `frontend/src/App.tsx`)
- App routes → Chat page: routes to (evidence: `frontend/src/App.tsx`)
- Landing page → Chat page: starts consultation (evidence: `README.md`)
- Chat page → Landing page: returns home (evidence: `README.md`)
- Landing page → GitHub mark: renders (evidence: `frontend/src/pages/Landing.tsx`)
- Chat page → Theme state: uses (evidence: `frontend/src/pages/Chat.tsx`)
- Chat page → Doctor voice choice: selects voice (evidence: `frontend/src/pages/Chat.tsx`)
- Chat page → Doctor illustration: renders (evidence: `frontend/src/pages/Chat.tsx`)
- Chat page → Chat panel: renders (evidence: `frontend/src/pages/Chat.tsx`)
- Chat panel → Message composer: renders (evidence: `frontend/src/components/ChatPanel.tsx`)
- Message composer → Audio recorder: records audio (evidence: `frontend/src/components/Composer.tsx`)
- Chat panel → API client: submits turn (evidence: `frontend/src/components/ChatPanel.tsx`)
- API client → Consult endpoint: posts multipart turn (evidence: `README.md`)
- Consult endpoint → IP rate limit: applies limit (evidence: `backend/app/routers/consult.py`)
- Consult endpoint → Speech transcription: transcribes audio (evidence: `backend/app/routers/consult.py`)
- Consult endpoint → Guidance and vision: generates reply (evidence: `backend/app/routers/consult.py`)
- Consult endpoint → Speech synthesis: synthesizes reply (evidence: `backend/app/routers/consult.py`)
- Consult endpoint → Response schemas: returns schema (evidence: `backend/app/routers/consult.py`)
- Speech transcription → Groq services: transcribes with (evidence: `README.md`)
- Guidance and vision → Groq services: tries first (evidence: `backend/app/services/llm.py`)
- Guidance and vision → OpenRouter: falls back to (evidence: `backend/app/services/llm.py`)
- Guidance and vision → Local responder: falls back to (evidence: `backend/app/services/llm.py`)
- Speech synthesis → Speech providers: synthesizes with fallbacks (evidence: `README.md`)
- FastAPI app → Consult endpoint: registers router (evidence: `backend/app/main.py`)
- FastAPI app → Provider settings: configures CORS (evidence: `backend/app/main.py`)
- FastAPI app → IP rate limit: installs middleware (evidence: `backend/app/main.py`)
- Consult endpoint → Provider settings: reads settings (evidence: `backend/app/routers/consult.py`)
- Chat panel → Message bubble: renders messages (evidence: `frontend/src/components/ChatPanel.tsx`)
- Message bubble → Audio player: renders playback (evidence: `frontend/src/components/MessageBubble.tsx`)
- Message bubble → Doctor illustration: renders avatar (evidence: `frontend/src/components/MessageBubble.tsx`)
- Chat panel → Doctor voice choice: uses voice choice (evidence: `frontend/src/components/ChatPanel.tsx`)
- Doctor illustration → Doctor voice choice: uses gender type (evidence: `frontend/src/components/DoctorIllustration.tsx`)
- Chat panel → Consult endpoint: receives response (evidence: `README.md`)
