# vel-asthramedtech/medfriend architecture

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

- Interactive diagram: https://gitdiagram.com/vel-asthramedtech/medfriend
- Repository: https://github.com/vel-asthramedtech/medfriend

## Overview

MedFriend is a medical-care web app with a React client, Express/MongoDB backend, and Python report-analysis service. A user enters through the landing and authentication flow, then accesses health reports, AI chat, reminders, government schemes, profile, dashboard, and image scanning. The documented report path uploads a file, stores it, requests AI analysis, and saves extracted results. The graph includes documented product areas whose route internals were not sampled; their detailed calls are therefore omitted. Edges reflect visible calls or route registration, with no assumed client-to-server wiring.

Main entry points: [`client/src/App.jsx`](https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/App.jsx) (App routing), [`server/index.js`](https://github.com/vel-asthramedtech/medfriend/blob/main/server/index.js) (Express API), [`server/routes/reports.js`](https://github.com/vel-asthramedtech/medfriend/blob/main/server/routes/reports.js) (Report routes), [`server/routes/auth.js`](https://github.com/vel-asthramedtech/medfriend/blob/main/server/routes/auth.js) (Auth routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["App routing<br/>[App.jsx]"]
  node_authstate["Auth state<br/>[AuthContext.jsx]"]
  node_landing["Landing<br/>[Landing.jsx]"]
  node_authui["Authentication UI<br/>[Auth.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_reportsui["Reports UI<br/>[Reports.jsx]"]
  node_chatui["Health chat UI<br/>[Chat.jsx]"]
  node_remindersui["Reminders UI<br/>[Reminders.jsx]"]
  node_schemesui["Schemes UI<br/>[Schemes.jsx]"]
  node_profileui["Profile UI<br/>[Profile.jsx]"]
  node_scannerui["Scanner UI<br/>[Scanner.jsx]"]
end

subgraph group_backend["API backend"]
  node_api["Express API<br/>[index.js]"]
  node_authroute["Auth routes<br/>[auth.js]"]
  node_authmw["JWT protection<br/>[auth.js]"]
  node_userdb[("User records<br/>[User.js]")]
  node_dbconfig["Database connection<br/>[db.js]"]
end

subgraph group_health["Health features"]
  node_reportsroute["Report routes<br/>[reports.js]"]
  node_reportdb[("Medical reports<br/>[MedicalReport.js]")]
  node_chatroute["Chat routes<br/>[chat.js]"]
  node_remindersroute["Reminder routes<br/>[reminders.js]"]
  node_schemesroute["Scheme routes<br/>[schemes.js]"]
  node_scannerroute["Scanner routes<br/>[scanner.js]"]
end

subgraph group_analysis["Report analysis"]
  node_aiservice["AI analysis API<br/>[main.py]"]
  node_ocr["Text extraction<br/>[ocr.py]"]
  node_analyzer["Report analysis<br/>[analyzer.py]"]
end

node_person(("Patient"))
node_mongodb[("MongoDB")]
node_cloudinary[("Cloudinary storage")]

node_person -->|"uses"| node_app
node_app -->|"provides auth"| node_authstate
node_app -->|"shows"| node_landing
node_app -->|"shows"| node_authui
node_app -->|"shows"| node_dashboard
node_app -->|"shows"| node_reportsui
node_app -->|"shows"| node_chatui
node_app -->|"shows"| node_remindersui
node_app -->|"shows"| node_schemesui
node_app -->|"shows"| node_profileui
node_app -->|"shows"| node_scannerui
node_authstate -.->|"requests session"| node_authroute
node_api -->|"connects"| node_dbconfig
node_dbconfig -->|"connects"| node_mongodb
node_api -->|"mounts"| node_authroute
node_api -->|"mounts"| node_reportsroute
node_api -->|"mounts"| node_chatroute
node_api -->|"mounts"| node_remindersroute
node_api -->|"mounts"| node_schemesroute
node_api -->|"mounts"| node_scannerroute
node_authroute -->|"reads and updates"| node_userdb
node_authroute -->|"protects profile routes"| node_authmw
node_authmw -->|"loads user"| node_userdb
node_reportsroute -->|"protects endpoints"| node_authmw
node_reportsroute -->|"reads and writes"| node_reportdb
node_reportsroute -->|"uploads and deletes"| node_cloudinary
node_reportsroute -->|"requests analysis"| node_aiservice
node_aiservice -->|"extracts text"| node_ocr
node_aiservice -->|"analyzes text"| node_analyzer

click node_app "https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/App.jsx"
click node_authstate "https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/context/AuthContext.jsx"
click node_landing "https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Landing.jsx"
click node_authui "https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Auth.jsx"
click node_dashboard "https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Dashboard.jsx"
click node_reportsui "https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Reports.jsx"
click node_chatui "https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Chat.jsx"
click node_remindersui "https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Reminders.jsx"
click node_schemesui "https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Schemes.jsx"
click node_profileui "https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Profile.jsx"
click node_scannerui "https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Scanner.jsx"
click node_api "https://github.com/vel-asthramedtech/medfriend/blob/main/server/index.js"
click node_authroute "https://github.com/vel-asthramedtech/medfriend/blob/main/server/routes/auth.js"
click node_authmw "https://github.com/vel-asthramedtech/medfriend/blob/main/server/middleware/auth.js"
click node_userdb "https://github.com/vel-asthramedtech/medfriend/blob/main/server/models/User.js"
click node_reportsroute "https://github.com/vel-asthramedtech/medfriend/blob/main/server/routes/reports.js"
click node_reportdb "https://github.com/vel-asthramedtech/medfriend/blob/main/server/models/MedicalReport.js"
click node_chatroute "https://github.com/vel-asthramedtech/medfriend/blob/main/server/routes/chat.js"
click node_remindersroute "https://github.com/vel-asthramedtech/medfriend/blob/main/server/routes/reminders.js"
click node_schemesroute "https://github.com/vel-asthramedtech/medfriend/blob/main/server/routes/schemes.js"
click node_scannerroute "https://github.com/vel-asthramedtech/medfriend/blob/main/server/routes/scanner.js"
click node_dbconfig "https://github.com/vel-asthramedtech/medfriend/blob/main/server/config/db.js"
click node_aiservice "https://github.com/vel-asthramedtech/medfriend/blob/main/ai-service/main.py"
click node_ocr "https://github.com/vel-asthramedtech/medfriend/blob/main/ai-service/ocr.py"
click node_analyzer "https://github.com/vel-asthramedtech/medfriend/blob/main/ai-service/analyzer.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,node_authstate,node_landing,node_authui,node_dashboard,node_reportsui,node_chatui,node_remindersui,node_schemesui,node_profileui,node_scannerui toneBlue
class node_api,node_authroute,node_authmw,node_userdb,node_dbconfig,node_mongodb,node_cloudinary toneAmber
class node_reportsroute,node_reportdb,node_chatroute,node_remindersroute,node_schemesroute,node_scannerroute toneMint
class node_aiservice,node_ocr,node_analyzer toneRose
class node_person toneIndigo
```

## Components

### Web client

- [App routing](https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Auth state](https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Landing](https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Landing.jsx): `client/src/pages/Landing.jsx`
- [Authentication UI](https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Auth.jsx): `client/src/pages/Auth.jsx`
- [Dashboard](https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Dashboard.jsx): `client/src/pages/Dashboard.jsx`
- [Reports UI](https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Reports.jsx): `client/src/pages/Reports.jsx`
- [Health chat UI](https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Chat.jsx): `client/src/pages/Chat.jsx`
- [Reminders UI](https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Reminders.jsx): `client/src/pages/Reminders.jsx`
- [Schemes UI](https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Schemes.jsx): `client/src/pages/Schemes.jsx`
- [Profile UI](https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Profile.jsx): `client/src/pages/Profile.jsx`
- [Scanner UI](https://github.com/vel-asthramedtech/medfriend/blob/main/client/src/pages/Scanner.jsx): `client/src/pages/Scanner.jsx`

### API backend

- [Express API](https://github.com/vel-asthramedtech/medfriend/blob/main/server/index.js): `server/index.js`
- [Auth routes](https://github.com/vel-asthramedtech/medfriend/blob/main/server/routes/auth.js): `server/routes/auth.js`
- [JWT protection](https://github.com/vel-asthramedtech/medfriend/blob/main/server/middleware/auth.js): `server/middleware/auth.js`
- [User records](https://github.com/vel-asthramedtech/medfriend/blob/main/server/models/User.js): `server/models/User.js`
- [Database connection](https://github.com/vel-asthramedtech/medfriend/blob/main/server/config/db.js): `server/config/db.js`

### Health features

- [Report routes](https://github.com/vel-asthramedtech/medfriend/blob/main/server/routes/reports.js): `server/routes/reports.js`
- [Medical reports](https://github.com/vel-asthramedtech/medfriend/blob/main/server/models/MedicalReport.js): `server/models/MedicalReport.js`
- [Chat routes](https://github.com/vel-asthramedtech/medfriend/blob/main/server/routes/chat.js): `server/routes/chat.js`
- [Reminder routes](https://github.com/vel-asthramedtech/medfriend/blob/main/server/routes/reminders.js): `server/routes/reminders.js`
- [Scheme routes](https://github.com/vel-asthramedtech/medfriend/blob/main/server/routes/schemes.js): `server/routes/schemes.js`
- [Scanner routes](https://github.com/vel-asthramedtech/medfriend/blob/main/server/routes/scanner.js): `server/routes/scanner.js`

### Report analysis

- [AI analysis API](https://github.com/vel-asthramedtech/medfriend/blob/main/ai-service/main.py): `ai-service/main.py`
- [Text extraction](https://github.com/vel-asthramedtech/medfriend/blob/main/ai-service/ocr.py): `ai-service/ocr.py`
- [Report analysis](https://github.com/vel-asthramedtech/medfriend/blob/main/ai-service/analyzer.py): `ai-service/analyzer.py`

### Other components

- **Patient**
- **MongoDB**
- **Cloudinary storage**

## Connections

- Patient → App routing: uses (evidence: `client/src/App.jsx`)
- App routing → Auth state: provides auth (evidence: `client/src/App.jsx`)
- App routing → Landing: shows (evidence: `client/src/App.jsx`)
- App routing → Authentication UI: shows (evidence: `client/src/App.jsx`)
- App routing → Dashboard: shows (evidence: `client/src/App.jsx`)
- App routing → Reports UI: shows (evidence: `client/src/App.jsx`)
- App routing → Health chat UI: shows (evidence: `client/src/App.jsx`)
- App routing → Reminders UI: shows (evidence: `client/src/App.jsx`)
- App routing → Schemes UI: shows (evidence: `client/src/App.jsx`)
- App routing → Profile UI: shows (evidence: `client/src/App.jsx`)
- App routing → Scanner UI: shows (evidence: `client/src/App.jsx`)
- Auth state → Auth routes: requests session
- Express API → Database connection: connects (evidence: `server/index.js`)
- Database connection → MongoDB: connects (evidence: `server/config/db.js`)
- Express API → Auth routes: mounts (evidence: `server/index.js`)
- Express API → Report routes: mounts (evidence: `server/index.js`)
- Express API → Chat routes: mounts (evidence: `server/index.js`)
- Express API → Reminder routes: mounts (evidence: `server/index.js`)
- Express API → Scheme routes: mounts (evidence: `server/index.js`)
- Express API → Scanner routes: mounts (evidence: `server/index.js`)
- Auth routes → User records: reads and updates (evidence: `server/routes/auth.js`)
- Auth routes → JWT protection: protects profile routes (evidence: `server/routes/auth.js`)
- JWT protection → User records: loads user (evidence: `server/middleware/auth.js`)
- Report routes → JWT protection: protects endpoints (evidence: `server/routes/reports.js`)
- Report routes → Medical reports: reads and writes (evidence: `server/routes/reports.js`)
- Report routes → Cloudinary storage: uploads and deletes (evidence: `server/routes/reports.js`)
- Report routes → AI analysis API: requests analysis (evidence: `server/routes/reports.js`)
- AI analysis API → Text extraction: extracts text (evidence: `ai-service/main.py`)
- AI analysis API → Report analysis: analyzes text (evidence: `ai-service/main.py`)
