# abuzar7a/caresync architecture

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

- Interactive diagram: https://gitdiagram.com/abuzar7a/caresync
- Repository: https://github.com/abuzar7a/caresync

## Overview

CareSync is a Next.js elderly-care and medication-management portal for patients, caregivers/family, and doctors. Users register or sign in, then reach a role-specific portal: patients track doses, caregivers manage medications and care-team invitations, and doctors review appointments and set availability. The README also describes appointment coordination and family-caregiver connections. The sampled pages show direct Supabase client calls; unsampled booking and notification details are not inferred.

Main entry points: [`src/app/(auth)/login/page.tsx`](https://github.com/abuzar7a/caresync/blob/main/src/app/(auth)/login/page.tsx) (Sign in), [`src/lib/supabase/client.ts`](https://github.com/abuzar7a/caresync/blob/main/src/lib/supabase/client.ts) (Browser Supabase client), [`src/middleware.ts`](https://github.com/abuzar7a/caresync/blob/main/src/middleware.ts) (Session routing), [`src/app/page.tsx`](https://github.com/abuzar7a/caresync/blob/main/src/app/page.tsx) (Product landing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and access"]
  node_home["Product landing<br/>[page.tsx]"]
  node_signup["Registration<br/>[page.tsx]"]
  node_login["Sign in<br/>[page.tsx]"]
  node_middleware["Session routing<br/>[middleware.ts]"]
end

subgraph group_care["Care portals"]
  node_patient["Patient dose tracking<br/>[page.tsx]"]
  node_caregiver["Caregiver management<br/>[page.tsx]"]
  node_doctor["Doctor appointments<br/>[page.tsx]"]
end

subgraph group_services["Backend services"]
  node_browser["Browser Supabase client<br/>[client.ts]"]
  node_server["Server Supabase client<br/>[server.ts]"]
  node_admin["Admin Supabase client<br/>[admin.ts]"]
  node_email["Resend email helper<br/>[resend.ts]"]
end

subgraph group_domain["Care data"]
  node_database[("Care and account data")]
  node_types["Domain data types<br/>[database.ts]"]
end

node_visitors(("CareSync users"))
node_supabase[("Supabase")]

node_visitors -->|"visit"| node_home
node_home -->|"open registration"| node_signup
node_home -->|"open sign-in"| node_login
node_visitors -->|"register"| node_signup
node_signup -->|"create account"| node_browser
node_visitors -->|"sign in"| node_login
node_login -->|"authenticate and read role"| node_browser
node_login -->|"route elderly users"| node_patient
node_login -->|"route doctors"| node_doctor
node_login -->|"route other roles"| node_caregiver
node_middleware -->|"validate session"| node_supabase
node_middleware -->|"protect and route"| node_patient
node_middleware -->|"protect and route"| node_doctor
node_middleware -->|"protect and route"| node_caregiver
node_patient -->|"read profile and log doses"| node_browser
node_caregiver -->|"manage care records"| node_browser
node_doctor -->|"manage appointments and hours"| node_browser
node_browser -.->|"access backend"| node_supabase
node_server -->|"create server session client"| node_supabase
node_admin -.->|"create admin client"| node_supabase
node_email -.->|"optional email workflow"| node_supabase
node_supabase -->|"persist care data"| node_database
node_types -.->|"describe domain records"| node_database

click node_home "https://github.com/abuzar7a/caresync/blob/main/src/app/page.tsx"
click node_signup "https://github.com/abuzar7a/caresync/blob/main/src/app/(auth)/signup/page.tsx"
click node_login "https://github.com/abuzar7a/caresync/blob/main/src/app/(auth)/login/page.tsx"
click node_middleware "https://github.com/abuzar7a/caresync/blob/main/src/middleware.ts"
click node_patient "https://github.com/abuzar7a/caresync/blob/main/src/app/patient/page.tsx"
click node_caregiver "https://github.com/abuzar7a/caresync/blob/main/src/app/caregiver/page.tsx"
click node_doctor "https://github.com/abuzar7a/caresync/blob/main/src/app/doctor/page.tsx"
click node_browser "https://github.com/abuzar7a/caresync/blob/main/src/lib/supabase/client.ts"
click node_server "https://github.com/abuzar7a/caresync/blob/main/src/lib/supabase/server.ts"
click node_admin "https://github.com/abuzar7a/caresync/blob/main/src/lib/supabase/admin.ts"
click node_email "https://github.com/abuzar7a/caresync/blob/main/src/lib/email/resend.ts"
click node_database "https://github.com/abuzar7a/caresync/blob/main/supabase/migrations/20261115_initial_schema.sql"
click node_types "https://github.com/abuzar7a/caresync/blob/main/src/types/database.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_home,node_signup,node_login,node_middleware,node_visitors toneBlue
class node_patient,node_caregiver,node_doctor,node_supabase toneAmber
class node_browser,node_server,node_admin,node_email toneMint
class node_database,node_types toneRose
```

## Components

### Entry and access

- [Product landing](https://github.com/abuzar7a/caresync/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Registration](https://github.com/abuzar7a/caresync/blob/main/src/app/(auth)/signup/page.tsx): `src/app/(auth)/signup/page.tsx`
- [Sign in](https://github.com/abuzar7a/caresync/blob/main/src/app/(auth)/login/page.tsx): `src/app/(auth)/login/page.tsx`
- [Session routing](https://github.com/abuzar7a/caresync/blob/main/src/middleware.ts): `src/middleware.ts`

### Care portals

- [Patient dose tracking](https://github.com/abuzar7a/caresync/blob/main/src/app/patient/page.tsx): `src/app/patient/page.tsx`
- [Caregiver management](https://github.com/abuzar7a/caresync/blob/main/src/app/caregiver/page.tsx): `src/app/caregiver/page.tsx`
- [Doctor appointments](https://github.com/abuzar7a/caresync/blob/main/src/app/doctor/page.tsx): `src/app/doctor/page.tsx`

### Backend services

- [Browser Supabase client](https://github.com/abuzar7a/caresync/blob/main/src/lib/supabase/client.ts): `src/lib/supabase/client.ts`
- [Server Supabase client](https://github.com/abuzar7a/caresync/blob/main/src/lib/supabase/server.ts): `src/lib/supabase/server.ts`
- [Admin Supabase client](https://github.com/abuzar7a/caresync/blob/main/src/lib/supabase/admin.ts): `src/lib/supabase/admin.ts`
- [Resend email helper](https://github.com/abuzar7a/caresync/blob/main/src/lib/email/resend.ts): `src/lib/email/resend.ts`

### Care data

- [Care and account data](https://github.com/abuzar7a/caresync/blob/main/supabase/migrations/20261115_initial_schema.sql): `supabase/migrations/20261115_initial_schema.sql`
- [Domain data types](https://github.com/abuzar7a/caresync/blob/main/src/types/database.ts): `src/types/database.ts`

### Other components

- **CareSync users**
- **Supabase**

## Connections

- CareSync users → Product landing: visit (evidence: `src/app/page.tsx`)
- Product landing → Registration: open registration (evidence: `src/app/page.tsx`)
- Product landing → Sign in: open sign-in (evidence: `src/app/page.tsx`)
- CareSync users → Registration: register (evidence: `src/app/(auth)/signup/page.tsx`)
- Registration → Browser Supabase client: create account (evidence: `src/app/(auth)/signup/page.tsx`)
- CareSync users → Sign in: sign in (evidence: `src/app/(auth)/login/page.tsx`)
- Sign in → Browser Supabase client: authenticate and read role (evidence: `src/app/(auth)/login/page.tsx`)
- Sign in → Patient dose tracking: route elderly users (evidence: `src/app/(auth)/login/page.tsx`)
- Sign in → Doctor appointments: route doctors (evidence: `src/app/(auth)/login/page.tsx`)
- Sign in → Caregiver management: route other roles (evidence: `src/app/(auth)/login/page.tsx`)
- Session routing → Supabase: validate session (evidence: `src/middleware.ts`)
- Session routing → Patient dose tracking: protect and route (evidence: `src/middleware.ts`)
- Session routing → Doctor appointments: protect and route (evidence: `src/middleware.ts`)
- Session routing → Caregiver management: protect and route (evidence: `src/middleware.ts`)
- Patient dose tracking → Browser Supabase client: read profile and log doses (evidence: `src/app/patient/page.tsx`)
- Caregiver management → Browser Supabase client: manage care records (evidence: `src/app/caregiver/page.tsx`)
- Doctor appointments → Browser Supabase client: manage appointments and hours (evidence: `src/app/doctor/page.tsx`)
- Browser Supabase client → Supabase: access backend (evidence: `README.md`)
- Server Supabase client → Supabase: create server session client (evidence: `src/lib/supabase/server.ts`)
- Admin Supabase client → Supabase: create admin client
- Resend email helper → Supabase: optional email workflow
- Supabase → Care and account data: persist care data (evidence: `README.md`)
- Domain data types → Care and account data: describe domain records
