# cdb26/emergensave-pub architecture

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

## Overview

EmergenSave coordinates emergency response across patients, dispatchers, ambulance responders, and hospitals, with separate patient-care and administrative features. The main documented flow is emergency request, dispatcher review and assignment, responder status/location updates, then hospital preparation with triage information. Firebase provides the documented real-time shared state; authentication guards form an internal access-control layer. Paths and connections for some features are based on the README and tree because their source was not sampled; the tree does not include the README-mentioned doctorPanel directory.

Main entry points: [`app/onAction/[facilityId]/[dispatchId]/page.tsx`](https://github.com/cdb26/emergensave-pub/blob/main/app/onAction/%5BfacilityId%5D/%5BdispatchId%5D/page.tsx) (Active Case), [`app/voicecall/page.tsx`](https://github.com/cdb26/emergensave-pub/blob/main/app/voicecall/page.tsx) (Live Voice Call), [`app/dispatchPanel/page.tsx`](https://github.com/cdb26/emergensave-pub/blob/main/app/dispatchPanel/page.tsx) (Dispatch Queue), [`app/ambuPanel/page.tsx`](https://github.com/cdb26/emergensave-pub/blob/main/app/ambuPanel/page.tsx) (Responder Dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_emergency["Emergency Response"]
  node_patient_emergency["Emergency Request<br/>[page.tsx]"]
  node_dispatch_queue["Dispatch Queue<br/>[page.tsx]"]
  node_responder_dispatch["Responder Dispatch<br/>[page.tsx]"]
  node_active_case["Active Case<br/>[page.tsx]"]
  node_voice_call["Live Voice Call<br/>[page.tsx]"]
end

subgraph group_care["Patient Care"]
  node_appointments["Appointments<br/>[page.tsx]"]
  node_medical_record["Medical History<br/>[page.tsx]"]
  node_profile["Patient Profile<br/>[page.tsx]"]
end

subgraph group_operations["Hospital Operations"]
  node_urgent_cases["Urgent Cases"]
  node_triage["Triage Notes<br/>[triage.tsx]"]
  node_hospital_management["Hospital Management<br/>[page.tsx]"]
  node_admin["Admin Oversight<br/>[page.tsx]"]
end

subgraph group_access["Identity and Access"]
  node_auth_guards["Role Guards"]
end

node_patient(("Patient"))
node_dispatcher(("Dispatcher"))
node_ambulance(("Ambulance Responder"))
node_hospital(("Receiving Hospital"))
node_firebase[("Firebase Services")]
node_maps["Google Maps"]
node_agora["Agora Calling"]

node_patient -->|"triggers"| node_patient_emergency
node_patient_emergency -->|"stores request"| node_firebase
node_firebase -->|"updates live"| node_dispatch_queue
node_dispatcher -->|"reviews"| node_dispatch_queue
node_dispatch_queue -->|"assigns case"| node_responder_dispatch
node_ambulance -->|"receives case"| node_responder_dispatch
node_responder_dispatch -->|"opens case"| node_active_case
node_active_case -->|"updates status"| node_firebase
node_active_case -.->|"shows location"| node_maps
node_firebase -->|"updates live"| node_urgent_cases
node_urgent_cases -->|"alerts"| node_hospital
node_active_case -->|"shares notes"| node_triage
node_dispatcher -.->|"initiates call"| node_voice_call
node_ambulance -.->|"initiates call"| node_voice_call
node_voice_call -.->|"connects"| node_patient
node_voice_call -.->|"uses RTC"| node_agora
node_patient -->|"books"| node_appointments
node_patient -->|"manages history"| node_medical_record
node_patient -->|"manages profile"| node_profile
node_hospital_management -->|"manages"| node_appointments
node_hospital_management -->|"manages"| node_urgent_cases
node_admin -->|"oversees records"| node_firebase
node_auth_guards -->|"checks identity"| node_firebase

click node_patient_emergency "https://github.com/cdb26/emergensave-pub/blob/main/app/homepage/page.tsx"
click node_dispatch_queue "https://github.com/cdb26/emergensave-pub/blob/main/app/dispatchPanel/page.tsx"
click node_responder_dispatch "https://github.com/cdb26/emergensave-pub/blob/main/app/ambuPanel/page.tsx"
click node_active_case "https://github.com/cdb26/emergensave-pub/blob/main/app/onAction/%5BfacilityId%5D/%5BdispatchId%5D/page.tsx"
click node_urgent_cases "https://github.com/cdb26/emergensave-pub/blob/main/app/hospitalPanel/components/UrgentCasesDashboard.tsx"
click node_triage "https://github.com/cdb26/emergensave-pub/blob/main/app/adminPanel/triage.tsx"
click node_voice_call "https://github.com/cdb26/emergensave-pub/blob/main/app/voicecall/page.tsx"
click node_appointments "https://github.com/cdb26/emergensave-pub/blob/main/app/medSched/page.tsx"
click node_medical_record "https://github.com/cdb26/emergensave-pub/blob/main/app/medRec/page.tsx"
click node_profile "https://github.com/cdb26/emergensave-pub/blob/main/app/profile/page.tsx"
click node_hospital_management "https://github.com/cdb26/emergensave-pub/blob/main/app/hospitalPanel/page.tsx"
click node_admin "https://github.com/cdb26/emergensave-pub/blob/main/app/adminPanel/page.tsx"
click node_auth_guards "https://github.com/cdb26/emergensave-pub/tree/main/components/Auth"

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_patient_emergency,node_dispatch_queue,node_responder_dispatch,node_active_case,node_voice_call toneBlue
class node_appointments,node_medical_record,node_profile,node_firebase toneAmber
class node_urgent_cases,node_triage,node_hospital_management,node_admin toneMint
class node_auth_guards toneRose
class node_patient,node_dispatcher,node_ambulance,node_hospital,node_maps,node_agora toneIndigo
```

## Components

### Emergency Response

- [Emergency Request](https://github.com/cdb26/emergensave-pub/blob/main/app/homepage/page.tsx): `app/homepage/page.tsx`
- [Dispatch Queue](https://github.com/cdb26/emergensave-pub/blob/main/app/dispatchPanel/page.tsx): `app/dispatchPanel/page.tsx`
- [Responder Dispatch](https://github.com/cdb26/emergensave-pub/blob/main/app/ambuPanel/page.tsx): `app/ambuPanel/page.tsx`
- [Active Case](https://github.com/cdb26/emergensave-pub/blob/main/app/onAction/%5BfacilityId%5D/%5BdispatchId%5D/page.tsx): `app/onAction/[facilityId]/[dispatchId]/page.tsx`
- [Live Voice Call](https://github.com/cdb26/emergensave-pub/blob/main/app/voicecall/page.tsx): `app/voicecall/page.tsx`

### Patient Care

- [Appointments](https://github.com/cdb26/emergensave-pub/blob/main/app/medSched/page.tsx): `app/medSched/page.tsx`
- [Medical History](https://github.com/cdb26/emergensave-pub/blob/main/app/medRec/page.tsx): `app/medRec/page.tsx`
- [Patient Profile](https://github.com/cdb26/emergensave-pub/blob/main/app/profile/page.tsx): `app/profile/page.tsx`

### Hospital Operations

- [Urgent Cases](https://github.com/cdb26/emergensave-pub/blob/main/app/hospitalPanel/components/UrgentCasesDashboard.tsx): `app/hospitalPanel/components/UrgentCasesDashboard.tsx`
- [Triage Notes](https://github.com/cdb26/emergensave-pub/blob/main/app/adminPanel/triage.tsx): `app/adminPanel/triage.tsx`
- [Hospital Management](https://github.com/cdb26/emergensave-pub/blob/main/app/hospitalPanel/page.tsx): `app/hospitalPanel/page.tsx`
- [Admin Oversight](https://github.com/cdb26/emergensave-pub/blob/main/app/adminPanel/page.tsx): `app/adminPanel/page.tsx`

### Identity and Access

- [Role Guards](https://github.com/cdb26/emergensave-pub/tree/main/components/Auth): `components/Auth`

### Other components

- **Patient**
- **Dispatcher**
- **Ambulance Responder**
- **Receiving Hospital**
- **Firebase Services**
- **Google Maps**
- **Agora Calling**

## Connections

- Patient → Emergency Request: triggers
- Emergency Request → Firebase Services: stores request
- Firebase Services → Dispatch Queue: updates live
- Dispatcher → Dispatch Queue: reviews
- Dispatch Queue → Responder Dispatch: assigns case
- Ambulance Responder → Responder Dispatch: receives case
- Responder Dispatch → Active Case: opens case
- Active Case → Firebase Services: updates status
- Active Case → Google Maps: shows location
- Firebase Services → Urgent Cases: updates live
- Urgent Cases → Receiving Hospital: alerts
- Active Case → Triage Notes: shares notes
- Dispatcher → Live Voice Call: initiates call
- Ambulance Responder → Live Voice Call: initiates call
- Live Voice Call → Patient: connects
- Live Voice Call → Agora Calling: uses RTC
- Patient → Appointments: books
- Patient → Medical History: manages history
- Patient → Patient Profile: manages profile
- Hospital Management → Appointments: manages
- Hospital Management → Urgent Cases: manages
- Admin Oversight → Firebase Services: oversees records
- Role Guards → Firebase Services: checks identity
