# sahil123goyal/medical_chatbot-vision-voice- architecture

> Architecture diagram of the GitHub repository sahil123goyal/medical_chatbot-vision-voice-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sahil123goyal/medical_chatbot-vision-voice-
- Repository: https://github.com/sahil123goyal/medical_chatbot-vision-voice-

## Overview

This is a medical-education chatbot with text, image, and voice input. A user submits a question through the browser; the API optionally obtains an image observation, invokes the conversational agent, and returns an answer with PDF or web sources. The agent rewrites the query, retrieves book passages, decides whether current web results are needed, and generates a safety-guided response. Separate browser controls and API endpoints support speech transcription and playback. The excerpts show the main runtime wiring; the README provides no additional capability detail.

Main entry points: [`app/main.py`](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/main.py) (FastAPI endpoints), [`app/knowledge.py`](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/knowledge.py) (Vector knowledge index), [`static/app.js`](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/static/app.js) (Chat interface), [`app/agent.py`](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/agent.py) (Safe answer generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Browser interface"]
  node_browser["Chat interface<br/>[app.js]"]
  node_page["Chat page<br/>[index.html]"]
end

subgraph group_api["API and media"]
  node_api_server["FastAPI endpoints<br/>[main.py]"]
  node_vision["Image observation<br/>[main.py]"]
  node_speech_in["Speech transcription<br/>[main.py]"]
  node_speech_out["Speech synthesis<br/>[main.py]"]
  node_settings["Runtime settings<br/>[config.py]"]
end

subgraph group_agent["Conversation agent"]
  node_rewrite["Query rewrite<br/>[agent.py]"]
  node_retrieve["Passage retrieval<br/>[agent.py]"]
  node_route["Source routing<br/>[agent.py]"]
  node_web_search["Web search<br/>[agent.py]"]
  node_answer["Safe answer generation<br/>[agent.py]"]
end

subgraph group_knowledge["Knowledge and memory"]
  node_ingestion["PDF ingestion<br/>[ingest.py]"]
  node_pdf["Medical reference PDF<br/>[Medical_book.pdf]"]
  node_knowledge_store[("Vector knowledge index<br/>[knowledge.py]")]
  node_conversation_memory[("Conversation checkpoint<br/>[agent.py]")]
end

node_user(("User"))
node_groq["Groq AI services"]
node_pinecone[("Pinecone")]
node_tavily["Tavily search"]
node_embedding_model["Sentence-transformers"]

node_user -->|"asks questions"| node_browser
node_browser -->|"sends chat"| node_api_server
node_api_server -->|"returns answer"| node_browser
node_api_server -->|"serves page"| node_page
node_browser -->|"requests transcription"| node_api_server
node_api_server -->|"handles audio"| node_speech_in
node_speech_in -->|"transcribes audio"| node_groq
node_browser -->|"requests playback"| node_api_server
node_api_server -->|"handles speech"| node_speech_out
node_speech_out -->|"synthesizes speech"| node_groq
node_api_server -->|"inspects image"| node_vision
node_vision -->|"describes image"| node_groq
node_api_server -->|"invokes agent"| node_rewrite
node_rewrite -->|"passes query"| node_retrieve
node_retrieve -->|"searches passages"| node_knowledge_store
node_retrieve -->|"passes results"| node_route
node_route -->|"dispatches if needed"| node_web_search
node_route -->|"dispatches directly"| node_answer
node_web_search -->|"searches web"| node_tavily
node_web_search -->|"passes results"| node_answer
node_answer -->|"generates response"| node_groq
node_answer -->|"checkpoints conversation"| node_conversation_memory
node_ingestion -->|"extracts pages"| node_pdf
node_ingestion -->|"upserts vectors"| node_knowledge_store
node_knowledge_store -->|"queries and stores"| node_pinecone
node_knowledge_store -->|"embeds query"| node_embedding_model
node_ingestion -->|"requests embeddings"| node_knowledge_store
node_api_server -->|"reads configuration"| node_settings
node_rewrite -->|"reads model settings"| node_settings
node_knowledge_store -->|"reads index settings"| node_settings

click node_browser "https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/static/app.js"
click node_page "https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/templates/index.html"
click node_api_server "https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/main.py"
click node_vision "https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/main.py"
click node_speech_in "https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/main.py"
click node_speech_out "https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/main.py"
click node_settings "https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/config.py"
click node_rewrite "https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/agent.py"
click node_retrieve "https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/agent.py"
click node_route "https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/agent.py"
click node_web_search "https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/agent.py"
click node_answer "https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/agent.py"
click node_ingestion "https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/ingest.py"
click node_pdf "https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/data/Medical_book.pdf"
click node_knowledge_store "https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/knowledge.py"
click node_conversation_memory "https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/agent.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_browser,node_page,node_user toneBlue
class node_api_server,node_vision,node_speech_in,node_speech_out,node_settings,node_pinecone toneAmber
class node_rewrite,node_retrieve,node_route,node_web_search,node_answer toneMint
class node_ingestion,node_pdf,node_knowledge_store,node_conversation_memory toneRose
class node_groq,node_tavily,node_embedding_model toneIndigo
```

## Components

### Browser interface

- [Chat interface](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/static/app.js): `static/app.js`
- [Chat page](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/templates/index.html): `templates/index.html`

### API and media

- [FastAPI endpoints](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/main.py): `app/main.py`
- [Image observation](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/main.py): `app/main.py`
- [Speech transcription](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/main.py): `app/main.py`
- [Speech synthesis](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/main.py): `app/main.py`
- [Runtime settings](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/config.py): `app/config.py`

### Conversation agent

- [Query rewrite](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/agent.py): `app/agent.py`
- [Passage retrieval](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/agent.py): `app/agent.py`
- [Source routing](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/agent.py): `app/agent.py`
- [Web search](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/agent.py): `app/agent.py`
- [Safe answer generation](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/agent.py): `app/agent.py`

### Knowledge and memory

- [PDF ingestion](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/ingest.py): `ingest.py`
- [Medical reference PDF](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/data/Medical_book.pdf): `data/Medical_book.pdf`
- [Vector knowledge index](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/knowledge.py): `app/knowledge.py`
- [Conversation checkpoint](https://github.com/sahil123goyal/medical_chatbot-vision-voice-/blob/main/app/agent.py): `app/agent.py`

### Other components

- **User**
- **Groq AI services**
- **Pinecone**
- **Tavily search**
- **Sentence-transformers**

## Connections

- User → Chat interface: asks questions (evidence: `static/app.js`)
- Chat interface → FastAPI endpoints: sends chat (evidence: `static/app.js`)
- FastAPI endpoints → Chat interface: returns answer (evidence: `static/app.js`)
- FastAPI endpoints → Chat page: serves page (evidence: `app/main.py`)
- Chat interface → FastAPI endpoints: requests transcription (evidence: `static/app.js`)
- FastAPI endpoints → Speech transcription: handles audio (evidence: `app/main.py`)
- Speech transcription → Groq AI services: transcribes audio (evidence: `app/main.py`)
- Chat interface → FastAPI endpoints: requests playback (evidence: `static/app.js`)
- FastAPI endpoints → Speech synthesis: handles speech (evidence: `app/main.py`)
- Speech synthesis → Groq AI services: synthesizes speech (evidence: `app/main.py`)
- FastAPI endpoints → Image observation: inspects image (evidence: `app/main.py`)
- Image observation → Groq AI services: describes image (evidence: `app/main.py`)
- FastAPI endpoints → Query rewrite: invokes agent (evidence: `app/main.py`)
- Query rewrite → Passage retrieval: passes query (evidence: `app/agent.py`)
- Passage retrieval → Vector knowledge index: searches passages (evidence: `app/agent.py`)
- Passage retrieval → Source routing: passes results (evidence: `app/agent.py`)
- Source routing → Web search: dispatches if needed (evidence: `app/agent.py`)
- Source routing → Safe answer generation: dispatches directly (evidence: `app/agent.py`)
- Web search → Tavily search: searches web (evidence: `app/agent.py`)
- Web search → Safe answer generation: passes results (evidence: `app/agent.py`)
- Safe answer generation → Groq AI services: generates response (evidence: `app/agent.py`)
- Safe answer generation → Conversation checkpoint: checkpoints conversation (evidence: `app/agent.py`)
- PDF ingestion → Medical reference PDF: extracts pages (evidence: `ingest.py`)
- PDF ingestion → Vector knowledge index: upserts vectors (evidence: `ingest.py`)
- Vector knowledge index → Pinecone: queries and stores (evidence: `app/knowledge.py`)
- Vector knowledge index → Sentence-transformers: embeds query (evidence: `app/knowledge.py`)
- PDF ingestion → Vector knowledge index: requests embeddings (evidence: `ingest.py`)
- FastAPI endpoints → Runtime settings: reads configuration (evidence: `app/main.py`)
- Query rewrite → Runtime settings: reads model settings (evidence: `app/agent.py`)
- Vector knowledge index → Runtime settings: reads index settings (evidence: `app/knowledge.py`)
