# nhmcare11-glitch/adabibnak architecture

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

- Interactive diagram: https://gitdiagram.com/nhmcare11-glitch/adabibnak
- Repository: https://github.com/nhmcare11-glitch/adabibnak

## Overview

1. This is a Next.js App Router application for a medical/telemedicine platform. The architecture is split between route-driven UI under `app/`, server-side business actions under `actions/`, and shared infrastructure in `lib/` plus `prisma/`.

2. The main user-facing surfaces are role-based dashboards and workflows:
   - patient dashboard
   - doctor dashboard and doctor verification/face-login
   - secretary dashboard
   - admin dashboard
   - verification manager dashboard
   - public doctor listing, specialty browsing, and appointment booking
   - chat and video-call experiences

3. Route structure is the primary boundary. `app/(auth)` contains sign-in/sign-up flows, while `app/(main)` contains authenticated application areas. This suggests a protected shell pattern where authentication and authorization decide which layout and routes a user can access.

4. Authorization is central to the system. `middleware.ts`, `lib/checkUser.ts`, and the `app/api/check-role` route imply role-based gating across the app. The existence of dedicated dashboards for admin, doctor, secretary, patient, and verification-manager means access control is not just cosmetic; it drives the route and data model boundaries.

5. Business operations are implemented in `actions/` as server-side actions grouped by domain: appointments, availability, chat, doctor, notifications, onboarding, payments, prescriptions, user management, verification, video calls, and role-specific flows. These actions are likely the main orchestration layer between UI and persistence.

6. Persistent data appears to be backed by Prisma and a relational database. `prisma/schema.prisma`, migrations, `lib/prisma.ts`, and `lib/data.tsx` indicate the app reads and writes structured domain entities such as users, doctors, appointments, prescriptions, payments, notifications, and verification records.

7. The appointment lifecycle is a key business flow. Users browse doctors by specialty, open a doctor profile, select a time slot, submit an appointment form, and then view appointments in role-specific dashboards. Supporting pieces include `app/(main)/doctors/...`, `actions/appointments.js`, `actions/availability.js`, and dashboard appointment lists.

8. Payments are a separate subsystem with both patient and doctor-facing views. `actions/payment.js`, `actions/paypal.js`, `lib/payment-utils.ts`, patient payment components, and doctor approval cards indicate the platform handles payment setup, payment status, approvals, and likely commission accounting. `app/(main)/patient-dashboard/paypal-return` shows a redirect/return flow from an external payment provider.

9. Communication features are split into chat, notifications, and video calls. Chat is route-based under `app/(main)/chat/[id]` with supporting actions in `actions/chat.js`. Notifications are exposed through `app/api/notifications/*` and UI components like `NotificationsBell`. Real-time feel is probably achieved through client components polling or server updates rather than a separate realtime service, based on the tree alone.

10. Doctor identity verification is a distinct subsystem. `lib/face/*`, the public face model assets, `app/(main)/doctor/face-login`, `app/api/doctor/face-verification/*`, and `actions/verification-manager.js` indicate browser-side face embedding/compare logic backed by server verification endpoints. This is a clear security boundary around doctor login/verification.

11. Several domain-specific dashboards aggregate data rather than own it. The admin dashboard manages verified and pending doctors, commissions, and availability. The secretary dashboard manages appointments, doctor/patient lists, and salary/payment views. The verification manager dashboard focuses on review/approval workflows. These screens are consumers of the same core domain data with different permissions.

12. The public experience also includes health content and utilities. `app/guide/*`, `app/calculators/child-growth`, `components/HeroSection.tsx`, and `components/HealthGuideSection.tsx` suggest the site is not only transactional but also informational. This content layer is separate from the authenticated operational workflows.

13. Internationalization is first-class. `i18n/request.ts` and `messages/en.json`, `ar.json`, `fr.json` show localized UI strings, so diagramming should include an i18n layer shared by routes and components rather than treating text as static.

14. Shared UI and application shell concerns live in `components/` and `components/ui/`. This includes the header/footer/navigation, notification bell, theme provider/toggle, and reusable cards/forms. These are cross-cutting presentation primitives used by the route pages, not standalone business modules.

15. Overall data flow is: browser route/UI -> server action or API route -> Prisma/database and supporting services -> updated dashboard or route state. The notable external boundary is PayPal for payments, plus model files in `public/models` and face-processing code for verification running partly in the browser and partly through API endpoints.

Main entry points: [`actions`](https://github.com/nhmcare11-glitch/adabibnak/tree/main/actions) (Server actions), [`lib`](https://github.com/nhmcare11-glitch/adabibnak/tree/main/lib) (Shared libs), [`middleware.ts`](https://github.com/nhmcare11-glitch/adabibnak/blob/main/middleware.ts) (Access guard), [`components`](https://github.com/nhmcare11-glitch/adabibnak/tree/main/components) (UI components)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_auth["Auth routes"]
  node_node_auth["Auth flows<br/>route group"]
end

subgraph group_group_main["Main app"]
  node_node_root_shell["App shell<br/>Next.js shell<br/>[layout.tsx]"]
  node_node_main_shell["Protected shell<br/>route shell"]
  node_node_doctors["Doctor browse"]
  node_node_booking["Booking flow<br/>appointment UI"]
  node_node_patient_dash["Patient dash<br/>dashboard"]
  node_node_doctor_dash["Doctor dash<br/>dashboard"]
  node_node_doctor_verify["Doctor verify<br/>security flow"]
  node_node_secretary_dash["Secretary dash<br/>dashboard"]
  node_node_admin_dash["Admin dash<br/>dashboard"]
  node_node_verif_manager["Verification mgr<br/>dashboard"]
  node_node_chat["Chat<br/>conversation view"]
  node_node_video["Video call<br/>call UI"]
  node_node_onboarding["Onboarding<br/>workflow"]
end

subgraph group_group_backend["Backend core"]
  node_node_middleware{{"Access guard<br/>middleware<br/>[middleware.ts]"}}
  node_node_check_role["Role check<br/>API route<br/>[route.js]"]
  node_node_notifications_api["Notifications API<br/>API routes"]
  node_node_cron["Reminder cron<br/>scheduled API<br/>[route.ts]"]
  node_node_face_api["Face API<br/>verification API"]
  node_node_actions[("Server actions<br/>orchestration layer")]
  node_node_prisma[("Prisma DB<br/>persistence<br/>[schema.prisma]")]
end

subgraph group_group_shared["Shared UI"]
  node_node_lib["Shared libs<br/>infra/utilities"]
  node_node_components["UI components<br/>shared UI"]
  node_node_i18n["i18n<br/>localization<br/>[request.ts]"]
end

subgraph group_group_public["Public content"]
  node_node_content["Guide content<br/>public content"]
end

node_node_middleware -->|"gate"| node_node_auth
node_node_middleware -->|"protects"| node_node_main_shell
node_node_check_role -.->|"supports"| node_node_middleware
node_node_main_shell -->|"routes to"| node_node_doctors
node_node_doctors -->|"opens"| node_node_booking
node_node_booking -->|"submits"| node_node_actions
node_node_patient_dash -->|"uses"| node_node_actions
node_node_doctor_dash -->|"uses"| node_node_actions
node_node_secretary_dash -->|"uses"| node_node_actions
node_node_admin_dash -->|"uses"| node_node_actions
node_node_verif_manager -->|"uses"| node_node_actions
node_node_chat -->|"messages"| node_node_actions
node_node_video -->|"session flow"| node_node_actions
node_node_notifications_api -->|"feeds"| node_node_components
node_node_face_api -->|"uses"| node_node_lib
node_node_doctor_verify -->|"verifies"| node_node_face_api
node_node_actions -->|"persists"| node_node_prisma
node_node_lib -->|"connects"| node_node_prisma
node_node_lib -.->|"localizes"| node_node_i18n
node_node_components -->|"composes"| node_node_root_shell
node_node_content -->|"renders with"| node_node_components
node_node_onboarding -->|"starts"| node_node_actions
node_node_cron -.->|"triggers"| node_node_actions

click node_node_root_shell "https://github.com/nhmcare11-glitch/adabibnak/blob/main/app/layout.tsx"
click node_node_auth "https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(auth)"
click node_node_middleware "https://github.com/nhmcare11-glitch/adabibnak/blob/main/middleware.ts"
click node_node_check_role "https://github.com/nhmcare11-glitch/adabibnak/blob/main/app/api/check-role/route.js"
click node_node_main_shell "https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)"
click node_node_doctors "https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/doctors"
click node_node_booking "https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/doctors/[specialty]/[id]"
click node_node_patient_dash "https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/patient-dashboard"
click node_node_doctor_dash "https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/doctor-dashboard"
click node_node_doctor_verify "https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/doctor/face-login"
click node_node_secretary_dash "https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/secretary-dashboard"
click node_node_admin_dash "https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/admin"
click node_node_verif_manager "https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/verification-manager"
click node_node_chat "https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/chat/[id]"
click node_node_video "https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/video-call"
click node_node_onboarding "https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/onboarding"
click node_node_notifications_api "https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/api/notifications"
click node_node_cron "https://github.com/nhmcare11-glitch/adabibnak/blob/main/app/api/cron/send-reminders/route.ts"
click node_node_face_api "https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/api/doctor/face-verification"
click node_node_actions "https://github.com/nhmcare11-glitch/adabibnak/tree/main/actions"
click node_node_prisma "https://github.com/nhmcare11-glitch/adabibnak/blob/main/prisma/schema.prisma"
click node_node_lib "https://github.com/nhmcare11-glitch/adabibnak/tree/main/lib"
click node_node_components "https://github.com/nhmcare11-glitch/adabibnak/tree/main/components"
click node_node_i18n "https://github.com/nhmcare11-glitch/adabibnak/blob/main/i18n/request.ts"
click node_node_content "https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/guide"

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_node_auth toneBlue
class node_node_root_shell,node_node_main_shell,node_node_doctors,node_node_booking,node_node_patient_dash,node_node_doctor_dash,node_node_doctor_verify,node_node_secretary_dash,node_node_admin_dash,node_node_verif_manager,node_node_chat,node_node_video,node_node_onboarding toneAmber
class node_node_middleware,node_node_check_role,node_node_notifications_api,node_node_cron,node_node_face_api,node_node_actions,node_node_prisma toneMint
class node_node_lib,node_node_components,node_node_i18n toneRose
class node_node_content toneIndigo
```

## Components

### Auth routes

Sign-in, sign-up, and access redirection flows

- [Auth flows](https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(auth)): route group · Sign-in and sign-up entry points under the auth layout · `app/(auth)`

### Main app

Authenticated route groups and role-based workspaces

- [App shell](https://github.com/nhmcare11-glitch/adabibnak/blob/main/app/layout.tsx): Next.js shell · Top-level application layout and protected route composition · `app/layout.tsx`
- [Protected shell](https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)): route shell · Authenticated application area that branches into role-specific and public-in-app experiences · `app/(main)`
- [Doctor browse](https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/doctors): directory · Public doctor listing, specialty browsing, and booking entry flow · `app/(main)/doctors`
- [Booking flow](https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/doctors/[specialty]/[id]): appointment UI · Doctor profile, availability, slot selection, and appointment submission · `app/(main)/doctors/[specialty]/[id]`
- [Patient dash](https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/patient-dashboard): dashboard · Patient profile, payment, and appointment management surface · `app/(main)/patient-dashboard`
- [Doctor dash](https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/doctor-dashboard): dashboard · Doctor-facing overview with appointments and payment approvals · `app/(main)/doctor-dashboard`
- [Doctor verify](https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/doctor/face-login): security flow · Face-login and verification pages for doctor identity · `app/(main)/doctor/face-login`
- [Secretary dash](https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/secretary-dashboard): dashboard · Operational workspace for appointments, people lists, and payment/salary views · `app/(main)/secretary-dashboard`
- [Admin dash](https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/admin): dashboard · Administrative controls for doctors, availability, and commissions · `app/(main)/admin`
- [Verification mgr](https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/verification-manager): dashboard · Review and approval workspace for verification operations · `app/(main)/verification-manager`
- [Chat](https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/chat/[id]): conversation view · Threaded messaging experience inside the authenticated app · `app/(main)/chat/[id]`
- [Video call](https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/video-call): call UI · In-app video calling experience and layout · `app/(main)/video-call`
- [Onboarding](https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/(main)/onboarding): workflow · Post-auth setup and profile completion flow · `app/(main)/onboarding`

### Backend core

Server actions, API routes, and persistence layer

- [Access guard](https://github.com/nhmcare11-glitch/adabibnak/blob/main/middleware.ts): middleware · Global request-time auth and authorization gate · `middleware.ts`
- [Role check](https://github.com/nhmcare11-glitch/adabibnak/blob/main/app/api/check-role/route.js): API route · Server endpoint for role validation and redirect decisions · `app/api/check-role/route.js`
- [Notifications API](https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/api/notifications): API routes · Read and update notification state for the app shell and dashboards · `app/api/notifications`
- [Reminder cron](https://github.com/nhmcare11-glitch/adabibnak/blob/main/app/api/cron/send-reminders/route.ts): scheduled API · Scheduled reminder dispatch for appointment operations · `app/api/cron/send-reminders/route.ts`
- [Face API](https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/api/doctor/face-verification): verification API · Browser-to-server endpoints for doctor face verification · `app/api/doctor/face-verification`
- [Server actions](https://github.com/nhmcare11-glitch/adabibnak/tree/main/actions): orchestration layer · Domain actions for appointments, payments, chat, users, verification, and dashboards · `actions`
- [Prisma DB](https://github.com/nhmcare11-glitch/adabibnak/blob/main/prisma/schema.prisma): persistence · Schema, migrations, and database access for domain entities · `prisma/schema.prisma`

### Shared UI

Reusable UI, i18n, and client-side application primitives

- [Shared libs](https://github.com/nhmcare11-glitch/adabibnak/tree/main/lib): infra/utilities · Prisma client, authorization helpers, payment utilities, face models, and shared data access · `lib`
- [UI components](https://github.com/nhmcare11-glitch/adabibnak/tree/main/components): shared UI · Reusable layout, navigation, forms, cards, and dashboard primitives · `components`
- [i18n](https://github.com/nhmcare11-glitch/adabibnak/blob/main/i18n/request.ts): localization · Locale request handling and translated message bundles · `i18n/request.ts`

### Public content

Health content, calculators, and marketing surfaces

- [Guide content](https://github.com/nhmcare11-glitch/adabibnak/tree/main/app/guide): public content · Health guides, calculators, and homepage content surfaces · `app/guide`

## Connections

- Access guard → Auth flows: gate · Blocks or redirects unauthenticated users into auth flows
- Access guard → Protected shell: protects · Protects authenticated areas and role-based navigation
- Role check → Access guard: supports · Used by request-time authorization checks
- Protected shell → Doctor browse: routes to · Exposes public-in-app doctor browsing
- Doctor browse → Booking flow: opens · Doctor specialty and profile pages lead into booking
- Booking flow → Server actions: submits · Appointment creation and slot handling are orchestrated server-side
- Patient dash → Server actions: uses · Loads and updates patient profile, payments, and appointments
- Doctor dash → Server actions: uses · Fetches appointments and payment approvals via server actions
- Secretary dash → Server actions: uses · Consumes operational lists, salary, and payment workflows
- Admin dash → Server actions: uses · Drives admin management of doctors, commissions, and availability
- Verification mgr → Server actions: uses · Processes verification review and approval operations
- Chat → Server actions: messages · Chat threads are coordinated through server-side chat actions
- Video call → Server actions: session flow · Call state and session actions are coordinated through backend actions
- Notifications API → UI components: feeds · Notification state is surfaced in shared UI such as the bell and shell
- Face API → Shared libs: uses · Face embedding, comparison, and model loading live in shared libs
- Doctor verify → Face API: verifies · Doctor login/verification pages invoke face verification endpoints
- Server actions → Prisma DB: persists · Core domain operations read and write relational records
- Shared libs → Prisma DB: connects · Shared data access uses the Prisma client and helpers
- Shared libs → i18n: localizes · Locale-aware utilities and shared UI draw from message bundles
- UI components → App shell: composes · Reusable UI pieces assemble the app shell and route layouts
- Guide content → UI components: renders with · Public informational pages are built from shared presentation primitives
- Onboarding → Server actions: starts · Onboarding writes user state through server actions
- Reminder cron → Server actions: triggers · Scheduled reminders reuse appointment and notification orchestration
