# abhishekghim/captoneproject architecture

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

- Interactive diagram: https://gitdiagram.com/abhishekghim/captoneproject
- Repository: https://github.com/abhishekghim/captoneproject

## Overview

Capital Radiology is a role-based MRI booking and clinic-workflow application. Patients book appointments and submit referrals; clinic staff register patients and coordinate scheduling and arrivals; technicians record scans; radiologists review imaging and finalize reports; patients and permitted referrers can then view results, while billing supports online payment and emailed invoices. Admin and super-admin dashboards cover operational oversight and staff access. The tree and README establish these product areas, but most of their page-to-hook wiring is unsampled; edges below are limited to documented flows and sampled server calls.

Main entry points: [`app/(app)/dashboard/page.tsx`](https://github.com/abhishekghim/captoneproject/blob/main/app/(app)/dashboard/page.tsx) (Role dashboards), [`app/api/payments/checkout/route.ts`](https://github.com/abhishekghim/captoneproject/blob/main/app/api/payments/checkout/route.ts) (Checkout API), [`app/api/assistant/route.ts`](https://github.com/abhishekghim/captoneproject/blob/main/app/api/assistant/route.ts) (Assistant API), [`app/api/payments/invoice/route.ts`](https://github.com/abhishekghim/captoneproject/blob/main/app/api/payments/invoice/route.ts) (Invoice API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and roles"]
  node_auth["Sign in and signup<br/>[page.tsx]"]
  node_oauth["OAuth callback<br/>[route.ts]"]
  node_role_dash["Role dashboards<br/>[page.tsx]"]
end

subgraph group_clinic["Clinic operations"]
  node_registry["Patient registration"]
  node_register_api["Registration API<br/>[route.ts]"]
  node_schedule["Schedule and arrivals<br/>[TodaysSchedule.tsx]"]
  node_notifications["Notification API<br/>[route.ts]"]
  node_notification_sender["Notification delivery<br/>[send.ts]"]
end

subgraph group_imaging["Imaging and reports"]
  node_scan_queue["Scan queue<br/>[TodaysQueue.tsx]"]
  node_scan_logger["Scan logging<br/>[ScanLoggerForm.tsx]"]
  node_storage["DICOM file storage<br/>[storage.ts]"]
  node_dicom_viewer["DICOM review<br/>[DicomViewer.tsx]"]
  node_dicom_tools["DICOM parsing and rendering<br/>[parse.ts]"]
  node_report_editor["Report authoring<br/>[ReportEditor.tsx]"]
end

subgraph group_patient["Patient services"]
  node_patient_booking["Appointment booking<br/>[page.tsx]"]
  node_referral["Referral submission"]
  node_results["Reports and results<br/>[page.tsx]"]
  node_billing["Billing dashboard<br/>[page.tsx]"]
  node_checkout["Checkout API<br/>[route.ts]"]
  node_assistant_widget["Assistant widget"]
  node_assistant_api["Assistant API<br/>[route.ts]"]
end

subgraph group_admin["Administration"]
  node_invoice["Invoice API<br/>[route.ts]"]
  node_webhook["Payment webhook<br/>[route.ts]"]
  node_admin_dash["Admin workflows<br/>[AdminDashboard.tsx]"]
  node_staff_admin["Staff directory"]
  node_staff_api["Staff creation API<br/>[route.ts]"]
end

node_visitor(("Patients and staff"))
node_supabase_auth{{"Supabase Auth"}}
node_stripe{{"Stripe"}}
node_billing_store[("Billing records")]
node_openai{{"OpenAI"}}

node_visitor -->|"signs in"| node_auth
node_auth -->|"authenticates"| node_supabase_auth
node_oauth -->|"exchanges code"| node_supabase_auth
node_supabase_auth -->|"routes by role"| node_role_dash
node_visitor -->|"uses dashboard"| node_role_dash
node_role_dash -->|"opens booking"| node_patient_booking
node_role_dash -->|"opens referrals"| node_referral
node_role_dash -->|"opens registration"| node_registry
node_registry -->|"registers patient"| node_register_api
node_register_api -->|"creates account"| node_supabase_auth
node_role_dash -->|"manages arrivals"| node_schedule
node_role_dash -->|"opens queue"| node_scan_queue
node_scan_queue -->|"records scan"| node_scan_logger
node_scan_logger -->|"uploads series"| node_storage
node_storage -->|"serves study URLs"| node_dicom_viewer
node_dicom_viewer -->|"parses images"| node_dicom_tools
node_role_dash -->|"authors reports"| node_report_editor
node_role_dash -->|"views results"| node_results
node_billing -->|"starts payment"| node_checkout
node_checkout -->|"creates session"| node_stripe
node_checkout -->|"reads and updates"| node_billing_store
node_invoice -->|"creates invoice"| node_stripe
node_invoice -->|"reads and updates"| node_billing_store
node_stripe -->|"sends events"| node_webhook
node_webhook -->|"settles bill"| node_billing_store
node_role_dash -->|"opens admin tools"| node_admin_dash
node_role_dash -->|"opens staff tools"| node_staff_admin
node_staff_admin -->|"creates staff"| node_staff_api
node_staff_api -->|"invites account"| node_supabase_auth
node_assistant_widget -->|"sends chat"| node_assistant_api
node_assistant_api -->|"verifies session"| node_supabase_auth
node_assistant_api -.->|"requests response"| node_openai
node_notifications -->|"dispatches"| node_notification_sender
node_notification_sender -->|"reads recipient"| node_supabase_auth

click node_auth "https://github.com/abhishekghim/captoneproject/blob/main/app/login/page.tsx"
click node_oauth "https://github.com/abhishekghim/captoneproject/blob/main/app/auth/callback/route.ts"
click node_role_dash "https://github.com/abhishekghim/captoneproject/blob/main/app/(app)/dashboard/page.tsx"
click node_patient_booking "https://github.com/abhishekghim/captoneproject/blob/main/app/(app)/dashboard/book/page.tsx"
click node_referral "https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/referring-doctor/NewReferralPanel.tsx"
click node_registry "https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/reception/PatientRegistry.tsx"
click node_register_api "https://github.com/abhishekghim/captoneproject/blob/main/app/api/reception/patients/register/route.ts"
click node_schedule "https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/reception/TodaysSchedule.tsx"
click node_scan_queue "https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/technician/TodaysQueue.tsx"
click node_scan_logger "https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/technician/ScanLoggerForm.tsx"
click node_storage "https://github.com/abhishekghim/captoneproject/blob/main/frontend/lib/storage.ts"
click node_dicom_viewer "https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/radiologist/DicomViewer.tsx"
click node_dicom_tools "https://github.com/abhishekghim/captoneproject/blob/main/frontend/lib/dicom/parse.ts"
click node_report_editor "https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/radiologist/ReportEditor.tsx"
click node_results "https://github.com/abhishekghim/captoneproject/blob/main/app/(app)/dashboard/results/page.tsx"
click node_billing "https://github.com/abhishekghim/captoneproject/blob/main/app/(app)/dashboard/billing/page.tsx"
click node_checkout "https://github.com/abhishekghim/captoneproject/blob/main/app/api/payments/checkout/route.ts"
click node_invoice "https://github.com/abhishekghim/captoneproject/blob/main/app/api/payments/invoice/route.ts"
click node_webhook "https://github.com/abhishekghim/captoneproject/blob/main/app/api/webhooks/stripe/route.ts"
click node_admin_dash "https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/admin/AdminDashboard.tsx"
click node_staff_admin "https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/super-admin/StaffDirectoryPanel.tsx"
click node_staff_api "https://github.com/abhishekghim/captoneproject/blob/main/app/api/super-admin/staff/create/route.ts"
click node_assistant_widget "https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/shared/AssistantWidget.tsx"
click node_assistant_api "https://github.com/abhishekghim/captoneproject/blob/main/app/api/assistant/route.ts"
click node_notifications "https://github.com/abhishekghim/captoneproject/blob/main/app/api/notifications/send/route.ts"
click node_notification_sender "https://github.com/abhishekghim/captoneproject/blob/main/backend/lib/notifications/send.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_auth,node_oauth,node_role_dash toneBlue
class node_registry,node_register_api,node_schedule,node_notifications,node_notification_sender,node_billing_store toneAmber
class node_scan_queue,node_scan_logger,node_storage,node_dicom_viewer,node_dicom_tools,node_report_editor toneMint
class node_patient_booking,node_referral,node_results,node_billing,node_checkout,node_assistant_widget,node_assistant_api toneRose
class node_invoice,node_webhook,node_admin_dash,node_staff_admin,node_staff_api,node_visitor,node_supabase_auth,node_stripe,node_openai toneIndigo
```

## Components

### Access and roles

- [Sign in and signup](https://github.com/abhishekghim/captoneproject/blob/main/app/login/page.tsx): `app/login/page.tsx`
- [OAuth callback](https://github.com/abhishekghim/captoneproject/blob/main/app/auth/callback/route.ts): `app/auth/callback/route.ts`
- [Role dashboards](https://github.com/abhishekghim/captoneproject/blob/main/app/(app)/dashboard/page.tsx): `app/(app)/dashboard/page.tsx`

### Clinic operations

- [Patient registration](https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/reception/PatientRegistry.tsx): `frontend/components/reception/PatientRegistry.tsx`
- [Registration API](https://github.com/abhishekghim/captoneproject/blob/main/app/api/reception/patients/register/route.ts): `app/api/reception/patients/register/route.ts`
- [Schedule and arrivals](https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/reception/TodaysSchedule.tsx): `frontend/components/reception/TodaysSchedule.tsx`
- [Notification API](https://github.com/abhishekghim/captoneproject/blob/main/app/api/notifications/send/route.ts): `app/api/notifications/send/route.ts`
- [Notification delivery](https://github.com/abhishekghim/captoneproject/blob/main/backend/lib/notifications/send.ts): `backend/lib/notifications/send.ts`

### Imaging and reports

- [Scan queue](https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/technician/TodaysQueue.tsx): `frontend/components/technician/TodaysQueue.tsx`
- [Scan logging](https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/technician/ScanLoggerForm.tsx): `frontend/components/technician/ScanLoggerForm.tsx`
- [DICOM file storage](https://github.com/abhishekghim/captoneproject/blob/main/frontend/lib/storage.ts): `frontend/lib/storage.ts`
- [DICOM review](https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/radiologist/DicomViewer.tsx): `frontend/components/radiologist/DicomViewer.tsx`
- [DICOM parsing and rendering](https://github.com/abhishekghim/captoneproject/blob/main/frontend/lib/dicom/parse.ts): `frontend/lib/dicom/parse.ts`
- [Report authoring](https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/radiologist/ReportEditor.tsx): `frontend/components/radiologist/ReportEditor.tsx`

### Patient services

- [Appointment booking](https://github.com/abhishekghim/captoneproject/blob/main/app/(app)/dashboard/book/page.tsx): `app/(app)/dashboard/book/page.tsx`
- [Referral submission](https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/referring-doctor/NewReferralPanel.tsx): `frontend/components/referring-doctor/NewReferralPanel.tsx`
- [Reports and results](https://github.com/abhishekghim/captoneproject/blob/main/app/(app)/dashboard/results/page.tsx): `app/(app)/dashboard/results/page.tsx`
- [Billing dashboard](https://github.com/abhishekghim/captoneproject/blob/main/app/(app)/dashboard/billing/page.tsx): `app/(app)/dashboard/billing/page.tsx`
- [Checkout API](https://github.com/abhishekghim/captoneproject/blob/main/app/api/payments/checkout/route.ts): `app/api/payments/checkout/route.ts`
- [Assistant widget](https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/shared/AssistantWidget.tsx): `frontend/components/shared/AssistantWidget.tsx`
- [Assistant API](https://github.com/abhishekghim/captoneproject/blob/main/app/api/assistant/route.ts): `app/api/assistant/route.ts`

### Administration

- [Invoice API](https://github.com/abhishekghim/captoneproject/blob/main/app/api/payments/invoice/route.ts): `app/api/payments/invoice/route.ts`
- [Payment webhook](https://github.com/abhishekghim/captoneproject/blob/main/app/api/webhooks/stripe/route.ts): `app/api/webhooks/stripe/route.ts`
- [Admin workflows](https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/admin/AdminDashboard.tsx): `frontend/components/admin/AdminDashboard.tsx`
- [Staff directory](https://github.com/abhishekghim/captoneproject/blob/main/frontend/components/super-admin/StaffDirectoryPanel.tsx): `frontend/components/super-admin/StaffDirectoryPanel.tsx`
- [Staff creation API](https://github.com/abhishekghim/captoneproject/blob/main/app/api/super-admin/staff/create/route.ts): `app/api/super-admin/staff/create/route.ts`

### Other components

- **Patients and staff**
- **Supabase Auth**
- **Stripe**
- **Billing records**
- **OpenAI**

## Connections

- Patients and staff → Sign in and signup: signs in
- Sign in and signup → Supabase Auth: authenticates
- OAuth callback → Supabase Auth: exchanges code
- Supabase Auth → Role dashboards: routes by role
- Patients and staff → Role dashboards: uses dashboard
- Role dashboards → Appointment booking: opens booking
- Role dashboards → Referral submission: opens referrals
- Role dashboards → Patient registration: opens registration
- Patient registration → Registration API: registers patient
- Registration API → Supabase Auth: creates account
- Role dashboards → Schedule and arrivals: manages arrivals
- Role dashboards → Scan queue: opens queue
- Scan queue → Scan logging: records scan
- Scan logging → DICOM file storage: uploads series
- DICOM file storage → DICOM review: serves study URLs
- DICOM review → DICOM parsing and rendering: parses images
- Role dashboards → Report authoring: authors reports
- Role dashboards → Reports and results: views results
- Billing dashboard → Checkout API: starts payment
- Checkout API → Stripe: creates session
- Checkout API → Billing records: reads and updates
- Invoice API → Stripe: creates invoice
- Invoice API → Billing records: reads and updates
- Stripe → Payment webhook: sends events
- Payment webhook → Billing records: settles bill
- Role dashboards → Admin workflows: opens admin tools
- Role dashboards → Staff directory: opens staff tools
- Staff directory → Staff creation API: creates staff
- Staff creation API → Supabase Auth: invites account
- Assistant widget → Assistant API: sends chat
- Assistant API → Supabase Auth: verifies session
- Assistant API → OpenAI: requests response
- Notification API → Notification delivery: dispatches
- Notification delivery → Supabase Auth: reads recipient
