# kyox7485/osem-webapp architecture

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

- Interactive diagram: https://gitdiagram.com/kyox7485/osem-webapp
- Repository: https://github.com/kyox7485/osem-webapp

## Overview

This is a Next.js care-management application for residential-care staff. The broad workflow is staff authentication and branch-scoped work, followed by resident, clinical, medication, physiotherapy, or inventory tasks and, where needed, generated reports. The tree shows substantial capabilities across these areas, but the README is empty and most feature pages were not sampled; those branches are represented without asserting unverified call chains. Edges are limited to relationships visible in excerpts or the source index.

Main entry points: [`webapp/src/app/(app)/layout.tsx`](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/layout.tsx) (Authenticated app shell), [`webapp/src/app/api/reports`](https://github.com/kyox7485/osem-webapp/tree/main/webapp/src/app/api/reports) (PDF report endpoints), [`webapp/src/lib/inventory/server.ts`](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/inventory/server.ts) (Inventory server services), [`webapp/src/app/(app)/residents/medication/orders/page.tsx`](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/residents/medication/orders/page.tsx) (Medication management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application shell"]
  node_shell["Authenticated app shell<br/>[layout.tsx]"]
  node_accounts["Accounts and staff<br/>[page.tsx]"]
end

subgraph group_care["Resident care"]
  node_residents["Resident records<br/>[page.tsx]"]
  node_medication["Medication management<br/>[page.tsx]"]
  node_medstock["Medication stock logic"]
  node_calendar["Medication chart calendar<br/>[calendar-engine.ts]"]
  node_consumables["Resident consumables<br/>[page.tsx]"]
end

subgraph group_clinical["Clinical practice"]
  node_clinical["Clinical records<br/>[page.tsx]"]
  node_woundupload["Wound photo upload<br/>[route.ts]"]
  node_physio["Physiotherapy assessments"]
  node_callbell["Callbell alerts<br/>[page.tsx]"]
end

subgraph group_inventory["Inventory operations"]
  node_inventoryui["Inventory workflows<br/>[page.tsx]"]
  node_invserver["Inventory server services<br/>[server.ts]"]
  node_invcore["Inventory rules and types<br/>[core.ts]"]
end

subgraph group_platform["Data and reporting"]
  node_supabase[("Supabase data service<br/>[server.ts]")]
  node_drive["Google Drive"]
  node_pdfreports["PDF report endpoints"]
  node_residentpdf["Resident PDF document"]
  node_nursingpdf["Nursing chart PDF"]
  node_physiopdf["Physio assessment PDF"]
  node_purchasepdf["Purchase list PDF"]
  node_translation["Translation services<br/>[server.ts]"]
  node_translate["Translation engine<br/>[translate.ts]"]
end

node_staff(("Care staff"))

node_staff -.->|"uses"| node_shell
node_shell -.->|"opens"| node_residents
node_shell -.->|"opens"| node_clinical
node_shell -.->|"opens"| node_inventoryui
node_shell -.->|"opens"| node_accounts
node_medication -.->|"uses"| node_medstock
node_medication -.->|"uses"| node_calendar
node_inventoryui -.->|"loads services"| node_invserver
node_invserver -->|"imports rules"| node_invcore
node_invserver -->|"queries data"| node_supabase
node_woundupload -->|"reads and writes"| node_supabase
node_woundupload -->|"uploads photo"| node_drive
node_pdfreports -->|"renders"| node_residentpdf
node_pdfreports -->|"renders"| node_nursingpdf
node_pdfreports -->|"renders"| node_physiopdf
node_pdfreports -->|"renders"| node_purchasepdf
node_translation -->|"calls"| node_translate

click node_shell "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/layout.tsx"
click node_residents "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/residents/%5Bid%5D/page.tsx"
click node_medication "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/residents/medication/orders/page.tsx"
click node_medstock "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/medication-stock.ts"
click node_calendar "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/medication-chart/calendar-engine.ts"
click node_consumables "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/residents/consumables/page.tsx"
click node_clinical "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/clinical/page.tsx"
click node_woundupload "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/api/wound-photos/route.ts"
click node_physio "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/physiotherapy/assessment-review.tsx"
click node_callbell "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/callbell/page.tsx"
click node_inventoryui "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/inventory/page.tsx"
click node_invserver "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/inventory/server.ts"
click node_invcore "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/inventory/core.ts"
click node_accounts "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/accounts/page.tsx"
click node_supabase "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/supabase/server.ts"
click node_pdfreports "https://github.com/kyox7485/osem-webapp/tree/main/webapp/src/app/api/reports"
click node_residentpdf "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/pdf/documents/resident-document.tsx"
click node_nursingpdf "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/pdf/documents/nursing-chart-document.tsx"
click node_physiopdf "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/pdf/documents/physio-assessment-document.tsx"
click node_purchasepdf "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/pdf/documents/purchase-list-document.tsx"
click node_translation "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/i18n/server.ts"
click node_translate "https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/i18n/translate.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_shell,node_accounts toneBlue
class node_residents,node_medication,node_medstock,node_calendar,node_consumables toneAmber
class node_clinical,node_woundupload,node_physio,node_callbell toneMint
class node_inventoryui,node_invserver,node_invcore toneRose
class node_supabase,node_drive,node_pdfreports,node_residentpdf,node_nursingpdf,node_physiopdf,node_purchasepdf,node_translation,node_translate,node_staff toneIndigo
```

## Components

### Application shell

- [Authenticated app shell](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/layout.tsx): `webapp/src/app/(app)/layout.tsx`
- [Accounts and staff](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/accounts/page.tsx): `webapp/src/app/(app)/accounts/page.tsx`

### Resident care

- [Resident records](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/residents/%5Bid%5D/page.tsx): `webapp/src/app/(app)/residents/[id]/page.tsx`
- [Medication management](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/residents/medication/orders/page.tsx): `webapp/src/app/(app)/residents/medication/orders/page.tsx`
- [Medication stock logic](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/medication-stock.ts): `webapp/src/lib/medication-stock.ts`
- [Medication chart calendar](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/medication-chart/calendar-engine.ts): `webapp/src/lib/medication-chart/calendar-engine.ts`
- [Resident consumables](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/residents/consumables/page.tsx): `webapp/src/app/(app)/residents/consumables/page.tsx`

### Clinical practice

- [Clinical records](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/clinical/page.tsx): `webapp/src/app/(app)/clinical/page.tsx`
- [Wound photo upload](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/api/wound-photos/route.ts): `webapp/src/app/api/wound-photos/route.ts`
- [Physiotherapy assessments](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/physiotherapy/assessment-review.tsx): `webapp/src/app/(app)/physiotherapy/assessment-review.tsx`
- [Callbell alerts](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/callbell/page.tsx): `webapp/src/app/(app)/callbell/page.tsx`

### Inventory operations

- [Inventory workflows](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/app/(app)/inventory/page.tsx): `webapp/src/app/(app)/inventory/page.tsx`
- [Inventory server services](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/inventory/server.ts): `webapp/src/lib/inventory/server.ts`
- [Inventory rules and types](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/inventory/core.ts): `webapp/src/lib/inventory/core.ts`

### Data and reporting

- [Supabase data service](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/supabase/server.ts): `webapp/src/lib/supabase/server.ts`
- **Google Drive**
- [PDF report endpoints](https://github.com/kyox7485/osem-webapp/tree/main/webapp/src/app/api/reports): `webapp/src/app/api/reports`
- [Resident PDF document](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/pdf/documents/resident-document.tsx): `webapp/src/lib/pdf/documents/resident-document.tsx`
- [Nursing chart PDF](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/pdf/documents/nursing-chart-document.tsx): `webapp/src/lib/pdf/documents/nursing-chart-document.tsx`
- [Physio assessment PDF](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/pdf/documents/physio-assessment-document.tsx): `webapp/src/lib/pdf/documents/physio-assessment-document.tsx`
- [Purchase list PDF](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/pdf/documents/purchase-list-document.tsx): `webapp/src/lib/pdf/documents/purchase-list-document.tsx`
- [Translation services](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/i18n/server.ts): `webapp/src/lib/i18n/server.ts`
- [Translation engine](https://github.com/kyox7485/osem-webapp/blob/main/webapp/src/lib/i18n/translate.ts): `webapp/src/lib/i18n/translate.ts`

### Other components

- **Care staff**

## Connections

- Care staff → Authenticated app shell: uses
- Authenticated app shell → Resident records: opens
- Authenticated app shell → Clinical records: opens
- Authenticated app shell → Inventory workflows: opens
- Authenticated app shell → Accounts and staff: opens
- Medication management → Medication stock logic: uses
- Medication management → Medication chart calendar: uses
- Inventory workflows → Inventory server services: loads services
- Inventory server services → Inventory rules and types: imports rules (evidence: `webapp/src/lib/inventory/server.ts`)
- Inventory server services → Supabase data service: queries data (evidence: `webapp/src/lib/inventory/server.ts`)
- Wound photo upload → Supabase data service: reads and writes (evidence: `webapp/src/app/api/wound-photos/route.ts`)
- Wound photo upload → Google Drive: uploads photo (evidence: `webapp/src/app/api/wound-photos/route.ts`)
- PDF report endpoints → Resident PDF document: renders (evidence: `webapp/src/app/api/reports/resident/route.tsx`)
- PDF report endpoints → Nursing chart PDF: renders (evidence: `webapp/src/app/api/reports/nursing-chart/route.tsx`)
- PDF report endpoints → Physio assessment PDF: renders (evidence: `webapp/src/app/api/reports/physio-assessment/route.tsx`)
- PDF report endpoints → Purchase list PDF: renders (evidence: `webapp/src/app/api/reports/purchase-list/route.tsx`)
- Translation services → Translation engine: calls (evidence: `webapp/src/lib/i18n/server.ts`)
