# wacxv/havenbloom architecture

> Architecture diagram of the GitHub repository wacxv/havenbloom, 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/wacxv/havenbloom
- Repository: https://github.com/wacxv/havenbloom

## Overview

HavenBloom combines a patient/doctor telemedicine web app, an Express/MongoDB backend, and Python BLE monitoring tools. The main workflow is account access, care coordination and consultation, with a separate device workflow that sends heart-rate readings through MQTT for persistence and live WebSocket display. Paths and links for unsampled capabilities are based on the README and repository tree; detailed wiring is shown only where the excerpts or documentation support it.

Main entry points: [`havenbloom-frontend-main/src/App.jsx`](https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/App.jsx) (HavenBloom client), [`havenbloom-backend-master/routes`](https://github.com/wacxv/havenbloom/tree/main/havenbloom-backend-master/routes) (REST route groups), [`havenbloom-backend-master/app.js`](https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/app.js) (Express entry point), [`havenbloom-backend-master/services/mqttService.js`](https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/services/mqttService.js) (MQTT ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_web["HavenBloom client<br/>[App.jsx]"]
  node_auth["Sign-in and profiles<br/>[SignIn.jsx]"]
  node_calendar["Appointments<br/>[Calendar.jsx]"]
  node_messages["Messaging<br/>[Messages.jsx]"]
  node_video["Video consultation<br/>[Videocall.jsx]"]
  node_analytics["Health analytics<br/>[Analytics.jsx]"]
  node_deviceui["Device linking<br/>[LinkDevice.jsx]"]
  node_adminui["Care administration<br/>[AssignPatient.jsx]"]
  node_socketclient["Socket client<br/>[socketService.js]"]
end

subgraph group_api["Backend API"]
  node_backend["Express entry point<br/>[app.js]"]
  node_routes["REST route groups"]
  node_authlogic["Account and OTP logic<br/>[userController.js]"]
  node_carelogic["Care workflows"]
  node_devicecontroller["Device and readings"]
  node_socketserver["Socket.IO signaling<br/>[app.js]"]
end

subgraph group_monitoring["Device monitoring"]
  node_ble["BLE monitor tools<br/>[SMARTWATCH.py]"]
  node_mqtt["MQTT ingestion<br/>[mqttService.js]"]
  node_websocket["Live BPM broadcast"]
end

subgraph group_persistence["Data and files"]
  node_mongo[("MongoDB<br/>[db.js]")]
  node_models[("Domain data models")]
  node_gridfs[("Fetal audio files<br/>[audioRoutes.js]")]
end

node_patient(("Patient or clinician"))
node_mqttbroker{{"MQTT broker"}}
node_smtp{{"SMTP email"}}

node_patient -->|"uses"| node_web
node_web -->|"routes to"| node_auth
node_web -->|"routes to"| node_calendar
node_web -->|"routes to"| node_messages
node_web -->|"routes to"| node_video
node_web -->|"routes to"| node_analytics
node_web -->|"routes to"| node_deviceui
node_web -->|"routes to"| node_adminui
node_messages -->|"uses"| node_socketclient
node_video -->|"uses"| node_socketclient
node_socketclient -->|"Socket.IO"| node_socketserver
node_web -->|"REST requests"| node_backend
node_backend -->|"mounts"| node_routes
node_routes -->|"dispatches"| node_authlogic
node_routes -->|"dispatches"| node_carelogic
node_routes -->|"dispatches"| node_devicecontroller
node_authlogic -->|"reads and writes"| node_models
node_carelogic -->|"care records"| node_models
node_devicecontroller -->|"reads and writes"| node_models
node_ble -->|"publishes BPM"| node_mqttbroker
node_ble -->|"device lookup"| node_backend
node_mqttbroker -->|"delivers readings"| node_mqtt
node_backend -->|"starts listener"| node_mqtt
node_mqtt -->|"stores aggregates"| node_models
node_mqtt -->|"broadcasts readings"| node_websocket
node_devicecontroller -->|"broadcasts live BPM"| node_websocket
node_websocket -->|"streams BPM"| node_analytics
node_authlogic -->|"sends OTP email"| node_smtp
node_routes -->|"audio download route"| node_gridfs
node_gridfs -->|"reads GridFS"| node_mongo

click node_web "https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/App.jsx"
click node_auth "https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/components/SignIn/SignIn.jsx"
click node_calendar "https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/components/Calendar/Calendar.jsx"
click node_messages "https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/components/Messages/Messages.jsx"
click node_video "https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/components/Videocall/Videocall.jsx"
click node_analytics "https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/components/Analytics/Analytics.jsx"
click node_deviceui "https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/components/LinkDevice/LinkDevice.jsx"
click node_adminui "https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/pages/admin/AssignPatient.jsx"
click node_socketclient "https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/services/socketService.js"
click node_backend "https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/app.js"
click node_routes "https://github.com/wacxv/havenbloom/tree/main/havenbloom-backend-master/routes"
click node_authlogic "https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/controllers/userController.js"
click node_carelogic "https://github.com/wacxv/havenbloom/tree/main/havenbloom-backend-master/controllers"
click node_devicecontroller "https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/controllers/deviceController.js"
click node_socketserver "https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/app.js"
click node_ble "https://github.com/wacxv/havenbloom/blob/main/GUI/SMARTWATCH.py"
click node_mqtt "https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/services/mqttService.js"
click node_websocket "https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/services/websocketService.js"
click node_mongo "https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/db.js"
click node_models "https://github.com/wacxv/havenbloom/tree/main/havenbloom-backend-master/models"
click node_gridfs "https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/routes/audioRoutes.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_web,node_auth,node_calendar,node_messages,node_video,node_analytics,node_deviceui,node_adminui,node_socketclient toneBlue
class node_backend,node_routes,node_authlogic,node_carelogic,node_devicecontroller,node_socketserver toneAmber
class node_ble,node_mqtt,node_websocket toneMint
class node_mongo,node_models,node_gridfs toneRose
class node_patient,node_mqttbroker,node_smtp toneIndigo
```

## Components

### Web application

- [HavenBloom client](https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/App.jsx): `havenbloom-frontend-main/src/App.jsx`
- [Sign-in and profiles](https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/components/SignIn/SignIn.jsx): `havenbloom-frontend-main/src/components/SignIn/SignIn.jsx`
- [Appointments](https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/components/Calendar/Calendar.jsx): `havenbloom-frontend-main/src/components/Calendar/Calendar.jsx`
- [Messaging](https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/components/Messages/Messages.jsx): `havenbloom-frontend-main/src/components/Messages/Messages.jsx`
- [Video consultation](https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/components/Videocall/Videocall.jsx): `havenbloom-frontend-main/src/components/Videocall/Videocall.jsx`
- [Health analytics](https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/components/Analytics/Analytics.jsx): `havenbloom-frontend-main/src/components/Analytics/Analytics.jsx`
- [Device linking](https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/components/LinkDevice/LinkDevice.jsx): `havenbloom-frontend-main/src/components/LinkDevice/LinkDevice.jsx`
- [Care administration](https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/pages/admin/AssignPatient.jsx): `havenbloom-frontend-main/src/pages/admin/AssignPatient.jsx`
- [Socket client](https://github.com/wacxv/havenbloom/blob/main/havenbloom-frontend-main/src/services/socketService.js): `havenbloom-frontend-main/src/services/socketService.js`

### Backend API

- [Express entry point](https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/app.js): `havenbloom-backend-master/app.js`
- [REST route groups](https://github.com/wacxv/havenbloom/tree/main/havenbloom-backend-master/routes): `havenbloom-backend-master/routes`
- [Account and OTP logic](https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/controllers/userController.js): `havenbloom-backend-master/controllers/userController.js`
- [Care workflows](https://github.com/wacxv/havenbloom/tree/main/havenbloom-backend-master/controllers): `havenbloom-backend-master/controllers`
- [Device and readings](https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/controllers/deviceController.js): `havenbloom-backend-master/controllers/deviceController.js`
- [Socket.IO signaling](https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/app.js): `havenbloom-backend-master/app.js`

### Device monitoring

- [BLE monitor tools](https://github.com/wacxv/havenbloom/blob/main/GUI/SMARTWATCH.py): `GUI/SMARTWATCH.py`
- [MQTT ingestion](https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/services/mqttService.js): `havenbloom-backend-master/services/mqttService.js`
- [Live BPM broadcast](https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/services/websocketService.js): `havenbloom-backend-master/services/websocketService.js`

### Data and files

- [MongoDB](https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/db.js): `havenbloom-backend-master/db.js`
- [Domain data models](https://github.com/wacxv/havenbloom/tree/main/havenbloom-backend-master/models): `havenbloom-backend-master/models`
- [Fetal audio files](https://github.com/wacxv/havenbloom/blob/main/havenbloom-backend-master/routes/audioRoutes.js): `havenbloom-backend-master/routes/audioRoutes.js`

### Other components

- **Patient or clinician**
- **MQTT broker**
- **SMTP email**

## Connections

- Patient or clinician → HavenBloom client: uses
- HavenBloom client → Sign-in and profiles: routes to
- HavenBloom client → Appointments: routes to
- HavenBloom client → Messaging: routes to
- HavenBloom client → Video consultation: routes to
- HavenBloom client → Health analytics: routes to
- HavenBloom client → Device linking: routes to
- HavenBloom client → Care administration: routes to
- Messaging → Socket client: uses
- Video consultation → Socket client: uses
- Socket client → Socket.IO signaling: Socket.IO
- HavenBloom client → Express entry point: REST requests
- Express entry point → REST route groups: mounts
- REST route groups → Account and OTP logic: dispatches
- REST route groups → Care workflows: dispatches
- REST route groups → Device and readings: dispatches
- Account and OTP logic → Domain data models: reads and writes
- Care workflows → Domain data models: care records
- Device and readings → Domain data models: reads and writes
- BLE monitor tools → MQTT broker: publishes BPM
- BLE monitor tools → Express entry point: device lookup
- MQTT broker → MQTT ingestion: delivers readings
- Express entry point → MQTT ingestion: starts listener
- MQTT ingestion → Domain data models: stores aggregates
- MQTT ingestion → Live BPM broadcast: broadcasts readings
- Device and readings → Live BPM broadcast: broadcasts live BPM
- Live BPM broadcast → Health analytics: streams BPM
- Account and OTP logic → SMTP email: sends OTP email
- REST route groups → Fetal audio files: audio download route
- Fetal audio files → MongoDB: reads GridFS
