# fahad6396/ivus-system architecture

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

- Interactive diagram: https://gitdiagram.com/fahad6396/ivus-system
- Repository: https://github.com/fahad6396/ivus-system

## Overview

IVUS Medical System is a web application for managing medical-device assets and their preventive and corrective maintenance. Users enter through the responsive application shell, then manage hospitals and devices, record maintenance, and review dashboard and activity data; administrators also manage users, and staff can import Excel data. Supabase provides the application’s data and authentication services. The README identifies the product capabilities; some routes and integrations are represented from the tree and README because their implementation was not sampled.

Main entry points: [`lib/supabase.ts`](https://github.com/fahad6396/ivus-system/blob/main/lib/supabase.ts) (Supabase client), [`lib/activity-log.ts`](https://github.com/fahad6396/ivus-system/blob/main/lib/activity-log.ts) (Activity writer), [`components/AppShell.tsx`](https://github.com/fahad6396/ivus-system/blob/main/components/AppShell.tsx) (App shell), [`app/devices/page.tsx`](https://github.com/fahad6396/ivus-system/blob/main/app/devices/page.tsx) (Device list)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Workspace and access"]
  node_shell["App shell<br/>[AppShell.tsx]"]
  node_login["Sign in<br/>[page.tsx]"]
  node_logout["Sign out<br/>[LogoutButton.tsx]"]
end

subgraph group_assets["Assets and customers"]
  node_device_list["Device list<br/>[page.tsx]"]
  node_device_create["Add device<br/>[page.tsx]"]
  node_device_detail["Device record<br/>[page.tsx]"]
  node_device_edit["Edit device<br/>[page.tsx]"]
  node_device_history_add["Add device history<br/>[page.tsx]"]
  node_hospitals["Hospital management<br/>[page.tsx]"]
end

subgraph group_maintenance["Maintenance operations"]
  node_ppm["PPM scheduling<br/>[page.tsx]"]
  node_maintenance_record["Maintenance tracking<br/>[page.tsx]"]
  node_ppm_alert["PPM alerts<br/>[PPMAlert.tsx]"]
end

subgraph group_insights["Insights and tools"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_activity["Activity log view<br/>[page.tsx]"]
  node_excel["Excel import<br/>[page.tsx]"]
end

subgraph group_platform["Data and administration"]
  node_users["User management<br/>[page.tsx]"]
  node_user_api["User API routes"]
  node_create_user_function["Create-user function<br/>[index.ts]"]
  node_weekly_report["Weekly PPM report<br/>[index.ts]"]
  node_activity_writer["Activity writer<br/>[activity-log.ts]"]
  node_supabase_client["Supabase client<br/>[supabase.ts]"]
  node_admin_client["Admin client<br/>[supabaseAdmin.ts]"]
end

node_user(("Staff user"))
node_supabase[("Supabase services")]

node_user -->|"uses"| node_shell
node_shell -->|"links to"| node_login
node_shell -->|"renders"| node_logout
node_shell -->|"renders"| node_ppm_alert
node_user -->|"views"| node_dashboard
node_dashboard -->|"queries"| node_supabase_client
node_device_list -->|"manages records"| node_supabase_client
node_device_list -->|"links to"| node_device_create
node_device_list -->|"opens"| node_device_detail
node_device_create -->|"writes records"| node_supabase_client
node_device_create -->|"logs actions"| node_activity_writer
node_device_detail -->|"queries records"| node_supabase_client
node_device_detail -->|"logs actions"| node_activity_writer
node_device_edit -->|"updates records"| node_supabase_client
node_device_history_add -->|"updates records"| node_supabase_client
node_hospitals -->|"manages hospitals"| node_supabase_client
node_hospitals -->|"logs actions"| node_activity_writer
node_ppm -->|"manages schedules"| node_supabase_client
node_ppm -->|"logs actions"| node_activity_writer
node_maintenance_record -->|"manages records"| node_supabase_client
node_ppm_alert -->|"queries schedules"| node_supabase_client
node_activity -->|"queries activity"| node_supabase_client
node_excel -->|"imports data"| node_supabase_client
node_users -->|"manages profiles"| node_supabase_client
node_user_api -->|"uses"| node_admin_client
node_create_user_function -.->|"provisions users"| node_supabase
node_weekly_report -.->|"sends report"| node_supabase
node_supabase_client -->|"connects to"| node_supabase
node_admin_client -->|"connects to"| node_supabase
node_activity_writer -->|"writes events"| node_supabase_client

click node_shell "https://github.com/fahad6396/ivus-system/blob/main/components/AppShell.tsx"
click node_login "https://github.com/fahad6396/ivus-system/blob/main/app/login/page.tsx"
click node_logout "https://github.com/fahad6396/ivus-system/blob/main/components/LogoutButton.tsx"
click node_dashboard "https://github.com/fahad6396/ivus-system/blob/main/app/page.tsx"
click node_device_list "https://github.com/fahad6396/ivus-system/blob/main/app/devices/page.tsx"
click node_device_create "https://github.com/fahad6396/ivus-system/blob/main/app/add-device/page.tsx"
click node_device_detail "https://github.com/fahad6396/ivus-system/blob/main/app/devices/%5Bid%5D/page.tsx"
click node_device_edit "https://github.com/fahad6396/ivus-system/blob/main/app/devices/%5Bid%5D/edit/page.tsx"
click node_device_history_add "https://github.com/fahad6396/ivus-system/blob/main/app/devices/%5Bid%5D/add/page.tsx"
click node_hospitals "https://github.com/fahad6396/ivus-system/blob/main/app/hospitals/page.tsx"
click node_ppm "https://github.com/fahad6396/ivus-system/blob/main/app/ppm/page.tsx"
click node_maintenance_record "https://github.com/fahad6396/ivus-system/blob/main/app/maintenance/%5Bid%5D/edit/page.tsx"
click node_ppm_alert "https://github.com/fahad6396/ivus-system/blob/main/components/PPMAlert.tsx"
click node_activity "https://github.com/fahad6396/ivus-system/blob/main/app/activity/page.tsx"
click node_excel "https://github.com/fahad6396/ivus-system/blob/main/app/tools/excel/page.tsx"
click node_users "https://github.com/fahad6396/ivus-system/blob/main/app/users/page.tsx"
click node_user_api "https://github.com/fahad6396/ivus-system/tree/main/app/api/users"
click node_create_user_function "https://github.com/fahad6396/ivus-system/blob/main/supabase/functions/create-user/index.ts"
click node_weekly_report "https://github.com/fahad6396/ivus-system/blob/main/supabase/functions/weekly-ppm-report/index.ts"
click node_activity_writer "https://github.com/fahad6396/ivus-system/blob/main/lib/activity-log.ts"
click node_supabase_client "https://github.com/fahad6396/ivus-system/blob/main/lib/supabase.ts"
click node_admin_client "https://github.com/fahad6396/ivus-system/blob/main/lib/supabaseAdmin.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_login,node_logout,node_user toneBlue
class node_device_list,node_device_create,node_device_detail,node_device_edit,node_device_history_add,node_hospitals,node_supabase toneAmber
class node_ppm,node_maintenance_record,node_ppm_alert toneMint
class node_dashboard,node_activity,node_excel toneRose
class node_users,node_user_api,node_create_user_function,node_weekly_report,node_activity_writer,node_supabase_client,node_admin_client toneIndigo
```

## Components

### Workspace and access

- [App shell](https://github.com/fahad6396/ivus-system/blob/main/components/AppShell.tsx): `components/AppShell.tsx`
- [Sign in](https://github.com/fahad6396/ivus-system/blob/main/app/login/page.tsx): `app/login/page.tsx`
- [Sign out](https://github.com/fahad6396/ivus-system/blob/main/components/LogoutButton.tsx): `components/LogoutButton.tsx`

### Assets and customers

- [Device list](https://github.com/fahad6396/ivus-system/blob/main/app/devices/page.tsx): `app/devices/page.tsx`
- [Add device](https://github.com/fahad6396/ivus-system/blob/main/app/add-device/page.tsx): `app/add-device/page.tsx`
- [Device record](https://github.com/fahad6396/ivus-system/blob/main/app/devices/%5Bid%5D/page.tsx): `app/devices/[id]/page.tsx`
- [Edit device](https://github.com/fahad6396/ivus-system/blob/main/app/devices/%5Bid%5D/edit/page.tsx): `app/devices/[id]/edit/page.tsx`
- [Add device history](https://github.com/fahad6396/ivus-system/blob/main/app/devices/%5Bid%5D/add/page.tsx): `app/devices/[id]/add/page.tsx`
- [Hospital management](https://github.com/fahad6396/ivus-system/blob/main/app/hospitals/page.tsx): `app/hospitals/page.tsx`

### Maintenance operations

- [PPM scheduling](https://github.com/fahad6396/ivus-system/blob/main/app/ppm/page.tsx): `app/ppm/page.tsx`
- [Maintenance tracking](https://github.com/fahad6396/ivus-system/blob/main/app/maintenance/%5Bid%5D/edit/page.tsx): `app/maintenance/[id]/edit/page.tsx`
- [PPM alerts](https://github.com/fahad6396/ivus-system/blob/main/components/PPMAlert.tsx): `components/PPMAlert.tsx`

### Insights and tools

- [Dashboard](https://github.com/fahad6396/ivus-system/blob/main/app/page.tsx): `app/page.tsx`
- [Activity log view](https://github.com/fahad6396/ivus-system/blob/main/app/activity/page.tsx): `app/activity/page.tsx`
- [Excel import](https://github.com/fahad6396/ivus-system/blob/main/app/tools/excel/page.tsx): `app/tools/excel/page.tsx`

### Data and administration

- [User management](https://github.com/fahad6396/ivus-system/blob/main/app/users/page.tsx): `app/users/page.tsx`
- [User API routes](https://github.com/fahad6396/ivus-system/tree/main/app/api/users): `app/api/users`
- [Create-user function](https://github.com/fahad6396/ivus-system/blob/main/supabase/functions/create-user/index.ts): `supabase/functions/create-user/index.ts`
- [Weekly PPM report](https://github.com/fahad6396/ivus-system/blob/main/supabase/functions/weekly-ppm-report/index.ts): `supabase/functions/weekly-ppm-report/index.ts`
- [Activity writer](https://github.com/fahad6396/ivus-system/blob/main/lib/activity-log.ts): `lib/activity-log.ts`
- [Supabase client](https://github.com/fahad6396/ivus-system/blob/main/lib/supabase.ts): `lib/supabase.ts`
- [Admin client](https://github.com/fahad6396/ivus-system/blob/main/lib/supabaseAdmin.ts): `lib/supabaseAdmin.ts`

### Other components

- **Staff user**
- **Supabase services**

## Connections

- Staff user → App shell: uses (evidence: `components/AppShell.tsx`)
- App shell → Sign in: links to (evidence: `components/AppShell.tsx`)
- App shell → Sign out: renders (evidence: `components/AppShell.tsx`)
- App shell → PPM alerts: renders (evidence: `components/AppShell.tsx`)
- Staff user → Dashboard: views (evidence: `README.md`)
- Dashboard → Supabase client: queries (evidence: `app/page.tsx`)
- Device list → Supabase client: manages records (evidence: `app/devices/page.tsx`)
- Device list → Add device: links to (evidence: `app/devices/page.tsx`)
- Device list → Device record: opens (evidence: `app/devices/page.tsx`)
- Add device → Supabase client: writes records (evidence: `app/add-device/page.tsx`)
- Add device → Activity writer: logs actions (evidence: `app/add-device/page.tsx`)
- Device record → Supabase client: queries records (evidence: `app/devices/[id]/page.tsx`)
- Device record → Activity writer: logs actions (evidence: `app/devices/[id]/page.tsx`)
- Edit device → Supabase client: updates records (evidence: `app/devices/[id]/edit/page.tsx`)
- Add device history → Supabase client: updates records (evidence: `app/devices/[id]/add/page.tsx`)
- Hospital management → Supabase client: manages hospitals (evidence: `app/hospitals/page.tsx`)
- Hospital management → Activity writer: logs actions (evidence: `app/hospitals/page.tsx`)
- PPM scheduling → Supabase client: manages schedules (evidence: `app/ppm/page.tsx`)
- PPM scheduling → Activity writer: logs actions (evidence: `app/ppm/page.tsx`)
- Maintenance tracking → Supabase client: manages records (evidence: `app/maintenance/[id]/edit/page.tsx`)
- PPM alerts → Supabase client: queries schedules (evidence: `components/PPMAlert.tsx`)
- Activity log view → Supabase client: queries activity (evidence: `app/activity/page.tsx`)
- Excel import → Supabase client: imports data (evidence: `app/tools/excel/page.tsx`)
- User management → Supabase client: manages profiles (evidence: `app/users/page.tsx`)
- User API routes → Admin client: uses (evidence: `app/api/users/create/route.ts`)
- Create-user function → Supabase services: provisions users
- Weekly PPM report → Supabase services: sends report
- Supabase client → Supabase services: connects to (evidence: `lib/supabase.ts`)
- Admin client → Supabase services: connects to (evidence: `lib/supabaseAdmin.ts`)
- Activity writer → Supabase client: writes events (evidence: `lib/activity-log.ts`)
