# congminhvt2003/healthymonitor architecture

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

## Overview

Healthy Monitor is a React Native app for live heart-rate and blood-oxygen monitoring, threshold alerts, emergency contact actions, account access, and health-history review. The principal flow starts the monitor at app launch, receives measurements, updates shared health state, and reacts to critical readings with stored alerts and an SOS sequence. History, reports, authentication, settings, and theming are represented as distinct capabilities. Several screen and service implementations were not sampled, so uncertain wiring—especially report generation and screen-to-service calls—is left out.

Main entry points: [`src/services/HeartMonitorController.ts`](https://github.com/congminhvt2003/healthymonitor/blob/main/src/services/HeartMonitorController.ts) (Monitor controller), [`src/navigation/AppNavigator.tsx`](https://github.com/congminhvt2003/healthymonitor/blob/main/src/navigation/AppNavigator.tsx) (Navigation), [`App.tsx`](https://github.com/congminhvt2003/healthymonitor/blob/main/App.tsx) (App entry), [`src/services/alertService.ts`](https://github.com/congminhvt2003/healthymonitor/blob/main/src/services/alertService.ts) (Alert service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App shell"]
  node_app["App entry<br/>[App.tsx]"]
  node_nav["Navigation<br/>[AppNavigator.tsx]"]
end

subgraph group_monitor["Live monitoring"]
  node_dashboard["Live dashboard"]
  node_controller["Monitor controller"]
  node_health["Health feed<br/>[healthService.ts]"]
  node_healthstate["Health state<br/>[useHealthStore.ts]"]
  node_thresholds["Health analysis<br/>[healthAnalysis.ts]"]
end

subgraph group_records["Health records"]
  node_alertsvc["Alert service<br/>[alertService.ts]"]
  node_alertlog["Alert log<br/>[AlertLog.tsx]"]
  node_historyscreen["History screen<br/>[HistoryScreen.tsx]"]
  node_historysvc["History service<br/>[historyService.ts]"]
  node_report["PDF reports<br/>[reportService.ts]"]
  node_database[("Firebase database<br/>[firebase.ts]")]
end

subgraph group_accounts["Accounts"]
  node_login["Login screen<br/>[LoginScreen.tsx]"]
  node_register["Registration screen<br/>[RegisterScreen.tsx]"]
  node_authsvc["Authentication<br/>[authService.ts]"]
end

subgraph group_settings["Preferences"]
  node_settingsscreen["Settings screen<br/>[SettingsScreen.tsx]"]
  node_settingssvc["Settings service<br/>[settingsService.ts]"]
  node_theme["Theme context<br/>[ThemeContext.tsx]"]
end

node_user(("App user"))
node_device(("Monitor device"))
node_auth(("Firebase Auth"))
node_location(("Device location"))
node_phone(("Phone messaging"))

node_user -->|"opens"| node_app
node_app -->|"starts monitoring"| node_controller
node_app -->|"renders"| node_nav
node_app -->|"provides theme"| node_theme
node_user -->|"navigates"| node_nav
node_nav -->|"dispatches"| node_dashboard
node_nav -->|"dispatches"| node_historyscreen
node_nav -->|"dispatches"| node_settingsscreen
node_nav -->|"dispatches"| node_login
node_nav -->|"dispatches"| node_register
node_controller -->|"loads settings"| node_settingssvc
node_controller -->|"subscribes"| node_health
node_health -.->|"receives measurements"| node_device
node_controller -->|"updates state"| node_healthstate
node_dashboard -->|"reads state"| node_healthstate
node_controller -->|"saves alerts"| node_alertsvc
node_controller -->|"deletes expired records"| node_historysvc
node_controller -->|"requests location"| node_location
node_controller -->|"opens SMS and dialer"| node_phone
node_alertlog -->|"subscribes alerts"| node_alertsvc
node_alertsvc -->|"reads and writes"| node_database
node_historysvc -->|"reads and writes"| node_database
node_settingssvc -.->|"accesses settings"| node_database
node_report -.->|"shares PDF"| node_phone
node_login -.->|"requests sign-in"| node_authsvc
node_register -.->|"requests registration"| node_authsvc
node_authsvc -->|"authenticates"| node_auth
node_settingsscreen -.->|"manages preferences"| node_settingssvc

click node_app "https://github.com/congminhvt2003/healthymonitor/blob/main/App.tsx"
click node_nav "https://github.com/congminhvt2003/healthymonitor/blob/main/src/navigation/AppNavigator.tsx"
click node_dashboard "https://github.com/congminhvt2003/healthymonitor/blob/main/src/screens/DashboardScreen.tsx"
click node_controller "https://github.com/congminhvt2003/healthymonitor/blob/main/src/services/HeartMonitorController.ts"
click node_health "https://github.com/congminhvt2003/healthymonitor/blob/main/src/services/healthService.ts"
click node_healthstate "https://github.com/congminhvt2003/healthymonitor/blob/main/src/store/useHealthStore.ts"
click node_thresholds "https://github.com/congminhvt2003/healthymonitor/blob/main/src/utils/healthAnalysis.ts"
click node_alertsvc "https://github.com/congminhvt2003/healthymonitor/blob/main/src/services/alertService.ts"
click node_alertlog "https://github.com/congminhvt2003/healthymonitor/blob/main/src/components/AlertLog.tsx"
click node_historyscreen "https://github.com/congminhvt2003/healthymonitor/blob/main/src/screens/HistoryScreen.tsx"
click node_historysvc "https://github.com/congminhvt2003/healthymonitor/blob/main/src/services/historyService.ts"
click node_report "https://github.com/congminhvt2003/healthymonitor/blob/main/src/services/reportService.ts"
click node_database "https://github.com/congminhvt2003/healthymonitor/blob/main/src/config/firebase.ts"
click node_settingsscreen "https://github.com/congminhvt2003/healthymonitor/blob/main/src/screens/SettingsScreen.tsx"
click node_settingssvc "https://github.com/congminhvt2003/healthymonitor/blob/main/src/services/settingsService.ts"
click node_theme "https://github.com/congminhvt2003/healthymonitor/blob/main/src/theme/ThemeContext.tsx"
click node_login "https://github.com/congminhvt2003/healthymonitor/blob/main/src/screens/LoginScreen.tsx"
click node_register "https://github.com/congminhvt2003/healthymonitor/blob/main/src/screens/RegisterScreen.tsx"
click node_authsvc "https://github.com/congminhvt2003/healthymonitor/blob/main/src/services/authService.ts"

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_nav,node_user toneBlue
class node_dashboard,node_controller,node_health,node_healthstate,node_thresholds toneAmber
class node_alertsvc,node_alertlog,node_historyscreen,node_historysvc,node_report,node_database toneMint
class node_login,node_register,node_authsvc toneRose
class node_settingsscreen,node_settingssvc,node_theme,node_device,node_auth,node_location,node_phone toneIndigo
```

## Components

### App shell

- [App entry](https://github.com/congminhvt2003/healthymonitor/blob/main/App.tsx): `App.tsx`
- [Navigation](https://github.com/congminhvt2003/healthymonitor/blob/main/src/navigation/AppNavigator.tsx): `src/navigation/AppNavigator.tsx`

### Live monitoring

- [Live dashboard](https://github.com/congminhvt2003/healthymonitor/blob/main/src/screens/DashboardScreen.tsx): `src/screens/DashboardScreen.tsx`
- [Monitor controller](https://github.com/congminhvt2003/healthymonitor/blob/main/src/services/HeartMonitorController.ts): `src/services/HeartMonitorController.ts`
- [Health feed](https://github.com/congminhvt2003/healthymonitor/blob/main/src/services/healthService.ts): `src/services/healthService.ts`
- [Health state](https://github.com/congminhvt2003/healthymonitor/blob/main/src/store/useHealthStore.ts): `src/store/useHealthStore.ts`
- [Health analysis](https://github.com/congminhvt2003/healthymonitor/blob/main/src/utils/healthAnalysis.ts): `src/utils/healthAnalysis.ts`

### Health records

- [Alert service](https://github.com/congminhvt2003/healthymonitor/blob/main/src/services/alertService.ts): `src/services/alertService.ts`
- [Alert log](https://github.com/congminhvt2003/healthymonitor/blob/main/src/components/AlertLog.tsx): `src/components/AlertLog.tsx`
- [History screen](https://github.com/congminhvt2003/healthymonitor/blob/main/src/screens/HistoryScreen.tsx): `src/screens/HistoryScreen.tsx`
- [History service](https://github.com/congminhvt2003/healthymonitor/blob/main/src/services/historyService.ts): `src/services/historyService.ts`
- [PDF reports](https://github.com/congminhvt2003/healthymonitor/blob/main/src/services/reportService.ts): `src/services/reportService.ts`
- [Firebase database](https://github.com/congminhvt2003/healthymonitor/blob/main/src/config/firebase.ts): `src/config/firebase.ts`

### Accounts

- [Login screen](https://github.com/congminhvt2003/healthymonitor/blob/main/src/screens/LoginScreen.tsx): `src/screens/LoginScreen.tsx`
- [Registration screen](https://github.com/congminhvt2003/healthymonitor/blob/main/src/screens/RegisterScreen.tsx): `src/screens/RegisterScreen.tsx`
- [Authentication](https://github.com/congminhvt2003/healthymonitor/blob/main/src/services/authService.ts): `src/services/authService.ts`

### Preferences

- [Settings screen](https://github.com/congminhvt2003/healthymonitor/blob/main/src/screens/SettingsScreen.tsx): `src/screens/SettingsScreen.tsx`
- [Settings service](https://github.com/congminhvt2003/healthymonitor/blob/main/src/services/settingsService.ts): `src/services/settingsService.ts`
- [Theme context](https://github.com/congminhvt2003/healthymonitor/blob/main/src/theme/ThemeContext.tsx): `src/theme/ThemeContext.tsx`

### Other components

- **App user**
- **Monitor device**
- **Firebase Auth**
- **Device location**
- **Phone messaging**

## Connections

- App user → App entry: opens
- App entry → Monitor controller: starts monitoring
- App entry → Navigation: renders
- App entry → Theme context: provides theme
- App user → Navigation: navigates
- Navigation → Live dashboard: dispatches
- Navigation → History screen: dispatches
- Navigation → Settings screen: dispatches
- Navigation → Login screen: dispatches
- Navigation → Registration screen: dispatches
- Monitor controller → Settings service: loads settings
- Monitor controller → Health feed: subscribes
- Health feed → Monitor device: receives measurements
- Monitor controller → Health state: updates state
- Live dashboard → Health state: reads state
- Monitor controller → Alert service: saves alerts
- Monitor controller → History service: deletes expired records
- Monitor controller → Device location: requests location
- Monitor controller → Phone messaging: opens SMS and dialer
- Alert log → Alert service: subscribes alerts
- Alert service → Firebase database: reads and writes
- History service → Firebase database: reads and writes
- Settings service → Firebase database: accesses settings
- PDF reports → Phone messaging: shares PDF
- Login screen → Authentication: requests sign-in
- Registration screen → Authentication: requests registration
- Authentication → Firebase Auth: authenticates
- Settings screen → Settings service: manages preferences
