# sadatsahaf/herv1. architecture

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

- Interactive diagram: https://gitdiagram.com/sadatsahaf/herv1.
- Repository: https://github.com/sadatsahaf/herv1.

## Overview

HERCULES is a React caregiver dashboard for monitoring patients’ safety. The main workflow is caregiver sign-in, loading patient and alert data, reviewing status and location, and responding with notes, resolved alerts, or on-demand AI insights. The README also documents device management and settings; these are represented within the root app because the sampled sources do not identify separate implementations. Map and chart behavior is partly simulated; wearable ingestion and automated alert generation are not evidenced in the sampled code.

Main entry points: [`App.tsx`](https://github.com/sadatsahaf/herv1./blob/main/App.tsx) (App Views and State), [`services/authService.ts`](https://github.com/sadatsahaf/herv1./blob/main/services/authService.ts) (Authentication), [`services/dataService.ts`](https://github.com/sadatsahaf/herv1./blob/main/services/dataService.ts) (Patient and Alert Data), [`firebaseConfig.ts`](https://github.com/sadatsahaf/herv1./blob/main/firebaseConfig.ts) (Firebase Setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Caregiver Dashboard"]
  node_entry["React Entry<br/>[index.tsx]"]
  node_app["App Views and State<br/>[App.tsx]"]
  node_alerts["Alert Center<br/>[App.tsx]"]
  node_devices_settings["Devices and Settings<br/>[App.tsx]"]
end

subgraph group_monitoring["Patient Monitoring"]
  node_patient_card["Patient Summary<br/>[PatientCard.tsx]"]
  node_threat_badge["Threat Status<br/>[ThreatBadge.tsx]"]
  node_map["Map and Geofences<br/>[MapWidget.tsx]"]
  node_notes["Care Notes<br/>[NotesWidget.tsx]"]
  node_vitals["Vitals Charts<br/>[VitalsChart.tsx]"]
  node_patient["Selected Patient"]
end

subgraph group_identity_data["Identity and Data"]
  node_auth_service["Authentication<br/>[authService.ts]"]
  node_firebase_config["Firebase Setup<br/>[firebaseConfig.ts]"]
  node_data_service["Patient and Alert Data<br/>[dataService.ts]"]
  node_firestore[("Firestore")]
  node_firebase_auth["Firebase Authentication"]
  node_domain_types["Domain Types<br/>[types.ts]"]
  node_seed_data["Demo Seed Data<br/>[constants.tsx]"]
end

subgraph group_insights["AI Insights"]
  node_ai_service["Patient Analysis<br/>[geminiService.ts]"]
  node_gemini["Google Gemini"]
end

node_caregiver(("Caregiver"))

node_caregiver -->|"opens"| node_entry
node_entry -->|"renders"| node_app
node_app -->|"handles auth"| node_auth_service
node_auth_service -->|"authenticates"| node_firebase_auth
node_auth_service -->|"reads and writes profiles"| node_firestore
node_app -->|"loads and updates"| node_data_service
node_data_service -->|"subscribes and writes"| node_firestore
node_data_service -->|"seeds records"| node_seed_data
node_auth_service -->|"uses clients"| node_firebase_config
node_data_service -->|"uses client"| node_firebase_config
node_firebase_config -->|"initializes"| node_firebase_auth
node_firebase_config -->|"initializes"| node_firestore
node_app -->|"manages"| node_alerts
node_app -.->|"presents"| node_devices_settings
node_app -->|"renders"| node_patient_card
node_patient_card -->|"renders"| node_threat_badge
node_app -->|"renders"| node_map
node_app -->|"renders"| node_notes
node_app -->|"renders"| node_vitals
node_app -->|"requests analysis"| node_ai_service
node_ai_service -->|"generates analysis"| node_gemini
node_app -->|"selects and displays"| node_patient
node_patient -->|"provides location history"| node_map
node_patient -->|"provides note history"| node_notes
node_patient -->|"provides status data"| node_ai_service
node_app -->|"uses domain models"| node_domain_types

click node_entry "https://github.com/sadatsahaf/herv1./blob/main/index.tsx"
click node_app "https://github.com/sadatsahaf/herv1./blob/main/App.tsx"
click node_alerts "https://github.com/sadatsahaf/herv1./blob/main/App.tsx"
click node_devices_settings "https://github.com/sadatsahaf/herv1./blob/main/App.tsx"
click node_patient_card "https://github.com/sadatsahaf/herv1./blob/main/components/PatientCard.tsx"
click node_threat_badge "https://github.com/sadatsahaf/herv1./blob/main/components/ThreatBadge.tsx"
click node_map "https://github.com/sadatsahaf/herv1./blob/main/components/MapWidget.tsx"
click node_notes "https://github.com/sadatsahaf/herv1./blob/main/components/NotesWidget.tsx"
click node_vitals "https://github.com/sadatsahaf/herv1./blob/main/components/VitalsChart.tsx"
click node_auth_service "https://github.com/sadatsahaf/herv1./blob/main/services/authService.ts"
click node_firebase_config "https://github.com/sadatsahaf/herv1./blob/main/firebaseConfig.ts"
click node_data_service "https://github.com/sadatsahaf/herv1./blob/main/services/dataService.ts"
click node_domain_types "https://github.com/sadatsahaf/herv1./blob/main/types.ts"
click node_seed_data "https://github.com/sadatsahaf/herv1./blob/main/constants.tsx"
click node_ai_service "https://github.com/sadatsahaf/herv1./blob/main/services/geminiService.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_entry,node_app,node_alerts,node_devices_settings toneBlue
class node_patient_card,node_threat_badge,node_map,node_notes,node_vitals,node_patient toneAmber
class node_auth_service,node_firebase_config,node_data_service,node_firestore,node_firebase_auth,node_domain_types,node_seed_data toneMint
class node_ai_service,node_gemini toneRose
class node_caregiver toneIndigo
```

## Components

### Caregiver Dashboard

- [React Entry](https://github.com/sadatsahaf/herv1./blob/main/index.tsx): `index.tsx`
- [App Views and State](https://github.com/sadatsahaf/herv1./blob/main/App.tsx): `App.tsx`
- [Alert Center](https://github.com/sadatsahaf/herv1./blob/main/App.tsx): `App.tsx`
- [Devices and Settings](https://github.com/sadatsahaf/herv1./blob/main/App.tsx): `App.tsx`

### Patient Monitoring

- [Patient Summary](https://github.com/sadatsahaf/herv1./blob/main/components/PatientCard.tsx): `components/PatientCard.tsx`
- [Threat Status](https://github.com/sadatsahaf/herv1./blob/main/components/ThreatBadge.tsx): `components/ThreatBadge.tsx`
- [Map and Geofences](https://github.com/sadatsahaf/herv1./blob/main/components/MapWidget.tsx): `components/MapWidget.tsx`
- [Care Notes](https://github.com/sadatsahaf/herv1./blob/main/components/NotesWidget.tsx): `components/NotesWidget.tsx`
- [Vitals Charts](https://github.com/sadatsahaf/herv1./blob/main/components/VitalsChart.tsx): `components/VitalsChart.tsx`
- **Selected Patient**

### Identity and Data

- [Authentication](https://github.com/sadatsahaf/herv1./blob/main/services/authService.ts): `services/authService.ts`
- [Firebase Setup](https://github.com/sadatsahaf/herv1./blob/main/firebaseConfig.ts): `firebaseConfig.ts`
- [Patient and Alert Data](https://github.com/sadatsahaf/herv1./blob/main/services/dataService.ts): `services/dataService.ts`
- **Firestore**
- **Firebase Authentication**
- [Domain Types](https://github.com/sadatsahaf/herv1./blob/main/types.ts): `types.ts`
- [Demo Seed Data](https://github.com/sadatsahaf/herv1./blob/main/constants.tsx): `constants.tsx`

### AI Insights

- [Patient Analysis](https://github.com/sadatsahaf/herv1./blob/main/services/geminiService.ts): `services/geminiService.ts`
- **Google Gemini**

### Other components

- **Caregiver**

## Connections

- Caregiver → React Entry: opens (evidence: `README.md`)
- React Entry → App Views and State: renders (evidence: `index.tsx`)
- App Views and State → Authentication: handles auth (evidence: `App.tsx`)
- Authentication → Firebase Authentication: authenticates (evidence: `services/authService.ts`)
- Authentication → Firestore: reads and writes profiles (evidence: `services/authService.ts`)
- App Views and State → Patient and Alert Data: loads and updates (evidence: `App.tsx`)
- Patient and Alert Data → Firestore: subscribes and writes (evidence: `services/dataService.ts`)
- Patient and Alert Data → Demo Seed Data: seeds records (evidence: `services/dataService.ts`)
- Authentication → Firebase Setup: uses clients (evidence: `services/authService.ts`)
- Patient and Alert Data → Firebase Setup: uses client (evidence: `services/dataService.ts`)
- Firebase Setup → Firebase Authentication: initializes (evidence: `firebaseConfig.ts`)
- Firebase Setup → Firestore: initializes (evidence: `firebaseConfig.ts`)
- App Views and State → Alert Center: manages (evidence: `App.tsx`)
- App Views and State → Devices and Settings: presents (evidence: `README.md`)
- App Views and State → Patient Summary: renders (evidence: `App.tsx`)
- Patient Summary → Threat Status: renders (evidence: `components/PatientCard.tsx`)
- App Views and State → Map and Geofences: renders (evidence: `App.tsx`)
- App Views and State → Care Notes: renders (evidence: `App.tsx`)
- App Views and State → Vitals Charts: renders (evidence: `App.tsx`)
- App Views and State → Patient Analysis: requests analysis (evidence: `App.tsx`)
- Patient Analysis → Google Gemini: generates analysis (evidence: `services/geminiService.ts`)
- App Views and State → Selected Patient: selects and displays (evidence: `App.tsx`)
- Selected Patient → Map and Geofences: provides location history
- Selected Patient → Care Notes: provides note history
- Selected Patient → Patient Analysis: provides status data
- App Views and State → Domain Types: uses domain models (evidence: `App.tsx`)
