# harsha33983/medical-bot- architecture

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

- Interactive diagram: https://gitdiagram.com/harsha33983/medical-bot-
- Repository: https://github.com/harsha33983/medical-bot-

## Overview

This is a full-stack symptom-prediction chatbot: users register or sign in, enter symptoms by text or voice, and receive condition predictions, descriptions, precautions, and a severity-based response. The React chatbot calls FastAPI through a shared API client; the backend authenticates protected predictions, matches symptoms to its loaded model feature list, and returns results from two classifiers plus reference data. It also generates speech audio for playback. The graph reflects the README and sampled source; some chatbot steps and data wiring are documented but not fully visible in the excerpts.

Main entry points: [`backend/app.py`](https://github.com/harsha33983/medical-bot-/blob/main/backend/app.py) (API handlers), [`frontend/src/pages/Chatbot.jsx`](https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/pages/Chatbot.jsx) (Consultation chat), [`frontend/src/App.jsx`](https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/App.jsx) (Route shell), [`frontend/src/services/api.js`](https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/services/api.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_app["Route shell<br/>[App.jsx]"]
  node_home["Home page<br/>[Home.jsx]"]
  node_login["Sign in<br/>[Login.jsx]"]
  node_register["Registration<br/>[Register.jsx]"]
  node_chat["Consultation chat<br/>[Chatbot.jsx]"]
  node_client["API client<br/>[api.js]"]
  node_voice["Speech recognition<br/>[Chatbot.jsx]"]
end

subgraph group_api["Backend API"]
  node_fastapi["API handlers<br/>[app.py]"]
  node_auth["Token auth<br/>[auth.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
  node_tts["Speech synthesis<br/>[app.py]"]
  node_audio["Generated audio"]
end

subgraph group_clinical["Prediction data"]
  node_symptoms["Symptom vocabulary"]
  node_classifiers["SVC and tree"]
  node_severity["Severity weights"]
  node_descriptions["Condition descriptions"]
  node_precautions["Precaution guidance"]
end

subgraph group_persistence["Identity and state"]
  node_dbsession["DB session<br/>[db.py]"]
  node_dbmodels["User model<br/>[db_models.py]"]
  node_sqlite[("User database<br/>[medical_chatbot.db]")]
end

node_user(("User"))
node_browser(("Browser speech"))
node_speech_engine(("pyttsx3"))

node_user -->|"opens"| node_home
node_user -->|"signs in"| node_login
node_user -->|"registers"| node_register
node_user -->|"enters symptoms"| node_chat
node_app -->|"routes"| node_home
node_app -->|"routes"| node_login
node_app -->|"routes"| node_register
node_app -->|"routes"| node_chat
node_login -->|"sends credentials"| node_client
node_register -->|"sends credentials"| node_client
node_chat -->|"requests symptoms"| node_client
node_client -->|"HTTP API"| node_fastapi
node_fastapi -->|"validates"| node_schemas
node_fastapi -->|"authenticates"| node_auth
node_fastapi -->|"opens session"| node_dbsession
node_fastapi -->|"queries users"| node_dbmodels
node_dbsession -->|"connects"| node_sqlite
node_dbmodels -->|"reads and writes"| node_sqlite
node_fastapi -->|"loads vocabulary"| node_symptoms
node_fastapi -->|"loads models"| node_classifiers
node_fastapi -->|"loads weights"| node_severity
node_fastapi -->|"loads descriptions"| node_descriptions
node_fastapi -->|"loads precautions"| node_precautions
node_fastapi -->|"predicts with"| node_classifiers
node_fastapi -->|"matches symptoms"| node_severity
node_fastapi -->|"looks up condition"| node_descriptions
node_fastapi -->|"looks up guidance"| node_precautions
node_fastapi -->|"dispatches speech"| node_tts
node_tts -->|"synthesizes"| node_speech_engine
node_tts -->|"writes WAV"| node_audio
node_chat -.->|"starts recognition"| node_voice
node_browser -.->|"provides speech API"| node_voice
node_voice -.->|"returns transcript"| node_chat

click node_app "https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/App.jsx"
click node_home "https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/pages/Home.jsx"
click node_login "https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/pages/Login.jsx"
click node_register "https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/pages/Register.jsx"
click node_chat "https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/pages/Chatbot.jsx"
click node_client "https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/services/api.js"
click node_fastapi "https://github.com/harsha33983/medical-bot-/blob/main/backend/app.py"
click node_auth "https://github.com/harsha33983/medical-bot-/blob/main/backend/auth.py"
click node_schemas "https://github.com/harsha33983/medical-bot-/blob/main/backend/schemas.py"
click node_dbsession "https://github.com/harsha33983/medical-bot-/blob/main/backend/db.py"
click node_dbmodels "https://github.com/harsha33983/medical-bot-/blob/main/backend/db_models.py"
click node_sqlite "https://github.com/harsha33983/medical-bot-/blob/main/backend/medical_chatbot.db"
click node_symptoms "https://github.com/harsha33983/medical-bot-/blob/main/backend/data/list_of_symptoms.pickle"
click node_classifiers "https://github.com/harsha33983/medical-bot-/tree/main/backend/models"
click node_severity "https://github.com/harsha33983/medical-bot-/blob/main/backend/data/Symptom-severity.csv"
click node_descriptions "https://github.com/harsha33983/medical-bot-/blob/main/backend/data/symptom_Description.csv"
click node_precautions "https://github.com/harsha33983/medical-bot-/blob/main/backend/data/symptom_precaution.csv"
click node_tts "https://github.com/harsha33983/medical-bot-/blob/main/backend/app.py"
click node_audio "https://github.com/harsha33983/medical-bot-/tree/main/backend/static"
click node_voice "https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/pages/Chatbot.jsx"

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,node_home,node_login,node_register,node_chat,node_client,node_voice,node_user,node_browser toneBlue
class node_fastapi,node_auth,node_schemas,node_tts,node_audio toneAmber
class node_symptoms,node_classifiers,node_severity,node_descriptions,node_precautions toneMint
class node_dbsession,node_dbmodels,node_sqlite toneRose
class node_speech_engine toneIndigo
```

## Components

### Web experience

- [Route shell](https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Home page](https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/pages/Home.jsx): `frontend/src/pages/Home.jsx`
- [Sign in](https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Registration](https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/pages/Register.jsx): `frontend/src/pages/Register.jsx`
- [Consultation chat](https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/pages/Chatbot.jsx): `frontend/src/pages/Chatbot.jsx`
- [API client](https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Speech recognition](https://github.com/harsha33983/medical-bot-/blob/main/frontend/src/pages/Chatbot.jsx): `frontend/src/pages/Chatbot.jsx`

### Backend API

- [API handlers](https://github.com/harsha33983/medical-bot-/blob/main/backend/app.py): `backend/app.py`
- [Token auth](https://github.com/harsha33983/medical-bot-/blob/main/backend/auth.py): `backend/auth.py`
- [Request schemas](https://github.com/harsha33983/medical-bot-/blob/main/backend/schemas.py): `backend/schemas.py`
- [Speech synthesis](https://github.com/harsha33983/medical-bot-/blob/main/backend/app.py): `backend/app.py`
- [Generated audio](https://github.com/harsha33983/medical-bot-/tree/main/backend/static): `backend/static`

### Prediction data

- [Symptom vocabulary](https://github.com/harsha33983/medical-bot-/blob/main/backend/data/list_of_symptoms.pickle): `backend/data/list_of_symptoms.pickle`
- [SVC and tree](https://github.com/harsha33983/medical-bot-/tree/main/backend/models): `backend/models`
- [Severity weights](https://github.com/harsha33983/medical-bot-/blob/main/backend/data/Symptom-severity.csv): `backend/data/Symptom-severity.csv`
- [Condition descriptions](https://github.com/harsha33983/medical-bot-/blob/main/backend/data/symptom_Description.csv): `backend/data/symptom_Description.csv`
- [Precaution guidance](https://github.com/harsha33983/medical-bot-/blob/main/backend/data/symptom_precaution.csv): `backend/data/symptom_precaution.csv`

### Identity and state

- [DB session](https://github.com/harsha33983/medical-bot-/blob/main/backend/db.py): `backend/db.py`
- [User model](https://github.com/harsha33983/medical-bot-/blob/main/backend/db_models.py): `backend/db_models.py`
- [User database](https://github.com/harsha33983/medical-bot-/blob/main/backend/medical_chatbot.db): `backend/medical_chatbot.db`

### Other components

- **User**
- **Browser speech**
- **pyttsx3**

## Connections

- User → Home page: opens
- User → Sign in: signs in
- User → Registration: registers
- User → Consultation chat: enters symptoms
- Route shell → Home page: routes
- Route shell → Sign in: routes
- Route shell → Registration: routes
- Route shell → Consultation chat: routes
- Sign in → API client: sends credentials
- Registration → API client: sends credentials
- Consultation chat → API client: requests symptoms
- API client → API handlers: HTTP API
- API handlers → Request schemas: validates
- API handlers → Token auth: authenticates
- API handlers → DB session: opens session
- API handlers → User model: queries users
- DB session → User database: connects
- User model → User database: reads and writes
- API handlers → Symptom vocabulary: loads vocabulary
- API handlers → SVC and tree: loads models
- API handlers → Severity weights: loads weights
- API handlers → Condition descriptions: loads descriptions
- API handlers → Precaution guidance: loads precautions
- API handlers → SVC and tree: predicts with
- API handlers → Severity weights: matches symptoms
- API handlers → Condition descriptions: looks up condition
- API handlers → Precaution guidance: looks up guidance
- API handlers → Speech synthesis: dispatches speech
- Speech synthesis → pyttsx3: synthesizes
- Speech synthesis → Generated audio: writes WAV
- Consultation chat → Speech recognition: starts recognition
- Browser speech → Speech recognition: provides speech API
- Speech recognition → Consultation chat: returns transcript
