# subashkandasamy/hsm architecture

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

- Interactive diagram: https://gitdiagram.com/subashkandasamy/hsm
- Repository: https://github.com/subashkandasamy/hsm

## Overview

Uyirly appears to be a hospital-management web application, accompanied by a separately run lab/radiology connector. The likely hospital workflow spans patient registration, outpatient/inpatient care, diagnostics, pharmacy and billing; the tree also shows distinct emergency, blood-bank, insurance and compliance capabilities. A useful internal layer is the server-action/API boundary backed by Supabase. The README is only the Next.js starter README, so it does not document product workflows. Edges below are limited to relationships visible in excerpts or SOURCE INDEX references; unsampled product areas are represented without guessed call chains.

Main entry points: [`src/app/(dashboard)`](https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)) (Dashboard interface), [`connector/src/index.ts`](https://github.com/subashkandasamy/hsm/blob/main/connector/src/index.ts) (Connector runtime), [`src/lib/supabase/service.ts`](https://github.com/subashkandasamy/hsm/blob/main/src/lib/supabase/service.ts) (Supabase service), [`src/app/api`](https://github.com/subashkandasamy/hsm/tree/main/src/app/api) (Device and webhook APIs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_hospital["Hospital operations"]
  node_patients["Patient records"]
  node_appointments["Appointments"]
  node_pharmacy["Pharmacy<br/>[pharmacy.ts]"]
  node_inventory["Inventory"]
end

subgraph group_clinical["Clinical and diagnostics"]
  node_opd["Outpatient care"]
  node_ipd["Inpatient care"]
  node_emergency["Emergency care"]
  node_lab["Laboratory"]
  node_radiology["Radiology"]
  node_blood["Blood bank"]
end

subgraph group_finance["Finance and administration"]
  node_billing["Billing"]
  node_servicebill["Service billing<br/>[serviceBill.ts]"]
  node_insurance["Insurance claims<br/>[insurance.ts]"]
  node_accounts["Accounts"]
  node_pcpndt["PCPNDT compliance"]
end

subgraph group_platform["Web platform"]
  node_ui["Dashboard interface"]
  node_actions["Server actions"]
  node_api["Device and webhook APIs"]
  node_supabase[("Supabase service<br/>[service.ts]")]
end

subgraph group_connector["Device connector"]
  node_connector["Connector runtime<br/>[index.ts]"]
  node_transports["Device transports"]
  node_queue["Result queue<br/>[queue.ts]"]
  node_uploader["Result uploader<br/>[uploader.ts]"]
  node_dicom["DICOM server<br/>[server.ts]"]
  node_dicomdisk["DICOM disk watcher<br/>[disk.ts]"]
  node_connectorstorage["Connector storage<br/>[storage.ts]"]
  node_connectorlog["Connector logging<br/>[log.ts]"]
end

node_staff(("Hospital staff"))
node_cloud(("Uyirly cloud"))
node_razorpay(("Razorpay"))

node_staff -.->|"uses"| node_ui
node_ui -.->|"manages"| node_patients
node_ui -.->|"manages"| node_appointments
node_ui -.->|"manages"| node_opd
node_ui -.->|"manages"| node_ipd
node_ui -.->|"manages"| node_emergency
node_ui -.->|"manages"| node_lab
node_ui -.->|"manages"| node_radiology
node_ui -.->|"manages"| node_blood
node_ui -.->|"manages"| node_pharmacy
node_ui -.->|"manages"| node_inventory
node_ui -.->|"manages"| node_billing
node_ui -.->|"manages"| node_insurance
node_ui -.->|"manages"| node_accounts
node_ui -.->|"manages"| node_pcpndt
node_ui -.->|"invokes"| node_actions
node_api -->|"queries"| node_supabase
node_api -->|"queries"| node_supabase
node_razorpay -.->|"sends events"| node_api
node_billing -.->|"creates service bills"| node_servicebill
node_connector -->|"uses"| node_queue
node_connector -->|"starts"| node_uploader
node_connector -->|"starts"| node_transports
node_connector -->|"starts"| node_dicom
node_connector -->|"resolves"| node_connectorstorage
node_connector -->|"initializes"| node_connectorlog
node_dicom -->|"logs"| node_connectorlog
node_dicom -->|"scans"| node_connectorstorage
node_dicom -->|"uses"| node_dicomdisk
node_connector -.->|"uploads results"| node_cloud
node_lab -.->|"receives analyzer results"| node_api
node_api -.->|"stores parsed results"| node_supabase
node_actions -.->|"reads and writes"| node_supabase
node_servicebill -->|"writes bills"| node_supabase
node_servicebill -->|"reconciles bill"| node_billing
node_insurance -.->|"persists remittances"| node_supabase

click node_patients "https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/patients"
click node_appointments "https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/appointments"
click node_opd "https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/opd"
click node_ipd "https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/ipd"
click node_emergency "https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/emergency"
click node_lab "https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/lab"
click node_radiology "https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/radiology"
click node_blood "https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/blood"
click node_pharmacy "https://github.com/subashkandasamy/hsm/blob/main/src/app/actions/pharmacy.ts"
click node_inventory "https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/inventory"
click node_billing "https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/billing"
click node_servicebill "https://github.com/subashkandasamy/hsm/blob/main/src/lib/billing/serviceBill.ts"
click node_insurance "https://github.com/subashkandasamy/hsm/blob/main/src/app/actions/insurance.ts"
click node_accounts "https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/accounts"
click node_pcpndt "https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/pcpndt"
click node_ui "https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)"
click node_actions "https://github.com/subashkandasamy/hsm/tree/main/src/app/actions"
click node_api "https://github.com/subashkandasamy/hsm/tree/main/src/app/api"
click node_supabase "https://github.com/subashkandasamy/hsm/blob/main/src/lib/supabase/service.ts"
click node_connector "https://github.com/subashkandasamy/hsm/blob/main/connector/src/index.ts"
click node_transports "https://github.com/subashkandasamy/hsm/tree/main/connector/src/transports"
click node_queue "https://github.com/subashkandasamy/hsm/blob/main/connector/src/queue.ts"
click node_uploader "https://github.com/subashkandasamy/hsm/blob/main/connector/src/uploader.ts"
click node_dicom "https://github.com/subashkandasamy/hsm/blob/main/connector/src/dicom/server.ts"
click node_dicomdisk "https://github.com/subashkandasamy/hsm/blob/main/connector/src/dicom/disk.ts"
click node_connectorstorage "https://github.com/subashkandasamy/hsm/blob/main/connector/src/storage.ts"
click node_connectorlog "https://github.com/subashkandasamy/hsm/blob/main/connector/src/log.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_patients,node_appointments,node_pharmacy,node_inventory toneBlue
class node_opd,node_ipd,node_emergency,node_lab,node_radiology,node_blood toneAmber
class node_billing,node_servicebill,node_insurance,node_accounts,node_pcpndt toneMint
class node_ui,node_actions,node_api,node_supabase toneRose
class node_connector,node_transports,node_queue,node_uploader,node_dicom,node_dicomdisk,node_connectorstorage,node_connectorlog,node_staff,node_cloud,node_razorpay toneIndigo
```

## Components

### Hospital operations

- [Patient records](https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/patients): `src/app/(dashboard)/patients`
- [Appointments](https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/appointments): `src/app/(dashboard)/appointments`
- [Pharmacy](https://github.com/subashkandasamy/hsm/blob/main/src/app/actions/pharmacy.ts): `src/app/actions/pharmacy.ts`
- [Inventory](https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/inventory): `src/app/(dashboard)/inventory`

### Clinical and diagnostics

- [Outpatient care](https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/opd): `src/app/(dashboard)/opd`
- [Inpatient care](https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/ipd): `src/app/(dashboard)/ipd`
- [Emergency care](https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/emergency): `src/app/(dashboard)/emergency`
- [Laboratory](https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/lab): `src/app/(dashboard)/lab`
- [Radiology](https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/radiology): `src/app/(dashboard)/radiology`
- [Blood bank](https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/blood): `src/app/(dashboard)/blood`

### Finance and administration

- [Billing](https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/billing): `src/app/(dashboard)/billing`
- [Service billing](https://github.com/subashkandasamy/hsm/blob/main/src/lib/billing/serviceBill.ts): `src/lib/billing/serviceBill.ts`
- [Insurance claims](https://github.com/subashkandasamy/hsm/blob/main/src/app/actions/insurance.ts): `src/app/actions/insurance.ts`
- [Accounts](https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/accounts): `src/app/(dashboard)/accounts`
- [PCPNDT compliance](https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)/pcpndt): `src/app/(dashboard)/pcpndt`

### Web platform

- [Dashboard interface](https://github.com/subashkandasamy/hsm/tree/main/src/app/(dashboard)): `src/app/(dashboard)`
- [Server actions](https://github.com/subashkandasamy/hsm/tree/main/src/app/actions): `src/app/actions`
- [Device and webhook APIs](https://github.com/subashkandasamy/hsm/tree/main/src/app/api): `src/app/api`
- [Supabase service](https://github.com/subashkandasamy/hsm/blob/main/src/lib/supabase/service.ts): `src/lib/supabase/service.ts`

### Device connector

- [Connector runtime](https://github.com/subashkandasamy/hsm/blob/main/connector/src/index.ts): `connector/src/index.ts`
- [Device transports](https://github.com/subashkandasamy/hsm/tree/main/connector/src/transports): `connector/src/transports`
- [Result queue](https://github.com/subashkandasamy/hsm/blob/main/connector/src/queue.ts): `connector/src/queue.ts`
- [Result uploader](https://github.com/subashkandasamy/hsm/blob/main/connector/src/uploader.ts): `connector/src/uploader.ts`
- [DICOM server](https://github.com/subashkandasamy/hsm/blob/main/connector/src/dicom/server.ts): `connector/src/dicom/server.ts`
- [DICOM disk watcher](https://github.com/subashkandasamy/hsm/blob/main/connector/src/dicom/disk.ts): `connector/src/dicom/disk.ts`
- [Connector storage](https://github.com/subashkandasamy/hsm/blob/main/connector/src/storage.ts): `connector/src/storage.ts`
- [Connector logging](https://github.com/subashkandasamy/hsm/blob/main/connector/src/log.ts): `connector/src/log.ts`

### Other components

- **Hospital staff**
- **Uyirly cloud**
- **Razorpay**

## Connections

- Hospital staff → Dashboard interface: uses
- Dashboard interface → Patient records: manages
- Dashboard interface → Appointments: manages
- Dashboard interface → Outpatient care: manages
- Dashboard interface → Inpatient care: manages
- Dashboard interface → Emergency care: manages
- Dashboard interface → Laboratory: manages
- Dashboard interface → Radiology: manages
- Dashboard interface → Blood bank: manages
- Dashboard interface → Pharmacy: manages
- Dashboard interface → Inventory: manages
- Dashboard interface → Billing: manages
- Dashboard interface → Insurance claims: manages (evidence: `src/app/(dashboard)/insurance/_components/RemittanceManagerModal.tsx`)
- Dashboard interface → Accounts: manages
- Dashboard interface → PCPNDT compliance: manages
- Dashboard interface → Server actions: invokes (evidence: `src/app/(dashboard)/insurance/_components/RemittanceManagerModal.tsx`)
- Device and webhook APIs → Supabase service: queries (evidence: `src/app/api/device/files/route.ts`)
- Device and webhook APIs → Supabase service: queries (evidence: `src/app/api/webhooks/razorpay/route.ts`)
- Razorpay → Device and webhook APIs: sends events
- Billing → Service billing: creates service bills
- Connector runtime → Result queue: uses (evidence: `connector/src/index.ts`)
- Connector runtime → Result uploader: starts (evidence: `connector/src/index.ts`)
- Connector runtime → Device transports: starts (evidence: `connector/src/index.ts`)
- Connector runtime → DICOM server: starts (evidence: `connector/src/index.ts`)
- Connector runtime → Connector storage: resolves (evidence: `connector/src/index.ts`)
- Connector runtime → Connector logging: initializes (evidence: `connector/src/index.ts`)
- DICOM server → Connector logging: logs (evidence: `connector/src/dicom/server.ts`)
- DICOM server → Connector storage: scans (evidence: `connector/src/dicom/server.ts`)
- DICOM server → DICOM disk watcher: uses (evidence: `connector/src/dicom/server.ts`)
- Connector runtime → Uyirly cloud: uploads results
- Laboratory → Device and webhook APIs: receives analyzer results
- Device and webhook APIs → Supabase service: stores parsed results (evidence: `src/app/api/webhooks/razorpay/route.ts`)
- Server actions → Supabase service: reads and writes
- Service billing → Supabase service: writes bills (evidence: `src/lib/billing/serviceBill.ts`)
- Service billing → Billing: reconciles bill (evidence: `src/lib/billing/serviceBill.ts`)
- Insurance claims → Supabase service: persists remittances
