# 2311060512-cloud/quanlyphongkham architecture

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

- Interactive diagram: https://gitdiagram.com/2311060512-cloud/quanlyphongkham
- Repository: https://github.com/2311060512-cloud/quanlyphongkham

## Overview

This is a Laravel microservices clinic-management system. A client enters through the API gateway, where JWT identity and role checks precede routing to the relevant service; the workflow spans account/provider management, patient registration and appointment handling, clinical services and test orders, then invoice generation and payment. Each service owns its database. The README documents billing’s cross-service data gathering and the gateway’s health checks. Sampled controller excerpts support the appointment, clinical, billing, and proxy flows; unsampled capabilities are included only where the README identifies them, with uncertain implementation links omitted.

Main entry points: [`api-gateway/app/Http/Controllers/CongGiaoTiepController.php`](https://github.com/2311060512-cloud/quanlyphongkham/blob/main/api-gateway/app/Http/Controllers/CongGiaoTiepController.php) (Reverse proxy and health), [`billing-service/app/Services/HoaDonService.php`](https://github.com/2311060512-cloud/quanlyphongkham/blob/main/billing-service/app/Services/HoaDonService.php) (Invoice aggregation and payment), [`appointment-service/app/Http/Controllers`](https://github.com/2311060512-cloud/quanlyphongkham/tree/main/appointment-service/app/Http/Controllers) (Patient and appointment API), [`auth-service/app/Http/Controllers`](https://github.com/2311060512-cloud/quanlyphongkham/tree/main/auth-service/app/Http/Controllers) (Accounts and authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["Gateway and portal"]
  node_gateway_auth["JWT and role middleware"]
  node_gateway_dispatch["Reverse proxy and health"]
  node_portal["Web portal"]
end

subgraph group_identity["Identity and providers"]
  node_auth_api["Accounts and authentication"]
  node_auth_logic["Identity and provider logic"]
  node_auth_store[("Identity database<br/>[database.php]")]
end

subgraph group_appointments["Patients and appointments"]
  node_appointment_api["Patient and appointment API"]
  node_appointment_logic["Patient and appointment logic"]
  node_appointment_store[("Appointment database<br/>[database.php]")]
  node_appointment_notice["Appointment notifications"]
end

subgraph group_clinical["Clinical services"]
  node_clinical_api["Clinical services API"]
  node_clinical_logic["Service orders and results<br/>[DichVuService.php]"]
  node_clinical_store[("Clinical database<br/>[database.php]")]
end

subgraph group_billing["Billing and payment"]
  node_billing_api["Invoice and payment API"]
  node_billing_logic["Invoice aggregation and payment<br/>[HoaDonService.php]"]
  node_billing_store[("Billing database<br/>[database.php]")]
end

node_client(("Web / API client"))
node_health_services(("Clinic microservices"))

node_client -->|"submits requests"| node_gateway_auth
node_gateway_auth -->|"validates JWT"| node_auth_api
node_gateway_auth -->|"authorizes and forwards"| node_gateway_dispatch
node_client -->|"uses portal"| node_portal
node_gateway_dispatch -->|"proxies identity routes"| node_auth_api
node_gateway_dispatch -->|"proxies appointment routes"| node_appointment_api
node_gateway_dispatch -->|"proxies clinical routes"| node_clinical_api
node_gateway_dispatch -->|"proxies billing routes"| node_billing_api
node_gateway_dispatch -->|"checks liveness"| node_health_services
node_auth_api -->|"invokes"| node_auth_logic
node_auth_logic -->|"reads and writes"| node_auth_store
node_appointment_api -->|"invokes"| node_appointment_logic
node_appointment_logic -->|"reads and writes"| node_appointment_store
node_appointment_api -.->|"sends notification"| node_appointment_notice
node_clinical_api -->|"invokes"| node_clinical_logic
node_clinical_logic -->|"reads and writes"| node_clinical_store
node_billing_api -->|"invokes"| node_billing_logic
node_billing_logic -->|"reads and writes"| node_billing_store
node_billing_logic -->|"fetches doctor pricing"| node_auth_api
node_billing_logic -->|"fetches appointment"| node_appointment_api
node_billing_logic -->|"fetches clinical charges"| node_clinical_api

click node_gateway_auth "https://github.com/2311060512-cloud/quanlyphongkham/tree/main/api-gateway/app/Http/Middleware"
click node_gateway_dispatch "https://github.com/2311060512-cloud/quanlyphongkham/blob/main/api-gateway/app/Http/Controllers/CongGiaoTiepController.php"
click node_portal "https://github.com/2311060512-cloud/quanlyphongkham/tree/main/api-gateway/resources/views"
click node_auth_api "https://github.com/2311060512-cloud/quanlyphongkham/tree/main/auth-service/app/Http/Controllers"
click node_auth_logic "https://github.com/2311060512-cloud/quanlyphongkham/tree/main/auth-service/app/Services"
click node_auth_store "https://github.com/2311060512-cloud/quanlyphongkham/blob/main/auth-service/config/database.php"
click node_appointment_api "https://github.com/2311060512-cloud/quanlyphongkham/tree/main/appointment-service/app/Http/Controllers"
click node_appointment_logic "https://github.com/2311060512-cloud/quanlyphongkham/tree/main/appointment-service/app/Services"
click node_appointment_store "https://github.com/2311060512-cloud/quanlyphongkham/blob/main/appointment-service/config/database.php"
click node_appointment_notice "https://github.com/2311060512-cloud/quanlyphongkham/blob/main/appointment-service/app/Notifications/ThongBaoLichHenNotification.php"
click node_clinical_api "https://github.com/2311060512-cloud/quanlyphongkham/blob/main/clinical-service/app/Http/Controllers/DichVuController.php"
click node_clinical_logic "https://github.com/2311060512-cloud/quanlyphongkham/blob/main/clinical-service/app/Services/DichVuService.php"
click node_clinical_store "https://github.com/2311060512-cloud/quanlyphongkham/blob/main/clinical-service/config/database.php"
click node_billing_api "https://github.com/2311060512-cloud/quanlyphongkham/blob/main/billing-service/app/Http/Controllers/HoaDonController.php"
click node_billing_logic "https://github.com/2311060512-cloud/quanlyphongkham/blob/main/billing-service/app/Services/HoaDonService.php"
click node_billing_store "https://github.com/2311060512-cloud/quanlyphongkham/blob/main/billing-service/config/database.php"

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_gateway_auth,node_gateway_dispatch,node_portal,node_client toneBlue
class node_auth_api,node_auth_logic,node_auth_store toneAmber
class node_appointment_api,node_appointment_logic,node_appointment_store,node_appointment_notice toneMint
class node_clinical_api,node_clinical_logic,node_clinical_store toneRose
class node_billing_api,node_billing_logic,node_billing_store,node_health_services toneIndigo
```

## Components

### Gateway and portal

- [JWT and role middleware](https://github.com/2311060512-cloud/quanlyphongkham/tree/main/api-gateway/app/Http/Middleware): `api-gateway/app/Http/Middleware`
- [Reverse proxy and health](https://github.com/2311060512-cloud/quanlyphongkham/blob/main/api-gateway/app/Http/Controllers/CongGiaoTiepController.php): `api-gateway/app/Http/Controllers/CongGiaoTiepController.php`
- [Web portal](https://github.com/2311060512-cloud/quanlyphongkham/tree/main/api-gateway/resources/views): `api-gateway/resources/views`

### Identity and providers

- [Accounts and authentication](https://github.com/2311060512-cloud/quanlyphongkham/tree/main/auth-service/app/Http/Controllers): `auth-service/app/Http/Controllers`
- [Identity and provider logic](https://github.com/2311060512-cloud/quanlyphongkham/tree/main/auth-service/app/Services): `auth-service/app/Services`
- [Identity database](https://github.com/2311060512-cloud/quanlyphongkham/blob/main/auth-service/config/database.php): `auth-service/config/database.php`

### Patients and appointments

- [Patient and appointment API](https://github.com/2311060512-cloud/quanlyphongkham/tree/main/appointment-service/app/Http/Controllers): `appointment-service/app/Http/Controllers`
- [Patient and appointment logic](https://github.com/2311060512-cloud/quanlyphongkham/tree/main/appointment-service/app/Services): `appointment-service/app/Services`
- [Appointment database](https://github.com/2311060512-cloud/quanlyphongkham/blob/main/appointment-service/config/database.php): `appointment-service/config/database.php`
- [Appointment notifications](https://github.com/2311060512-cloud/quanlyphongkham/blob/main/appointment-service/app/Notifications/ThongBaoLichHenNotification.php): `appointment-service/app/Notifications/ThongBaoLichHenNotification.php`

### Clinical services

- [Clinical services API](https://github.com/2311060512-cloud/quanlyphongkham/blob/main/clinical-service/app/Http/Controllers/DichVuController.php): `clinical-service/app/Http/Controllers/DichVuController.php`
- [Service orders and results](https://github.com/2311060512-cloud/quanlyphongkham/blob/main/clinical-service/app/Services/DichVuService.php): `clinical-service/app/Services/DichVuService.php`
- [Clinical database](https://github.com/2311060512-cloud/quanlyphongkham/blob/main/clinical-service/config/database.php): `clinical-service/config/database.php`

### Billing and payment

- [Invoice and payment API](https://github.com/2311060512-cloud/quanlyphongkham/blob/main/billing-service/app/Http/Controllers/HoaDonController.php): `billing-service/app/Http/Controllers/HoaDonController.php`
- [Invoice aggregation and payment](https://github.com/2311060512-cloud/quanlyphongkham/blob/main/billing-service/app/Services/HoaDonService.php): `billing-service/app/Services/HoaDonService.php`
- [Billing database](https://github.com/2311060512-cloud/quanlyphongkham/blob/main/billing-service/config/database.php): `billing-service/config/database.php`

### Other components

- **Web / API client**
- **Clinic microservices**

## Connections

- Web / API client → JWT and role middleware: submits requests
- JWT and role middleware → Accounts and authentication: validates JWT
- JWT and role middleware → Reverse proxy and health: authorizes and forwards
- Web / API client → Web portal: uses portal
- Reverse proxy and health → Accounts and authentication: proxies identity routes
- Reverse proxy and health → Patient and appointment API: proxies appointment routes
- Reverse proxy and health → Clinical services API: proxies clinical routes
- Reverse proxy and health → Invoice and payment API: proxies billing routes
- Reverse proxy and health → Clinic microservices: checks liveness
- Accounts and authentication → Identity and provider logic: invokes
- Identity and provider logic → Identity database: reads and writes
- Patient and appointment API → Patient and appointment logic: invokes
- Patient and appointment logic → Appointment database: reads and writes
- Patient and appointment API → Appointment notifications: sends notification
- Clinical services API → Service orders and results: invokes
- Service orders and results → Clinical database: reads and writes
- Invoice and payment API → Invoice aggregation and payment: invokes
- Invoice aggregation and payment → Billing database: reads and writes
- Invoice aggregation and payment → Accounts and authentication: fetches doctor pricing
- Invoice aggregation and payment → Patient and appointment API: fetches appointment
- Invoice aggregation and payment → Clinical services API: fetches clinical charges
