# rohit-create-ctrl/agentic-ai-doctor-and-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot
- Repository: https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot

## Overview

MedAI is a health-information web app combining a local symptom/chat assistant, medicine lookup, prescription-upload demo, emergency guidance, and a health-history dashboard backed by an Express API and MongoDB. The evidenced consultation path is symptom entry in the chat page, local analysis in the data module, and a displayed response; dashboard records have a separate authenticated backend path. The prescription page simulates analysis rather than calling an OCR service. Frontend API wiring and unsampled page behavior are not asserted here.

Main entry points: [`ai-doctor/src/app/chat/page.tsx`](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/app/chat/page.tsx) (Consultation chat), [`backend/server.js`](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/server.js) (Express server), [`backend/routes/dataRoutes.js`](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/routes/dataRoutes.js) (Record routes), [`ai-doctor/src/app/page.tsx`](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/app/page.tsx) (Home)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_home["Home<br/>[page.tsx]"]
  node_chat["Consultation chat<br/>[page.tsx]"]
  node_dashboard["Health dashboard<br/>[page.tsx]"]
  node_medicine["Medicine lookup<br/>[page.tsx]"]
  node_prescription["Prescription reader<br/>[page.tsx]"]
  node_emergency["Emergency support<br/>[page.tsx]"]
  node_frontendapi["Frontend API client<br/>[api.ts]"]
end

subgraph group_health["Health information"]
  node_symptom["Symptom analysis<br/>[data.ts]"]
  node_healthdata["Medicine and advice data<br/>[data.ts]"]
end

subgraph group_api["Backend API"]
  node_server["Express server<br/>[server.js]"]
  node_authroutes["Auth routes<br/>[authRoutes.js]"]
  node_authcontroller["Auth controller<br/>[authController.js]"]
  node_dataroutes["Record routes<br/>[dataRoutes.js]"]
  node_datacontroller["Record controller<br/>[dataController.js]"]
  node_authguard["JWT protection<br/>[authMiddleware.js]"]
  node_errors["Error handling<br/>[errorMiddleware.js]"]
end

subgraph group_storage["Persistence"]
  node_usermodel["User model<br/>[User.js]"]
  node_recordmodel["Record model<br/>[Record.js]"]
  node_dbconfig["Database connection<br/>[db.js]"]
  node_mongodb[("MongoDB")]
end

node_person(("User"))

node_person -->|"opens"| node_home
node_home -->|"starts consultation"| node_chat
node_person -->|"enters symptoms"| node_chat
node_chat -->|"analyzes symptoms"| node_symptom
node_chat -->|"generates reply"| node_healthdata
node_symptom -->|"returns diagnosis"| node_chat
node_person -->|"searches medicines"| node_medicine
node_person -->|"uploads image"| node_prescription
node_person -->|"requests guidance"| node_emergency
node_person -->|"views history"| node_dashboard
node_server -->|"mounts routes"| node_authroutes
node_server -->|"mounts routes"| node_dataroutes
node_server -->|"handles errors"| node_errors
node_authroutes -->|"dispatches"| node_authcontroller
node_dataroutes -->|"protects records"| node_authguard
node_dataroutes -->|"dispatches"| node_datacontroller
node_authcontroller -->|"reads and creates"| node_usermodel
node_authguard -->|"loads user"| node_usermodel
node_datacontroller -->|"manages records"| node_recordmodel
node_dbconfig -->|"connects"| node_mongodb

click node_home "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/app/page.tsx"
click node_chat "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/app/chat/page.tsx"
click node_dashboard "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/app/dashboard/page.tsx"
click node_medicine "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/app/medicine/page.tsx"
click node_prescription "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/app/prescription/page.tsx"
click node_emergency "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/app/emergency/page.tsx"
click node_symptom "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/lib/data.ts"
click node_healthdata "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/lib/data.ts"
click node_frontendapi "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/lib/api.ts"
click node_server "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/server.js"
click node_authroutes "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/routes/authRoutes.js"
click node_authcontroller "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/controllers/authController.js"
click node_dataroutes "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/routes/dataRoutes.js"
click node_datacontroller "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/controllers/dataController.js"
click node_authguard "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/middlewares/authMiddleware.js"
click node_errors "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/middlewares/errorMiddleware.js"
click node_usermodel "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/models/User.js"
click node_recordmodel "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/models/Record.js"
click node_dbconfig "https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/config/db.js"

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_home,node_chat,node_dashboard,node_medicine,node_prescription,node_emergency,node_frontendapi,node_person toneBlue
class node_symptom,node_healthdata toneAmber
class node_server,node_authroutes,node_authcontroller,node_dataroutes,node_datacontroller,node_authguard,node_errors toneMint
class node_usermodel,node_recordmodel,node_dbconfig,node_mongodb toneRose
```

## Components

### Web experience

- [Home](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/app/page.tsx): `ai-doctor/src/app/page.tsx`
- [Consultation chat](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/app/chat/page.tsx): `ai-doctor/src/app/chat/page.tsx`
- [Health dashboard](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/app/dashboard/page.tsx): `ai-doctor/src/app/dashboard/page.tsx`
- [Medicine lookup](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/app/medicine/page.tsx): `ai-doctor/src/app/medicine/page.tsx`
- [Prescription reader](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/app/prescription/page.tsx): `ai-doctor/src/app/prescription/page.tsx`
- [Emergency support](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/app/emergency/page.tsx): `ai-doctor/src/app/emergency/page.tsx`
- [Frontend API client](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/lib/api.ts): `ai-doctor/src/lib/api.ts`

### Health information

- [Symptom analysis](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/lib/data.ts): `ai-doctor/src/lib/data.ts`
- [Medicine and advice data](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/ai-doctor/src/lib/data.ts): `ai-doctor/src/lib/data.ts`

### Backend API

- [Express server](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/server.js): `backend/server.js`
- [Auth routes](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Auth controller](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [Record routes](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/routes/dataRoutes.js): `backend/routes/dataRoutes.js`
- [Record controller](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/controllers/dataController.js): `backend/controllers/dataController.js`
- [JWT protection](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/middlewares/authMiddleware.js): `backend/middlewares/authMiddleware.js`
- [Error handling](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/middlewares/errorMiddleware.js): `backend/middlewares/errorMiddleware.js`

### Persistence

- [User model](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/models/User.js): `backend/models/User.js`
- [Record model](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/models/Record.js): `backend/models/Record.js`
- [Database connection](https://github.com/rohit-create-ctrl/agentic-ai-doctor-and-chatbot/blob/main/backend/config/db.js): `backend/config/db.js`
- **MongoDB**

### Other components

- **User**

## Connections

- User → Home: opens
- Home → Consultation chat: starts consultation
- User → Consultation chat: enters symptoms
- Consultation chat → Symptom analysis: analyzes symptoms
- Consultation chat → Medicine and advice data: generates reply
- Symptom analysis → Consultation chat: returns diagnosis
- User → Medicine lookup: searches medicines
- User → Prescription reader: uploads image
- User → Emergency support: requests guidance
- User → Health dashboard: views history
- Express server → Auth routes: mounts routes
- Express server → Record routes: mounts routes
- Express server → Error handling: handles errors
- Auth routes → Auth controller: dispatches
- Record routes → JWT protection: protects records
- Record routes → Record controller: dispatches
- Auth controller → User model: reads and creates
- JWT protection → User model: loads user
- Record controller → Record model: manages records
- Database connection → MongoDB: connects
