# goldhoang/clinic-booking architecture

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

- Interactive diagram: https://gitdiagram.com/goldhoang/clinic-booking
- Repository: https://github.com/goldhoang/clinic-booking

## Overview

Clinic Booking System is a role-based clinic appointment web app. Patients register or sign in, book appointments, and manage them; doctors and administrators use role-specific dashboards and management screens. The graph shows documented user flows and source-indexed component usage, plus the sampled API-to-auth, validation, and persistence calls. Several page-to-API connections and dashboard data flows are not shown in the available excerpts, so they are omitted rather than inferred.

Main entry points: [`src/app/api/admin/users/route.ts`](https://github.com/goldhoang/clinic-booking/blob/master/src/app/api/admin/users/route.ts) (Admin user creation), [`src/app/patient/dashboard/page.tsx`](https://github.com/goldhoang/clinic-booking/blob/master/src/app/patient/dashboard/page.tsx) (Patient dashboard), [`src/app/doctor/dashboard/page.tsx`](https://github.com/goldhoang/clinic-booking/blob/master/src/app/doctor/dashboard/page.tsx) (Doctor dashboard), [`src/components/ThemeProvider.tsx`](https://github.com/goldhoang/clinic-booking/blob/master/src/components/ThemeProvider.tsx) (Theme provider)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_login_ui["Login screen<br/>[page.tsx]"]
  node_register_ui["Registration screen<br/>[page.tsx]"]
  node_booking_ui["Appointment booking<br/>[page.tsx]"]
  node_patient_dash["Patient dashboard<br/>[page.tsx]"]
  node_doctor_dash["Doctor dashboard<br/>[page.tsx]"]
  node_admin_dash["Admin dashboard<br/>[page.tsx]"]
  node_admin_users_ui["Admin user management<br/>[page.tsx]"]
  node_my_appts["My appointments<br/>[page.tsx]"]
end

subgraph group_workflows["App workflows"]
  node_auth_login["Login endpoint<br/>[route.ts]"]
  node_auth_register["Registration endpoint<br/>[route.ts]"]
  node_appointments_api["Appointment endpoints<br/>[route.ts]"]
  node_appointment_update["Appointment status update<br/>[route.ts]"]
  node_admin_user_api["Admin user creation<br/>[route.ts]"]
end

subgraph group_identity["Identity and security"]
  node_security["Validation and rate limits<br/>[security.ts]"]
  node_route_client["Session route client<br/>[supabase-route.ts]"]
  node_supabase_admin["Privileged auth client<br/>[supabase-admin.ts]"]
end

subgraph group_data["Data and presentation"]
  node_prisma["Prisma client<br/>[prisma.ts]"]
  node_theme_provider["Theme provider<br/>[ThemeProvider.tsx]"]
  node_theme_config["Role theme settings<br/>[theme.ts]"]
  node_appointment_card["Appointment card"]
  node_appointment_modal["Appointment details modal"]
  node_dashboard_shell["Dashboard shell<br/>[DashboardShell.tsx]"]
  node_hero["Dashboard hero<br/>[HeroSection.tsx]"]
  node_stats["Dashboard statistics<br/>[StatsCard.tsx]"]
  node_date_utils["Date utilities<br/>[date-utils.ts]"]
  node_specialties["Doctor specialties<br/>[specialties.ts]"]
end

node_patient(("Patient"))
node_doctor(("Doctor"))
node_admin(("Administrator"))
node_supabase[("Supabase Auth and database")]

node_patient -->|"signs in"| node_login_ui
node_patient -->|"registers"| node_register_ui
node_patient -->|"books visit"| node_booking_ui
node_patient -->|"views dashboard"| node_patient_dash
node_doctor -->|"views dashboard"| node_doctor_dash
node_admin -->|"views dashboard"| node_admin_dash
node_admin -->|"manages users"| node_admin_users_ui
node_patient -->|"manages appointments"| node_my_appts
node_login_ui -->|"submits credentials"| node_auth_login
node_register_ui -->|"submits registration"| node_auth_register
node_booking_ui -->|"books appointment"| node_appointments_api
node_auth_login -->|"validates and limits"| node_security
node_auth_login -->|"creates session client"| node_route_client
node_auth_register -->|"validates and limits"| node_security
node_auth_register -->|"creates session client"| node_route_client
node_appointments_api -->|"validates and limits"| node_security
node_appointments_api -->|"creates session client"| node_route_client
node_appointment_update -->|"validates and limits"| node_security
node_appointment_update -->|"creates session client"| node_route_client
node_admin_user_api -->|"checks caller session"| node_route_client
node_admin_user_api -->|"reads and creates profile"| node_prisma
node_admin_user_api -->|"creates auth user"| node_supabase_admin
node_admin_user_api -->|"validates and limits"| node_security
node_admin_user_api -->|"checks doctor specialty"| node_specialties
node_appointments_api -->|"reads and creates appointments"| node_supabase
node_appointment_update -->|"reads and updates appointment"| node_supabase
node_auth_login -->|"authenticates and reads profile"| node_supabase
node_auth_register -->|"registers and creates profile"| node_supabase
node_admin_user_api -->|"creates auth account"| node_supabase
node_patient_dash -->|"renders"| node_appointment_card
node_patient_dash -->|"renders"| node_appointment_modal
node_patient_dash -->|"renders"| node_hero
node_patient_dash -->|"renders"| node_stats
node_doctor_dash -->|"renders"| node_appointment_card
node_doctor_dash -->|"renders"| node_appointment_modal
node_doctor_dash -->|"renders"| node_hero
node_doctor_dash -->|"renders"| node_stats
node_admin_dash -->|"uses"| node_date_utils
node_admin_users_ui -->|"uses"| node_date_utils
node_my_appts -->|"uses"| node_date_utils
node_patient_dash -->|"uses"| node_theme_provider
node_doctor_dash -->|"uses"| node_theme_provider
node_appointment_card -->|"reads theme"| node_theme_provider
node_appointment_modal -->|"reads theme"| node_theme_provider
node_theme_provider -->|"loads palettes"| node_theme_config
node_dashboard_shell -->|"uses theme"| node_theme_provider
node_dashboard_shell -->|"uses settings"| node_theme_config

click node_login_ui "https://github.com/goldhoang/clinic-booking/blob/master/src/app/login/page.tsx"
click node_register_ui "https://github.com/goldhoang/clinic-booking/blob/master/src/app/register/page.tsx"
click node_booking_ui "https://github.com/goldhoang/clinic-booking/blob/master/src/app/book-appointment/page.tsx"
click node_patient_dash "https://github.com/goldhoang/clinic-booking/blob/master/src/app/patient/dashboard/page.tsx"
click node_doctor_dash "https://github.com/goldhoang/clinic-booking/blob/master/src/app/doctor/dashboard/page.tsx"
click node_admin_dash "https://github.com/goldhoang/clinic-booking/blob/master/src/app/admin/dashboard/page.tsx"
click node_admin_users_ui "https://github.com/goldhoang/clinic-booking/blob/master/src/app/admin/users/page.tsx"
click node_my_appts "https://github.com/goldhoang/clinic-booking/blob/master/src/app/my-appointments/page.tsx"
click node_auth_login "https://github.com/goldhoang/clinic-booking/blob/master/src/app/api/auth/login/route.ts"
click node_auth_register "https://github.com/goldhoang/clinic-booking/blob/master/src/app/api/auth/register/route.ts"
click node_appointments_api "https://github.com/goldhoang/clinic-booking/blob/master/src/app/api/appointments/route.ts"
click node_appointment_update "https://github.com/goldhoang/clinic-booking/blob/master/src/app/api/appointments/%5Bid%5D/route.ts"
click node_admin_user_api "https://github.com/goldhoang/clinic-booking/blob/master/src/app/api/admin/users/route.ts"
click node_security "https://github.com/goldhoang/clinic-booking/blob/master/src/lib/security.ts"
click node_route_client "https://github.com/goldhoang/clinic-booking/blob/master/src/lib/supabase-route.ts"
click node_supabase_admin "https://github.com/goldhoang/clinic-booking/blob/master/src/lib/supabase-admin.ts"
click node_prisma "https://github.com/goldhoang/clinic-booking/blob/master/src/lib/prisma.ts"
click node_theme_provider "https://github.com/goldhoang/clinic-booking/blob/master/src/components/ThemeProvider.tsx"
click node_theme_config "https://github.com/goldhoang/clinic-booking/blob/master/src/lib/theme.ts"
click node_appointment_card "https://github.com/goldhoang/clinic-booking/blob/master/src/components/AppointmentCard.tsx"
click node_appointment_modal "https://github.com/goldhoang/clinic-booking/blob/master/src/components/AppointmentDetailModal.tsx"
click node_dashboard_shell "https://github.com/goldhoang/clinic-booking/blob/master/src/components/DashboardShell.tsx"
click node_hero "https://github.com/goldhoang/clinic-booking/blob/master/src/components/HeroSection.tsx"
click node_stats "https://github.com/goldhoang/clinic-booking/blob/master/src/components/StatsCard.tsx"
click node_date_utils "https://github.com/goldhoang/clinic-booking/blob/master/src/lib/date-utils.ts"
click node_specialties "https://github.com/goldhoang/clinic-booking/blob/master/src/lib/specialties.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_login_ui,node_register_ui,node_booking_ui,node_patient_dash,node_doctor_dash,node_admin_dash,node_admin_users_ui,node_my_appts toneBlue
class node_auth_login,node_auth_register,node_appointments_api,node_appointment_update,node_admin_user_api,node_supabase toneAmber
class node_security,node_route_client,node_supabase_admin toneMint
class node_prisma,node_theme_provider,node_theme_config,node_appointment_card,node_appointment_modal,node_dashboard_shell,node_hero,node_stats,node_date_utils,node_specialties toneRose
class node_patient,node_doctor,node_admin toneIndigo
```

## Components

### User experience

- [Login screen](https://github.com/goldhoang/clinic-booking/blob/master/src/app/login/page.tsx): `src/app/login/page.tsx`
- [Registration screen](https://github.com/goldhoang/clinic-booking/blob/master/src/app/register/page.tsx): `src/app/register/page.tsx`
- [Appointment booking](https://github.com/goldhoang/clinic-booking/blob/master/src/app/book-appointment/page.tsx): `src/app/book-appointment/page.tsx`
- [Patient dashboard](https://github.com/goldhoang/clinic-booking/blob/master/src/app/patient/dashboard/page.tsx): `src/app/patient/dashboard/page.tsx`
- [Doctor dashboard](https://github.com/goldhoang/clinic-booking/blob/master/src/app/doctor/dashboard/page.tsx): `src/app/doctor/dashboard/page.tsx`
- [Admin dashboard](https://github.com/goldhoang/clinic-booking/blob/master/src/app/admin/dashboard/page.tsx): `src/app/admin/dashboard/page.tsx`
- [Admin user management](https://github.com/goldhoang/clinic-booking/blob/master/src/app/admin/users/page.tsx): `src/app/admin/users/page.tsx`
- [My appointments](https://github.com/goldhoang/clinic-booking/blob/master/src/app/my-appointments/page.tsx): `src/app/my-appointments/page.tsx`

### App workflows

- [Login endpoint](https://github.com/goldhoang/clinic-booking/blob/master/src/app/api/auth/login/route.ts): `src/app/api/auth/login/route.ts`
- [Registration endpoint](https://github.com/goldhoang/clinic-booking/blob/master/src/app/api/auth/register/route.ts): `src/app/api/auth/register/route.ts`
- [Appointment endpoints](https://github.com/goldhoang/clinic-booking/blob/master/src/app/api/appointments/route.ts): `src/app/api/appointments/route.ts`
- [Appointment status update](https://github.com/goldhoang/clinic-booking/blob/master/src/app/api/appointments/%5Bid%5D/route.ts): `src/app/api/appointments/[id]/route.ts`
- [Admin user creation](https://github.com/goldhoang/clinic-booking/blob/master/src/app/api/admin/users/route.ts): `src/app/api/admin/users/route.ts`

### Identity and security

- [Validation and rate limits](https://github.com/goldhoang/clinic-booking/blob/master/src/lib/security.ts): `src/lib/security.ts`
- [Session route client](https://github.com/goldhoang/clinic-booking/blob/master/src/lib/supabase-route.ts): `src/lib/supabase-route.ts`
- [Privileged auth client](https://github.com/goldhoang/clinic-booking/blob/master/src/lib/supabase-admin.ts): `src/lib/supabase-admin.ts`

### Data and presentation

- [Prisma client](https://github.com/goldhoang/clinic-booking/blob/master/src/lib/prisma.ts): `src/lib/prisma.ts`
- [Theme provider](https://github.com/goldhoang/clinic-booking/blob/master/src/components/ThemeProvider.tsx): `src/components/ThemeProvider.tsx`
- [Role theme settings](https://github.com/goldhoang/clinic-booking/blob/master/src/lib/theme.ts): `src/lib/theme.ts`
- [Appointment card](https://github.com/goldhoang/clinic-booking/blob/master/src/components/AppointmentCard.tsx): `src/components/AppointmentCard.tsx`
- [Appointment details modal](https://github.com/goldhoang/clinic-booking/blob/master/src/components/AppointmentDetailModal.tsx): `src/components/AppointmentDetailModal.tsx`
- [Dashboard shell](https://github.com/goldhoang/clinic-booking/blob/master/src/components/DashboardShell.tsx): `src/components/DashboardShell.tsx`
- [Dashboard hero](https://github.com/goldhoang/clinic-booking/blob/master/src/components/HeroSection.tsx): `src/components/HeroSection.tsx`
- [Dashboard statistics](https://github.com/goldhoang/clinic-booking/blob/master/src/components/StatsCard.tsx): `src/components/StatsCard.tsx`
- [Date utilities](https://github.com/goldhoang/clinic-booking/blob/master/src/lib/date-utils.ts): `src/lib/date-utils.ts`
- [Doctor specialties](https://github.com/goldhoang/clinic-booking/blob/master/src/lib/specialties.ts): `src/lib/specialties.ts`

### Other components

- **Patient**
- **Doctor**
- **Administrator**
- **Supabase Auth and database**

## Connections

- Patient → Login screen: signs in (evidence: `README.md`)
- Patient → Registration screen: registers (evidence: `README.md`)
- Patient → Appointment booking: books visit (evidence: `README.md`)
- Patient → Patient dashboard: views dashboard (evidence: `README.md`)
- Doctor → Doctor dashboard: views dashboard (evidence: `README.md`)
- Administrator → Admin dashboard: views dashboard (evidence: `README.md`)
- Administrator → Admin user management: manages users (evidence: `README.md`)
- Patient → My appointments: manages appointments (evidence: `README.md`)
- Login screen → Login endpoint: submits credentials (evidence: `README.md`)
- Registration screen → Registration endpoint: submits registration (evidence: `README.md`)
- Appointment booking → Appointment endpoints: books appointment (evidence: `README.md`)
- Login endpoint → Validation and rate limits: validates and limits (evidence: `src/app/api/auth/login/route.ts`)
- Login endpoint → Session route client: creates session client (evidence: `src/app/api/auth/login/route.ts`)
- Registration endpoint → Validation and rate limits: validates and limits (evidence: `src/app/api/auth/register/route.ts`)
- Registration endpoint → Session route client: creates session client (evidence: `src/app/api/auth/register/route.ts`)
- Appointment endpoints → Validation and rate limits: validates and limits (evidence: `src/app/api/appointments/route.ts`)
- Appointment endpoints → Session route client: creates session client (evidence: `src/app/api/appointments/route.ts`)
- Appointment status update → Validation and rate limits: validates and limits (evidence: `src/app/api/appointments/[id]/route.ts`)
- Appointment status update → Session route client: creates session client (evidence: `src/app/api/appointments/[id]/route.ts`)
- Admin user creation → Session route client: checks caller session (evidence: `src/app/api/admin/users/route.ts`)
- Admin user creation → Prisma client: reads and creates profile (evidence: `src/app/api/admin/users/route.ts`)
- Admin user creation → Privileged auth client: creates auth user (evidence: `src/app/api/admin/users/route.ts`)
- Admin user creation → Validation and rate limits: validates and limits (evidence: `src/app/api/admin/users/route.ts`)
- Admin user creation → Doctor specialties: checks doctor specialty (evidence: `src/app/api/admin/users/route.ts`)
- Appointment endpoints → Supabase Auth and database: reads and creates appointments (evidence: `src/app/api/appointments/route.ts`)
- Appointment status update → Supabase Auth and database: reads and updates appointment (evidence: `src/app/api/appointments/[id]/route.ts`)
- Login endpoint → Supabase Auth and database: authenticates and reads profile (evidence: `src/app/api/auth/login/route.ts`)
- Registration endpoint → Supabase Auth and database: registers and creates profile (evidence: `src/app/api/auth/register/route.ts`)
- Admin user creation → Supabase Auth and database: creates auth account (evidence: `src/app/api/admin/users/route.ts`)
- Patient dashboard → Appointment card: renders (evidence: `src/app/patient/dashboard/page.tsx`)
- Patient dashboard → Appointment details modal: renders (evidence: `src/app/patient/dashboard/page.tsx`)
- Patient dashboard → Dashboard hero: renders (evidence: `src/app/patient/dashboard/page.tsx`)
- Patient dashboard → Dashboard statistics: renders (evidence: `src/app/patient/dashboard/page.tsx`)
- Doctor dashboard → Appointment card: renders (evidence: `src/app/doctor/dashboard/page.tsx`)
- Doctor dashboard → Appointment details modal: renders (evidence: `src/app/doctor/dashboard/page.tsx`)
- Doctor dashboard → Dashboard hero: renders (evidence: `src/app/doctor/dashboard/page.tsx`)
- Doctor dashboard → Dashboard statistics: renders (evidence: `src/app/doctor/dashboard/page.tsx`)
- Admin dashboard → Date utilities: uses (evidence: `src/app/admin/dashboard/page.tsx`)
- Admin user management → Date utilities: uses (evidence: `src/app/admin/users/page.tsx`)
- My appointments → Date utilities: uses (evidence: `src/app/my-appointments/page.tsx`)
- Patient dashboard → Theme provider: uses
- Doctor dashboard → Theme provider: uses (evidence: `src/app/doctor/dashboard/page.tsx`)
- Appointment card → Theme provider: reads theme (evidence: `src/components/AppointmentCard.tsx`)
- Appointment details modal → Theme provider: reads theme (evidence: `src/components/AppointmentDetailModal.tsx`)
- Theme provider → Role theme settings: loads palettes (evidence: `src/components/ThemeProvider.tsx`)
- Dashboard shell → Theme provider: uses theme (evidence: `src/components/DashboardShell.tsx`)
- Dashboard shell → Role theme settings: uses settings (evidence: `src/components/DashboardShell.tsx`)
