# sahildhatwalia/pulseflow architecture

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

- Interactive diagram: https://gitdiagram.com/sahildhatwalia/pulseflow
- Repository: https://github.com/sahildhatwalia/pulseflow

## Overview

PulseFlow is an emergency-department intake, triage, and patient-flow application. Patients check in through a kiosk or staff intake; clinicians assess acuity, optionally request an AI ESI prediction, and manage room assignments or priority overrides. The server maintains queue state and recalculates priorities and wait estimates, then synchronizes updates to staff and public displays. The README also documents analytics and HIPAA-conscious public views. Server and UI excerpts are partial, so links for unsampled endpoint and view behavior are limited to documented capabilities.

Main entry points: [`client/src/App.jsx`](https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/App.jsx) (Application shell), [`server/src/server.js`](https://github.com/sahildhatwalia/pulseflow/blob/main/server/src/server.js) (Express API), [`server/src/db.js`](https://github.com/sahildhatwalia/pulseflow/blob/main/server/src/db.js) (Hospital state), [`client/src/components/StaffTriageView.jsx`](https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/components/StaffTriageView.jsx) (Staff triage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Clinical and Public UI"]
  node_app["Application shell<br/>[App.jsx]"]
  node_intake["Patient intake"]
  node_triage["Staff triage"]
  node_override["Priority override"]
  node_publicdisplay["Public queue display"]
  node_banner["Patient call banner"]
  node_analyticsview["Analytics dashboard<br/>[AnalyticsView.jsx]"]
  node_hipaaview["Privacy display"]
  node_api["HTTP client<br/>[api.js]"]
  node_socketclient["Realtime client<br/>[socket.js]"]
end

subgraph group_server["API and Coordination"]
  node_http["Express API<br/>[server.js]"]
  node_socketserver["Socket.IO server<br/>[server.js]"]
end

subgraph group_flow["Queue and Clinical Flow"]
  node_ai["AI triage<br/>[ai.js]"]
  node_prediction["Queue prediction"]
  node_db[("Hospital state<br/>[db.js]")]
end

subgraph group_compliance["Privacy and Analytics"]
  node_hipaa["PHI protection<br/>[hipaa.js]"]
  node_analytics["Throughput metrics<br/>[db.js]"]
end

node_patient(("Patient"))
node_staff(("Clinical staff"))
node_admin(("Administrator"))

node_patient -->|"checks in"| node_intake
node_staff -->|"assesses"| node_triage
node_admin -->|"sets override"| node_override
node_intake -->|"submits intake"| node_app
node_triage -->|"updates status"| node_app
node_override -->|"requests override"| node_app
node_app -->|"calls API"| node_api
node_api -->|"HTTP requests"| node_http
node_http -->|"reads and updates"| node_db
node_http -->|"requests prediction"| node_ai
node_ai -->|"returns ESI"| node_http
node_db -->|"recalculates queue"| node_prediction
node_db -->|"creates tokens"| node_hipaa
node_http -->|"sanitizes public data"| node_hipaa
node_http -->|"broadcasts updates"| node_socketserver
node_socketserver -->|"pushes events"| node_socketclient
node_socketclient -->|"delivers events"| node_app
node_app -->|"renders view"| node_publicdisplay
node_app -->|"renders view"| node_triage
node_app -->|"renders view"| node_override
node_app -->|"renders view"| node_banner
node_app -->|"renders view"| node_analyticsview
node_app -->|"renders view"| node_hipaaview
node_patient -->|"views queue"| node_publicdisplay
node_db -->|"provides metrics"| node_analytics
node_analyticsview -->|"fetches analytics"| node_api
node_hipaaview -->|"displays privacy view"| node_app

click node_app "https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/App.jsx"
click node_intake "https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/components/PatientDisplayView.jsx"
click node_triage "https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/components/StaffTriageView.jsx"
click node_override "https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/components/AdminOverrideView.jsx"
click node_publicdisplay "https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/components/PatientDisplayView.jsx"
click node_banner "https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/components/PatientCallBanner.jsx"
click node_analyticsview "https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/components/AnalyticsView.jsx"
click node_hipaaview "https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/components/HipaaComplianceView.jsx"
click node_api "https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/services/api.js"
click node_socketclient "https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/services/socket.js"
click node_http "https://github.com/sahildhatwalia/pulseflow/blob/main/server/src/server.js"
click node_socketserver "https://github.com/sahildhatwalia/pulseflow/blob/main/server/src/server.js"
click node_ai "https://github.com/sahildhatwalia/pulseflow/blob/main/server/src/ai.js"
click node_prediction "https://github.com/sahildhatwalia/pulseflow/blob/main/server/src/predictionEngine.js"
click node_db "https://github.com/sahildhatwalia/pulseflow/blob/main/server/src/db.js"
click node_hipaa "https://github.com/sahildhatwalia/pulseflow/blob/main/server/src/hipaa.js"
click node_analytics "https://github.com/sahildhatwalia/pulseflow/blob/main/server/src/db.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_intake,node_triage,node_override,node_publicdisplay,node_banner,node_analyticsview,node_hipaaview,node_api,node_socketclient toneBlue
class node_http,node_socketserver toneAmber
class node_ai,node_prediction,node_db toneMint
class node_hipaa,node_analytics toneRose
class node_patient,node_staff,node_admin toneIndigo
```

## Components

### Clinical and Public UI

- [Application shell](https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Patient intake](https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/components/PatientDisplayView.jsx): `client/src/components/PatientDisplayView.jsx`
- [Staff triage](https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/components/StaffTriageView.jsx): `client/src/components/StaffTriageView.jsx`
- [Priority override](https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/components/AdminOverrideView.jsx): `client/src/components/AdminOverrideView.jsx`
- [Public queue display](https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/components/PatientDisplayView.jsx): `client/src/components/PatientDisplayView.jsx`
- [Patient call banner](https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/components/PatientCallBanner.jsx): `client/src/components/PatientCallBanner.jsx`
- [Analytics dashboard](https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/components/AnalyticsView.jsx): `client/src/components/AnalyticsView.jsx`
- [Privacy display](https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/components/HipaaComplianceView.jsx): `client/src/components/HipaaComplianceView.jsx`
- [HTTP client](https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/services/api.js): `client/src/services/api.js`
- [Realtime client](https://github.com/sahildhatwalia/pulseflow/blob/main/client/src/services/socket.js): `client/src/services/socket.js`

### API and Coordination

- [Express API](https://github.com/sahildhatwalia/pulseflow/blob/main/server/src/server.js): `server/src/server.js`
- [Socket.IO server](https://github.com/sahildhatwalia/pulseflow/blob/main/server/src/server.js): `server/src/server.js`

### Queue and Clinical Flow

- [AI triage](https://github.com/sahildhatwalia/pulseflow/blob/main/server/src/ai.js): `server/src/ai.js`
- [Queue prediction](https://github.com/sahildhatwalia/pulseflow/blob/main/server/src/predictionEngine.js): `server/src/predictionEngine.js`
- [Hospital state](https://github.com/sahildhatwalia/pulseflow/blob/main/server/src/db.js): `server/src/db.js`

### Privacy and Analytics

- [PHI protection](https://github.com/sahildhatwalia/pulseflow/blob/main/server/src/hipaa.js): `server/src/hipaa.js`
- [Throughput metrics](https://github.com/sahildhatwalia/pulseflow/blob/main/server/src/db.js): `server/src/db.js`

### Other components

- **Patient**
- **Clinical staff**
- **Administrator**

## Connections

- Patient → Patient intake: checks in
- Clinical staff → Staff triage: assesses
- Administrator → Priority override: sets override
- Patient intake → Application shell: submits intake
- Staff triage → Application shell: updates status
- Priority override → Application shell: requests override
- Application shell → HTTP client: calls API
- HTTP client → Express API: HTTP requests
- Express API → Hospital state: reads and updates
- Express API → AI triage: requests prediction
- AI triage → Express API: returns ESI
- Hospital state → Queue prediction: recalculates queue
- Hospital state → PHI protection: creates tokens
- Express API → PHI protection: sanitizes public data
- Express API → Socket.IO server: broadcasts updates
- Socket.IO server → Realtime client: pushes events
- Realtime client → Application shell: delivers events
- Application shell → Public queue display: renders view
- Application shell → Staff triage: renders view
- Application shell → Priority override: renders view
- Application shell → Patient call banner: renders view
- Application shell → Analytics dashboard: renders view
- Application shell → Privacy display: renders view
- Patient → Public queue display: views queue
- Hospital state → Throughput metrics: provides metrics
- Analytics dashboard → HTTP client: fetches analytics
- Privacy display → Application shell: displays privacy view
