# thinkhatminpro/clinicalappmanagement architecture

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

- Interactive diagram: https://gitdiagram.com/thinkhatminpro/clinicalappmanagement
- Repository: https://github.com/thinkhatminpro/clinicalappmanagement

## Overview

Clinic Appointment Management System supports patient self-service booking, doctor appointment management, and staff administration. Users enter through role-specific web portals; API routes authorize requests, controllers translate HTTP input, services enforce domain rules, and PostgreSQL stores clinic records. The principal booking workflow includes doctor availability, appointment creation, and overlap validation; staff also manages patient and doctor records and dashboards. The README documents the capabilities and layered API design. Some frontend-to-endpoint wiring and unsampled implementation details are represented only at subsystem level.

Main entry points: [`api/src/app.js`](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/app.js) (Express API), [`web/src/App.jsx`](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/web/src/App.jsx) (Role portals), [`web/src/lib/api.js`](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/web/src/lib/api.js) (API client), [`api/src/config/prisma.js`](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/config/prisma.js) (Prisma client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Role portals<br/>[App.jsx]"]
  node_authpage["Sign in / signup<br/>[AuthPage.jsx]"]
  node_patientui["Patient portal"]
  node_doctorui["Doctor portal"]
  node_staffui["Staff portal"]
  node_apiclient["API client<br/>[api.js]"]
end

subgraph group_api["API and access"]
  node_express["Express API<br/>[app.js]"]
  node_authroutes["Authentication routes<br/>[authRoutes.js]"]
  node_patientroutes["Patient routes<br/>[patientRoutes.js]"]
  node_doctorroutes["Doctor routes<br/>[doctorRoutes.js]"]
  node_staffroutes["Staff routes<br/>[staffRoutes.js]"]
  node_guards["JWT and role guards"]
  node_swagger["API documentation<br/>[swagger.js]"]
end

subgraph group_domain["Clinic workflows"]
  node_authservice["Authentication logic<br/>[authService.js]"]
  node_patientcontroller["Patient requests"]
  node_doctorcontroller["Doctor requests"]
  node_staffcontroller["Staff requests<br/>[staffController.js]"]
  node_patientservice["Patient booking and profile<br/>[patientService.js]"]
  node_doctorservice["Doctor appointments<br/>[doctorService.js]"]
  node_staffservice["Staff administration<br/>[staffService.js]"]
end

subgraph group_data["Persistence and errors"]
  node_userrepo["User repository<br/>[userRepository.js]"]
  node_prisma["Prisma client<br/>[prisma.js]"]
  node_postgres[("PostgreSQL")]
  node_errors["Error responses<br/>[errorHandler.js]"]
end

node_browser(("Clinic users"))

node_browser -->|"uses portals"| node_app
node_app -->|"routes to"| node_authpage
node_app -->|"routes to"| node_patientui
node_app -->|"routes to"| node_doctorui
node_app -->|"routes to"| node_staffui
node_authpage -.->|"submits auth"| node_apiclient
node_patientui -.->|"requests clinic data"| node_apiclient
node_doctorui -.->|"requests clinic data"| node_apiclient
node_staffui -->|"requests clinic data"| node_apiclient
node_apiclient -->|"calls API"| node_express
node_express -->|"mounts"| node_authroutes
node_express -->|"mounts"| node_patientroutes
node_express -->|"mounts"| node_doctorroutes
node_express -->|"mounts"| node_staffroutes
node_express -->|"formats failures"| node_errors
node_express -->|"serves docs"| node_swagger
node_authroutes -->|"handles login"| node_authservice
node_authroutes -.->|"protects routes"| node_guards
node_patientroutes -->|"checks access"| node_guards
node_doctorroutes -->|"checks access"| node_guards
node_staffroutes -->|"checks access"| node_guards
node_patientroutes -->|"dispatches"| node_patientcontroller
node_doctorroutes -->|"dispatches"| node_doctorcontroller
node_staffroutes -->|"dispatches"| node_staffcontroller
node_patientcontroller -->|"delegates"| node_patientservice
node_doctorcontroller -->|"delegates"| node_doctorservice
node_staffcontroller -->|"delegates"| node_staffservice
node_authservice -->|"looks up users"| node_userrepo
node_userrepo -->|"reads and writes"| node_postgres
node_patientservice -->|"uses database"| node_prisma
node_doctorservice -->|"uses database"| node_prisma
node_staffservice -->|"uses database"| node_prisma
node_prisma -->|"persists records"| node_postgres

click node_app "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/web/src/App.jsx"
click node_authpage "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/web/src/pages/auth/AuthPage.jsx"
click node_patientui "https://github.com/thinkhatminpro/clinicalappmanagement/tree/main/web/src/pages/patient"
click node_doctorui "https://github.com/thinkhatminpro/clinicalappmanagement/tree/main/web/src/pages/doctor"
click node_staffui "https://github.com/thinkhatminpro/clinicalappmanagement/tree/main/web/src/pages/staff"
click node_apiclient "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/web/src/lib/api.js"
click node_express "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/app.js"
click node_authroutes "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/routes/authRoutes.js"
click node_patientroutes "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/routes/patientRoutes.js"
click node_doctorroutes "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/routes/doctorRoutes.js"
click node_staffroutes "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/routes/staffRoutes.js"
click node_authservice "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/services/authService.js"
click node_patientcontroller "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/controllers/patientController.js"
click node_doctorcontroller "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/controllers/doctorController.js"
click node_staffcontroller "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/controllers/staffController.js"
click node_patientservice "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/services/patientService.js"
click node_doctorservice "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/services/doctorService.js"
click node_staffservice "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/services/staffService.js"
click node_guards "https://github.com/thinkhatminpro/clinicalappmanagement/tree/main/api/src/guards"
click node_userrepo "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/repositories/userRepository.js"
click node_prisma "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/config/prisma.js"
click node_errors "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/middleware/errorHandler.js"
click node_swagger "https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/config/swagger.js"

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_app,node_authpage,node_patientui,node_doctorui,node_staffui,node_apiclient,node_browser toneBlue
class node_express,node_authroutes,node_patientroutes,node_doctorroutes,node_staffroutes,node_guards,node_swagger toneAmber
class node_authservice,node_patientcontroller,node_doctorcontroller,node_staffcontroller,node_patientservice,node_doctorservice,node_staffservice toneMint
class node_userrepo,node_prisma,node_postgres,node_errors toneRose
```

## Components

### Web application

- [Role portals](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/web/src/App.jsx): `web/src/App.jsx`
- [Sign in / signup](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/web/src/pages/auth/AuthPage.jsx): `web/src/pages/auth/AuthPage.jsx`
- [Patient portal](https://github.com/thinkhatminpro/clinicalappmanagement/tree/main/web/src/pages/patient): `web/src/pages/patient`
- [Doctor portal](https://github.com/thinkhatminpro/clinicalappmanagement/tree/main/web/src/pages/doctor): `web/src/pages/doctor`
- [Staff portal](https://github.com/thinkhatminpro/clinicalappmanagement/tree/main/web/src/pages/staff): `web/src/pages/staff`
- [API client](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/web/src/lib/api.js): `web/src/lib/api.js`

### API and access

- [Express API](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/app.js): `api/src/app.js`
- [Authentication routes](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/routes/authRoutes.js): `api/src/routes/authRoutes.js`
- [Patient routes](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/routes/patientRoutes.js): `api/src/routes/patientRoutes.js`
- [Doctor routes](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/routes/doctorRoutes.js): `api/src/routes/doctorRoutes.js`
- [Staff routes](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/routes/staffRoutes.js): `api/src/routes/staffRoutes.js`
- [JWT and role guards](https://github.com/thinkhatminpro/clinicalappmanagement/tree/main/api/src/guards): `api/src/guards`
- [API documentation](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/config/swagger.js): `api/src/config/swagger.js`

### Clinic workflows

- [Authentication logic](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/services/authService.js): `api/src/services/authService.js`
- [Patient requests](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/controllers/patientController.js): `api/src/controllers/patientController.js`
- [Doctor requests](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/controllers/doctorController.js): `api/src/controllers/doctorController.js`
- [Staff requests](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/controllers/staffController.js): `api/src/controllers/staffController.js`
- [Patient booking and profile](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/services/patientService.js): `api/src/services/patientService.js`
- [Doctor appointments](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/services/doctorService.js): `api/src/services/doctorService.js`
- [Staff administration](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/services/staffService.js): `api/src/services/staffService.js`

### Persistence and errors

- [User repository](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/repositories/userRepository.js): `api/src/repositories/userRepository.js`
- [Prisma client](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/config/prisma.js): `api/src/config/prisma.js`
- **PostgreSQL**
- [Error responses](https://github.com/thinkhatminpro/clinicalappmanagement/blob/main/api/src/middleware/errorHandler.js): `api/src/middleware/errorHandler.js`

### Other components

- **Clinic users**

## Connections

- Clinic users → Role portals: uses portals (evidence: `web/src/App.jsx`)
- Role portals → Sign in / signup: routes to (evidence: `web/src/App.jsx`)
- Role portals → Patient portal: routes to (evidence: `web/src/App.jsx`)
- Role portals → Doctor portal: routes to (evidence: `web/src/App.jsx`)
- Role portals → Staff portal: routes to (evidence: `web/src/App.jsx`)
- Sign in / signup → API client: submits auth
- Patient portal → API client: requests clinic data
- Doctor portal → API client: requests clinic data
- Staff portal → API client: requests clinic data (evidence: `web/src/pages/staff/Appointments.jsx`)
- API client → Express API: calls API (evidence: `README.md`)
- Express API → Authentication routes: mounts (evidence: `api/src/app.js`)
- Express API → Patient routes: mounts (evidence: `api/src/app.js`)
- Express API → Doctor routes: mounts (evidence: `api/src/app.js`)
- Express API → Staff routes: mounts (evidence: `api/src/app.js`)
- Express API → Error responses: formats failures (evidence: `api/src/app.js`)
- Express API → API documentation: serves docs (evidence: `api/src/app.js`)
- Authentication routes → Authentication logic: handles login (evidence: `api/src/routes/authRoutes.js`)
- Authentication routes → JWT and role guards: protects routes
- Patient routes → JWT and role guards: checks access (evidence: `api/src/routes/patientRoutes.js`)
- Doctor routes → JWT and role guards: checks access (evidence: `api/src/routes/doctorRoutes.js`)
- Staff routes → JWT and role guards: checks access (evidence: `api/src/routes/staffRoutes.js`)
- Patient routes → Patient requests: dispatches (evidence: `api/src/routes/patientRoutes.js`)
- Doctor routes → Doctor requests: dispatches (evidence: `api/src/routes/doctorRoutes.js`)
- Staff routes → Staff requests: dispatches (evidence: `api/src/routes/staffRoutes.js`)
- Patient requests → Patient booking and profile: delegates (evidence: `api/src/controllers/patientController.js`)
- Doctor requests → Doctor appointments: delegates (evidence: `README.md`)
- Staff requests → Staff administration: delegates (evidence: `api/src/controllers/staffController.js`)
- Authentication logic → User repository: looks up users (evidence: `api/src/services/authService.js`)
- User repository → PostgreSQL: reads and writes (evidence: `api/src/repositories/userRepository.js`)
- Patient booking and profile → Prisma client: uses database (evidence: `api/src/services/patientService.js`)
- Doctor appointments → Prisma client: uses database (evidence: `api/src/services/doctorService.js`)
- Staff administration → Prisma client: uses database (evidence: `api/src/services/staffService.js`)
- Prisma client → PostgreSQL: persists records (evidence: `api/src/config/prisma.js`)
