# saboten123/well_nest architecture

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

- Interactive diagram: https://gitdiagram.com/saboten123/well_nest
- Repository: https://github.com/saboten123/well_nest

## Overview

Well-Nest is a mental-health and community-wellness platform: people find care providers, manage appointments, communicate with clinicians, and use an AI wellness assistant. The React app presents those workflows; the Express service owns accounts, profiles, appointments, messaging, and video-call sessions, while the FastAPI service handles conversational AI and session memory. A separate blockchain backend supports outbreak reporting, events, donations, and rewards. The README documents RAG and web retrieval; their exact internal wiring is not fully shown in the sampled sources.

Main entry points: [`backend/src/app.js`](https://github.com/saboten123/well_nest/blob/main/backend/src/app.js) (HTTP app), [`frontend/src/App.jsx`](https://github.com/saboten123/well_nest/blob/main/frontend/src/App.jsx) (Page router), [`ai_backend/app/agent.py`](https://github.com/saboten123/well_nest/blob/main/ai_backend/app/agent.py) (AI agent), [`blockchain_backend/index.js`](https://github.com/saboten123/well_nest/blob/main/blockchain_backend/index.js) (Community API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_app["Page router<br/>[App.jsx]"]
  node_carepages["Care pages<br/>[DoctorsPage.jsx]"]
  node_appointmentpages["Appointment pages"]
  node_chatpage["AI chat page<br/>[AiChatPage.jsx]"]
  node_communitypages["Community pages<br/>[OutBreakPage.jsx]"]
  node_api["API client<br/>[api.js]"]
end

subgraph group_care["Care backend"]
  node_express["HTTP app<br/>[app.js]"]
  node_authroutes["Auth routes<br/>[auth.routes.js]"]
  node_authcontroller["Auth workflows<br/>[auth.controller.js]"]
  node_profileroutes["Profile routes<br/>[profile.routes.js]"]
  node_profilecontrollers["Care controllers"]
  node_appointmentroutes["Appointment routes"]
  node_chatroutes["Patient chat<br/>[chat.routes.js]"]
  node_videoroutes["Video-call routes"]
  node_videocontroller["Call sessions"]
  node_signaling["WebRTC signaling<br/>[webrtcHandler.js]"]
  node_caredata[("Care records<br/>[Appointments.js]")]
end

subgraph group_assistant["AI assistant"]
  node_aiapi["Chat endpoint<br/>[routes.py]"]
  node_agent["AI agent<br/>[agent.py]"]
  node_rag["Retrieval<br/>[rag.py]"]
  node_memory[("Conversation memory<br/>[memory.py]")]
  node_gemini["Gemini service<br/>[gemini_tool.py]"]
  node_tavily["Tavily search<br/>[tavily_tool.py]"]
end

subgraph group_community["Community and blockchain"]
  node_communityapi["Community API<br/>[index.js]"]
  node_outbreak["Outbreak reporting<br/>[outbreakRouter.js]"]
  node_events["Event participation<br/>[organiseRouter.js]"]
  node_donations["Donations and rewards<br/>[moneyRouter.js]"]
  node_chainservices["Contract services"]
  node_communitydata[("Community records<br/>[outbreakRecords.js]")]
end

node_person(("Platform user"))

node_person -->|"uses"| node_app
node_app -->|"routes to"| node_carepages
node_app -->|"routes to"| node_appointmentpages
node_app -->|"routes to"| node_chatpage
node_app -->|"routes to"| node_communitypages
node_carepages -->|"requests data"| node_api
node_appointmentpages -->|"requests data"| node_api
node_api -->|"HTTP requests"| node_express
node_express -->|"mounts"| node_authroutes
node_express -->|"mounts"| node_profileroutes
node_express -->|"mounts"| node_appointmentroutes
node_express -->|"mounts"| node_videoroutes
node_authroutes -->|"dispatches"| node_authcontroller
node_profileroutes -->|"dispatches"| node_profilecontrollers
node_videoroutes -->|"dispatches"| node_videocontroller
node_videocontroller -->|"reads and writes"| node_caredata
node_express -->|"initializes"| node_signaling
node_chatpage -->|"chat request"| node_aiapi
node_aiapi -->|"loads and updates"| node_memory
node_aiapi -->|"runs"| node_agent
node_agent -.->|"retrieves context"| node_rag
node_agent -.->|"generates reply"| node_gemini
node_agent -.->|"searches web"| node_tavily
node_communitypages -->|"community requests"| node_communityapi
node_communityapi -->|"mounts"| node_outbreak
node_communityapi -->|"mounts"| node_events
node_communityapi -->|"mounts"| node_donations
node_outbreak -->|"stores reports"| node_communitydata
node_outbreak -->|"verifies and submits"| node_chainservices

click node_app "https://github.com/saboten123/well_nest/blob/main/frontend/src/App.jsx"
click node_carepages "https://github.com/saboten123/well_nest/blob/main/frontend/src/pages/DoctorsPage.jsx"
click node_appointmentpages "https://github.com/saboten123/well_nest/blob/main/frontend/src/pages/PatientAppointmentsPage.jsx"
click node_chatpage "https://github.com/saboten123/well_nest/blob/main/frontend/src/pages/AiChatPage.jsx"
click node_communitypages "https://github.com/saboten123/well_nest/blob/main/frontend/src/pages/OutBreakPage.jsx"
click node_api "https://github.com/saboten123/well_nest/blob/main/frontend/src/utils/api.js"
click node_express "https://github.com/saboten123/well_nest/blob/main/backend/src/app.js"
click node_authroutes "https://github.com/saboten123/well_nest/blob/main/backend/src/routes/auth.routes.js"
click node_authcontroller "https://github.com/saboten123/well_nest/blob/main/backend/src/controllers/auth.controller.js"
click node_profileroutes "https://github.com/saboten123/well_nest/blob/main/backend/src/routes/profile.routes.js"
click node_profilecontrollers "https://github.com/saboten123/well_nest/blob/main/backend/src/controllers/doctor.controller.js"
click node_appointmentroutes "https://github.com/saboten123/well_nest/blob/main/backend/src/routes/appointmentRouter.js"
click node_chatroutes "https://github.com/saboten123/well_nest/blob/main/backend/src/routes/chat.routes.js"
click node_videoroutes "https://github.com/saboten123/well_nest/blob/main/backend/src/routes/videoCall.routes.js"
click node_videocontroller "https://github.com/saboten123/well_nest/blob/main/backend/src/controllers/videoCall.controller.js"
click node_signaling "https://github.com/saboten123/well_nest/blob/main/backend/src/socket/webrtcHandler.js"
click node_caredata "https://github.com/saboten123/well_nest/blob/main/backend/src/models/Appointments.js"
click node_aiapi "https://github.com/saboten123/well_nest/blob/main/ai_backend/app/routes.py"
click node_agent "https://github.com/saboten123/well_nest/blob/main/ai_backend/app/agent.py"
click node_rag "https://github.com/saboten123/well_nest/blob/main/ai_backend/app/rag.py"
click node_memory "https://github.com/saboten123/well_nest/blob/main/ai_backend/app/memory.py"
click node_gemini "https://github.com/saboten123/well_nest/blob/main/ai_backend/app/tools/gemini_tool.py"
click node_tavily "https://github.com/saboten123/well_nest/blob/main/ai_backend/app/tools/tavily_tool.py"
click node_communityapi "https://github.com/saboten123/well_nest/blob/main/blockchain_backend/index.js"
click node_outbreak "https://github.com/saboten123/well_nest/blob/main/blockchain_backend/routes/outbreakRouter.js"
click node_events "https://github.com/saboten123/well_nest/blob/main/blockchain_backend/routes/organiseRouter.js"
click node_donations "https://github.com/saboten123/well_nest/blob/main/blockchain_backend/routes/moneyRouter.js"
click node_chainservices "https://github.com/saboten123/well_nest/blob/main/blockchain_backend/contractService/Outbreak_contract.js"
click node_communitydata "https://github.com/saboten123/well_nest/blob/main/blockchain_backend/model/outbreakRecords.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_app,node_carepages,node_appointmentpages,node_chatpage,node_communitypages,node_api,node_person toneBlue
class node_express,node_authroutes,node_authcontroller,node_profileroutes,node_profilecontrollers,node_appointmentroutes,node_chatroutes,node_videoroutes,node_videocontroller,node_signaling,node_caredata toneAmber
class node_aiapi,node_agent,node_rag,node_memory,node_gemini,node_tavily toneMint
class node_communityapi,node_outbreak,node_events,node_donations,node_chainservices,node_communitydata toneRose
```

## Components

### Web experience

- [Page router](https://github.com/saboten123/well_nest/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Care pages](https://github.com/saboten123/well_nest/blob/main/frontend/src/pages/DoctorsPage.jsx): `frontend/src/pages/DoctorsPage.jsx`
- [Appointment pages](https://github.com/saboten123/well_nest/blob/main/frontend/src/pages/PatientAppointmentsPage.jsx): `frontend/src/pages/PatientAppointmentsPage.jsx`
- [AI chat page](https://github.com/saboten123/well_nest/blob/main/frontend/src/pages/AiChatPage.jsx): `frontend/src/pages/AiChatPage.jsx`
- [Community pages](https://github.com/saboten123/well_nest/blob/main/frontend/src/pages/OutBreakPage.jsx): `frontend/src/pages/OutBreakPage.jsx`
- [API client](https://github.com/saboten123/well_nest/blob/main/frontend/src/utils/api.js): `frontend/src/utils/api.js`

### Care backend

- [HTTP app](https://github.com/saboten123/well_nest/blob/main/backend/src/app.js): `backend/src/app.js`
- [Auth routes](https://github.com/saboten123/well_nest/blob/main/backend/src/routes/auth.routes.js): `backend/src/routes/auth.routes.js`
- [Auth workflows](https://github.com/saboten123/well_nest/blob/main/backend/src/controllers/auth.controller.js): `backend/src/controllers/auth.controller.js`
- [Profile routes](https://github.com/saboten123/well_nest/blob/main/backend/src/routes/profile.routes.js): `backend/src/routes/profile.routes.js`
- [Care controllers](https://github.com/saboten123/well_nest/blob/main/backend/src/controllers/doctor.controller.js): `backend/src/controllers/doctor.controller.js`
- [Appointment routes](https://github.com/saboten123/well_nest/blob/main/backend/src/routes/appointmentRouter.js): `backend/src/routes/appointmentRouter.js`
- [Patient chat](https://github.com/saboten123/well_nest/blob/main/backend/src/routes/chat.routes.js): `backend/src/routes/chat.routes.js`
- [Video-call routes](https://github.com/saboten123/well_nest/blob/main/backend/src/routes/videoCall.routes.js): `backend/src/routes/videoCall.routes.js`
- [Call sessions](https://github.com/saboten123/well_nest/blob/main/backend/src/controllers/videoCall.controller.js): `backend/src/controllers/videoCall.controller.js`
- [WebRTC signaling](https://github.com/saboten123/well_nest/blob/main/backend/src/socket/webrtcHandler.js): `backend/src/socket/webrtcHandler.js`
- [Care records](https://github.com/saboten123/well_nest/blob/main/backend/src/models/Appointments.js): `backend/src/models/Appointments.js`

### AI assistant

- [Chat endpoint](https://github.com/saboten123/well_nest/blob/main/ai_backend/app/routes.py): `ai_backend/app/routes.py`
- [AI agent](https://github.com/saboten123/well_nest/blob/main/ai_backend/app/agent.py): `ai_backend/app/agent.py`
- [Retrieval](https://github.com/saboten123/well_nest/blob/main/ai_backend/app/rag.py): `ai_backend/app/rag.py`
- [Conversation memory](https://github.com/saboten123/well_nest/blob/main/ai_backend/app/memory.py): `ai_backend/app/memory.py`
- [Gemini service](https://github.com/saboten123/well_nest/blob/main/ai_backend/app/tools/gemini_tool.py): `ai_backend/app/tools/gemini_tool.py`
- [Tavily search](https://github.com/saboten123/well_nest/blob/main/ai_backend/app/tools/tavily_tool.py): `ai_backend/app/tools/tavily_tool.py`

### Community and blockchain

- [Community API](https://github.com/saboten123/well_nest/blob/main/blockchain_backend/index.js): `blockchain_backend/index.js`
- [Outbreak reporting](https://github.com/saboten123/well_nest/blob/main/blockchain_backend/routes/outbreakRouter.js): `blockchain_backend/routes/outbreakRouter.js`
- [Event participation](https://github.com/saboten123/well_nest/blob/main/blockchain_backend/routes/organiseRouter.js): `blockchain_backend/routes/organiseRouter.js`
- [Donations and rewards](https://github.com/saboten123/well_nest/blob/main/blockchain_backend/routes/moneyRouter.js): `blockchain_backend/routes/moneyRouter.js`
- [Contract services](https://github.com/saboten123/well_nest/blob/main/blockchain_backend/contractService/Outbreak_contract.js): `blockchain_backend/contractService/Outbreak_contract.js`
- [Community records](https://github.com/saboten123/well_nest/blob/main/blockchain_backend/model/outbreakRecords.js): `blockchain_backend/model/outbreakRecords.js`

### Other components

- **Platform user**

## Connections

- Platform user → Page router: uses
- Page router → Care pages: routes to
- Page router → Appointment pages: routes to
- Page router → AI chat page: routes to
- Page router → Community pages: routes to
- Care pages → API client: requests data
- Appointment pages → API client: requests data
- API client → HTTP app: HTTP requests
- HTTP app → Auth routes: mounts
- HTTP app → Profile routes: mounts
- HTTP app → Appointment routes: mounts
- HTTP app → Video-call routes: mounts
- Auth routes → Auth workflows: dispatches
- Profile routes → Care controllers: dispatches
- Video-call routes → Call sessions: dispatches
- Call sessions → Care records: reads and writes
- HTTP app → WebRTC signaling: initializes
- AI chat page → Chat endpoint: chat request
- Chat endpoint → Conversation memory: loads and updates
- Chat endpoint → AI agent: runs
- AI agent → Retrieval: retrieves context
- AI agent → Gemini service: generates reply
- AI agent → Tavily search: searches web
- Community pages → Community API: community requests
- Community API → Outbreak reporting: mounts
- Community API → Event participation: mounts
- Community API → Donations and rewards: mounts
- Outbreak reporting → Community records: stores reports
- Outbreak reporting → Contract services: verifies and submits
