# aritradas2003/somnisense architecture

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

- Interactive diagram: https://gitdiagram.com/aritradas2003/somnisense
- Repository: https://github.com/aritradas2003/somnisense

## Overview

SomniSense is a healthcare monitoring frontend for authentication, patient and device workflows, and operational views. The evidenced workflow is sign-in, protected navigation, patient management or device assignment, and service-backed data retrieval. The tree also contains monitoring, alerts, analytics, and session views; their implementation details are not shown, so their connections are omitted. The README provides only the product name, and the supplied excerpts do not show a backend implementation.

Main entry points: [`frontend/src/app/router.jsx`](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/app/router.jsx) (Protected routes), [`frontend/src/services/patientService.js`](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/services/patientService.js) (Patient service), [`frontend/src/services/api/httpClient.js`](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/services/api/httpClient.js) (HTTP client), [`frontend/src/components/common/PatientsTable.jsx`](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/components/common/PatientsTable.jsx) (Patient table)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application and access"]
  node_app["App bootstrap<br/>[App.jsx]"]
  node_router["Protected routes<br/>[router.jsx]"]
  node_login["Sign-in page<br/>[LoginPage.jsx]"]
  node_authhook["Auth hook<br/>[useAuth.js]"]
  node_authstate["Auth state<br/>[authSlice.js]"]
  node_layout["App layout<br/>[AppLayout.jsx]"]
end

subgraph group_care["Patient and monitoring"]
  node_dashboard["Dashboard<br/>[DashboardPage.jsx]"]
  node_patients["Patient list<br/>[PatientsPage.jsx]"]
  node_addpatient["Add patient<br/>[AddPatientPage.jsx]"]
  node_patientdetails["Patient details"]
  node_patienttable["Patient table<br/>[PatientsTable.jsx]"]
  node_monitoring["Live monitoring"]
  node_alerts["Alerts view<br/>[AlertsPage.jsx]"]
  node_analytics["Analytics view<br/>[AnalyticsPage.jsx]"]
  node_sessions["Sessions view<br/>[SessionsPage.jsx]"]
end

subgraph group_devices["Device management"]
  node_devicespage["Device inventory<br/>[DevicesPage.jsx]"]
end

subgraph group_services["Services and API"]
  node_authservice["Auth service<br/>[authService.js]"]
  node_patientservice["Patient service<br/>[patientService.js]"]
  node_dashboardservice["Dashboard service"]
  node_deviceservice["Device service<br/>[deviceService.js]"]
  node_mockservices["Mock services"]
  node_http["HTTP client<br/>[httpClient.js]"]
  node_config["API configuration<br/>[apiConfig.js]"]
end

node_user(("Staff user"))
node_backend{{"SomniSense API"}}

node_user -->|"enters credentials"| node_login
node_app -->|"renders"| node_router
node_router -->|"routes to"| node_login
node_router -->|"wraps protected views"| node_layout
node_router -->|"routes to"| node_dashboard
node_router -->|"routes to"| node_patients
node_router -->|"routes to"| node_addpatient
node_router -->|"routes to"| node_patientdetails
node_router -->|"routes to"| node_devicespage
node_login -->|"uses"| node_authhook
node_router -->|"checks access"| node_authhook
node_authhook -->|"dispatches sign-in"| node_authstate
node_authstate -->|"calls login"| node_authservice
node_dashboard -->|"loads data"| node_dashboardservice
node_dashboard -->|"renders"| node_patienttable
node_patients -->|"loads patients"| node_patientservice
node_patients -->|"renders"| node_patienttable
node_addpatient -->|"creates patient"| node_patientservice
node_patientdetails -->|"loads overview"| node_patientservice
node_devicespage -->|"loads and assigns"| node_deviceservice
node_devicespage -->|"loads patients"| node_patientservice
node_deviceservice -->|"requests API"| node_http
node_patientservice -->|"requests API"| node_http
node_dashboardservice -->|"requests API"| node_http
node_authservice -->|"requests API"| node_http
node_deviceservice -->|"uses in mock mode"| node_mockservices
node_patientservice -->|"uses in mock mode"| node_mockservices
node_dashboardservice -->|"uses in mock mode"| node_mockservices
node_authservice -->|"uses in mock mode"| node_mockservices
node_http -->|"uses base URL"| node_config
node_http -->|"sends requests"| node_backend
node_patienttable -->|"renders status badge"| node_patienttable

click node_app "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/App.jsx"
click node_router "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/app/router.jsx"
click node_login "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/auth/LoginPage.jsx"
click node_authhook "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/hooks/useAuth.js"
click node_authstate "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/features/auth/authSlice.js"
click node_layout "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/components/layout/AppLayout.jsx"
click node_dashboard "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/dashboard/DashboardPage.jsx"
click node_patients "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/patients/PatientsPage.jsx"
click node_addpatient "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/patients/AddPatientPage.jsx"
click node_patientdetails "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/patients/PatientDetailsPage.jsx"
click node_patienttable "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/components/common/PatientsTable.jsx"
click node_monitoring "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/monitoring/LiveMonitoringPage.jsx"
click node_alerts "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/alerts/AlertsPage.jsx"
click node_analytics "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/analytics/AnalyticsPage.jsx"
click node_sessions "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/sessions/SessionsPage.jsx"
click node_devicespage "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/devices/DevicesPage.jsx"
click node_authservice "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/services/authService.js"
click node_patientservice "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/services/patientService.js"
click node_dashboardservice "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/services/dashboardService.js"
click node_deviceservice "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/services/deviceService.js"
click node_mockservices "https://github.com/aritradas2003/somnisense/tree/main/frontend/src/services/mocks"
click node_http "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/services/api/httpClient.js"
click node_config "https://github.com/aritradas2003/somnisense/blob/main/frontend/src/services/api/apiConfig.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_router,node_login,node_authhook,node_authstate,node_layout,node_user toneBlue
class node_dashboard,node_patients,node_addpatient,node_patientdetails,node_patienttable,node_monitoring,node_alerts,node_analytics,node_sessions toneAmber
class node_devicespage,node_backend toneMint
class node_authservice,node_patientservice,node_dashboardservice,node_deviceservice,node_mockservices,node_http,node_config toneRose
```

## Components

### Application and access

- [App bootstrap](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Protected routes](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/app/router.jsx): `frontend/src/app/router.jsx`
- [Sign-in page](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/auth/LoginPage.jsx): `frontend/src/pages/auth/LoginPage.jsx`
- [Auth hook](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/hooks/useAuth.js): `frontend/src/hooks/useAuth.js`
- [Auth state](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/features/auth/authSlice.js): `frontend/src/features/auth/authSlice.js`
- [App layout](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/components/layout/AppLayout.jsx): `frontend/src/components/layout/AppLayout.jsx`

### Patient and monitoring

- [Dashboard](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/dashboard/DashboardPage.jsx): `frontend/src/pages/dashboard/DashboardPage.jsx`
- [Patient list](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/patients/PatientsPage.jsx): `frontend/src/pages/patients/PatientsPage.jsx`
- [Add patient](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/patients/AddPatientPage.jsx): `frontend/src/pages/patients/AddPatientPage.jsx`
- [Patient details](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/patients/PatientDetailsPage.jsx): `frontend/src/pages/patients/PatientDetailsPage.jsx`
- [Patient table](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/components/common/PatientsTable.jsx): `frontend/src/components/common/PatientsTable.jsx`
- [Live monitoring](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/monitoring/LiveMonitoringPage.jsx): `frontend/src/pages/monitoring/LiveMonitoringPage.jsx`
- [Alerts view](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/alerts/AlertsPage.jsx): `frontend/src/pages/alerts/AlertsPage.jsx`
- [Analytics view](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/analytics/AnalyticsPage.jsx): `frontend/src/pages/analytics/AnalyticsPage.jsx`
- [Sessions view](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/sessions/SessionsPage.jsx): `frontend/src/pages/sessions/SessionsPage.jsx`

### Device management

- [Device inventory](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/pages/devices/DevicesPage.jsx): `frontend/src/pages/devices/DevicesPage.jsx`

### Services and API

- [Auth service](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/services/authService.js): `frontend/src/services/authService.js`
- [Patient service](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/services/patientService.js): `frontend/src/services/patientService.js`
- [Dashboard service](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/services/dashboardService.js): `frontend/src/services/dashboardService.js`
- [Device service](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/services/deviceService.js): `frontend/src/services/deviceService.js`
- [Mock services](https://github.com/aritradas2003/somnisense/tree/main/frontend/src/services/mocks): `frontend/src/services/mocks`
- [HTTP client](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/services/api/httpClient.js): `frontend/src/services/api/httpClient.js`
- [API configuration](https://github.com/aritradas2003/somnisense/blob/main/frontend/src/services/api/apiConfig.js): `frontend/src/services/api/apiConfig.js`

### Other components

- **Staff user**
- **SomniSense API**

## Connections

- Staff user → Sign-in page: enters credentials (evidence: `frontend/src/pages/auth/LoginPage.jsx`)
- App bootstrap → Protected routes: renders (evidence: `frontend/src/App.jsx`)
- Protected routes → Sign-in page: routes to (evidence: `frontend/src/app/router.jsx`)
- Protected routes → App layout: wraps protected views (evidence: `frontend/src/app/router.jsx`)
- Protected routes → Dashboard: routes to (evidence: `frontend/src/app/router.jsx`)
- Protected routes → Patient list: routes to (evidence: `frontend/src/app/router.jsx`)
- Protected routes → Add patient: routes to (evidence: `frontend/src/app/router.jsx`)
- Protected routes → Patient details: routes to (evidence: `frontend/src/app/router.jsx`)
- Protected routes → Device inventory: routes to (evidence: `frontend/src/app/router.jsx`)
- Sign-in page → Auth hook: uses (evidence: `frontend/src/pages/auth/LoginPage.jsx`)
- Protected routes → Auth hook: checks access (evidence: `frontend/src/app/router.jsx`)
- Auth hook → Auth state: dispatches sign-in (evidence: `frontend/src/hooks/useAuth.js`)
- Auth state → Auth service: calls login (evidence: `frontend/src/features/auth/authSlice.js`)
- Dashboard → Dashboard service: loads data (evidence: `frontend/src/pages/dashboard/DashboardPage.jsx`)
- Dashboard → Patient table: renders (evidence: `frontend/src/pages/dashboard/DashboardPage.jsx`)
- Patient list → Patient service: loads patients (evidence: `frontend/src/pages/patients/PatientsPage.jsx`)
- Patient list → Patient table: renders (evidence: `frontend/src/pages/patients/PatientsPage.jsx`)
- Add patient → Patient service: creates patient (evidence: `frontend/src/pages/patients/AddPatientPage.jsx`)
- Patient details → Patient service: loads overview (evidence: `frontend/src/pages/patients/PatientDetailsPage.jsx`)
- Device inventory → Device service: loads and assigns (evidence: `frontend/src/pages/devices/DevicesPage.jsx`)
- Device inventory → Patient service: loads patients (evidence: `frontend/src/pages/devices/DevicesPage.jsx`)
- Device service → HTTP client: requests API (evidence: `frontend/src/services/deviceService.js`)
- Patient service → HTTP client: requests API (evidence: `frontend/src/services/patientService.js`)
- Dashboard service → HTTP client: requests API (evidence: `frontend/src/services/dashboardService.js`)
- Auth service → HTTP client: requests API (evidence: `frontend/src/services/authService.js`)
- Device service → Mock services: uses in mock mode (evidence: `frontend/src/services/deviceService.js`)
- Patient service → Mock services: uses in mock mode (evidence: `frontend/src/services/patientService.js`)
- Dashboard service → Mock services: uses in mock mode (evidence: `frontend/src/services/dashboardService.js`)
- Auth service → Mock services: uses in mock mode (evidence: `frontend/src/services/authService.js`)
- HTTP client → API configuration: uses base URL (evidence: `frontend/src/services/api/httpClient.js`)
- HTTP client → SomniSense API: sends requests (evidence: `frontend/src/services/api/httpClient.js`)
- Patient table → Patient table: renders status badge (evidence: `frontend/src/components/common/PatientsTable.jsx`)
