# khoathaycuoi/btl-java architecture

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

- Interactive diagram: https://gitdiagram.com/khoathaycuoi/btl-java
- Repository: https://github.com/khoathaycuoi/btl-java

## Overview

This is a dental-clinic management application with a React role-based portal and a Spring backend. The principal workflow is user sign-in, token-based session and role selection, then role-specific clinic tasks such as appointments, clinical records, prescriptions, and billing. The backend also covers staff, services, attendance, and equipment maintenance. The README provides no capability detail; several subsystem branches below are identified by the supplied file tree, so links involving unsampled code are dashed rather than asserted as verified calls.

Main entry points: [`nha-khoa-backend/src/main/java/com/nhakhoa/backend/repository`](https://github.com/khoathaycuoi/btl-java/tree/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/repository) (Data repositories), [`nha-khoa-frontend/src/App.jsx`](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-frontend/src/App.jsx) (Portal and roles), [`nha-khoa-frontend/src/components/roles/Role_Admin.jsx`](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-frontend/src/components/roles/Role_Admin.jsx) (Admin dashboard), [`nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/AuthService.java`](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/AuthService.java) (Registration and login)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portal["Web portal"]
  node_app["Portal and roles<br/>[App.jsx]"]
  node_auth_api["Auth API client<br/>[Auth.js]"]
  node_user_api["User API client<br/>[User.js]"]
  node_role_admin["Admin dashboard<br/>[Role_Admin.jsx]"]
  node_login_ui["Login and registration<br/>[LoginPage.jsx]"]
end

subgraph group_identity["Identity and users"]
  node_auth_controller["Authentication routes"]
  node_auth_service["Registration and login<br/>[AuthService.java]"]
  node_jwt["JWT service<br/>[JwtService.java]"]
  node_user_controller["User routes"]
  node_user_service["User management<br/>[UserService.java]"]
end

subgraph group_care["Dental care"]
  node_appointment_routes["Appointment routes"]
  node_appointments["Appointment management"]
  node_clinical["Clinical records and prescriptions"]
  node_billing["Invoices"]
end

subgraph group_operations["Clinic operations"]
  node_attendance["Staff attendance"]
  node_equipment["Equipment maintenance<br/>[BaoTriService.java]"]
  node_services["Dental services<br/>[DichVuService.java]"]
  node_service_routes["Service routes"]
end

subgraph group_persistence["Domain data"]
  node_records[("Clinic entities")]
  node_repositories[("Data repositories")]
  node_people[("Person and staff entities<br/>[ConNguoi.java]")]
end

node_visitor(("Clinic user"))
node_backend["Clinic backend"]

node_visitor -->|"uses portal"| node_app
node_app -->|"renders login"| node_login_ui
node_app -->|"logs in"| node_auth_api
node_app -->|"loads profile"| node_user_api
node_app -->|"selects role view"| node_role_admin
node_role_admin -->|"loads profile"| node_user_api
node_auth_api -.->|"HTTP requests"| node_backend
node_user_api -.->|"HTTP requests"| node_backend
node_backend -.->|"serves routes"| node_auth_controller
node_auth_controller -.->|"delegates"| node_auth_service
node_auth_service -->|"generates token"| node_jwt
node_auth_service -->|"uses repositories"| node_repositories
node_user_controller -->|"delegates"| node_user_service
node_user_service -->|"reads and updates"| node_repositories
node_appointment_routes -->|"delegates"| node_appointments
node_appointments -->|"queries appointments"| node_repositories
node_service_routes -->|"delegates"| node_services
node_equipment -->|"reads and writes"| node_repositories
node_auth_service -->|"creates people"| node_people
node_appointments -->|"uses clinic entities"| node_records
node_clinical -.->|"uses data"| node_repositories
node_billing -.->|"uses data"| node_repositories
node_attendance -.->|"uses data"| node_repositories
node_services -.->|"uses data"| node_repositories
node_role_admin -->|"renders records pages"| node_clinical
node_role_admin -->|"renders invoices page"| node_billing
node_role_admin -->|"renders services page"| node_services

click node_app "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-frontend/src/App.jsx"
click node_auth_api "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-frontend/src/api/Auth.js"
click node_user_api "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-frontend/src/api/User.js"
click node_role_admin "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-frontend/src/components/roles/Role_Admin.jsx"
click node_login_ui "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-frontend/src/components/auth/LoginPage.jsx"
click node_backend "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/NhaKhoaBackendApplication.java"
click node_auth_controller "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/controller/AuthController.java"
click node_auth_service "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/AuthService.java"
click node_jwt "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/security/JwtService.java"
click node_user_controller "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/controller/UserController.java"
click node_user_service "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/UserService.java"
click node_appointment_routes "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/controller/LichHenController.java"
click node_appointments "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/LichHenService.java"
click node_clinical "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/MedicalRecordService.java"
click node_billing "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/InvoiceService.java"
click node_attendance "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/ChamCongService.java"
click node_equipment "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/BaoTriService.java"
click node_services "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/DichVuService.java"
click node_service_routes "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/controller/DichVuController.java"
click node_records "https://github.com/khoathaycuoi/btl-java/tree/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/entity"
click node_repositories "https://github.com/khoathaycuoi/btl-java/tree/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/repository"
click node_people "https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/entity/ConNguoi.java"

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_auth_api,node_user_api,node_role_admin,node_login_ui,node_visitor toneBlue
class node_auth_controller,node_auth_service,node_jwt,node_user_controller,node_user_service toneAmber
class node_appointment_routes,node_appointments,node_clinical,node_billing toneMint
class node_attendance,node_equipment,node_services,node_service_routes toneRose
class node_records,node_repositories,node_people toneIndigo
class node_backend toneTeal
```

## Components

### Web portal

- [Portal and roles](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-frontend/src/App.jsx): `nha-khoa-frontend/src/App.jsx`
- [Auth API client](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-frontend/src/api/Auth.js): `nha-khoa-frontend/src/api/Auth.js`
- [User API client](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-frontend/src/api/User.js): `nha-khoa-frontend/src/api/User.js`
- [Admin dashboard](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-frontend/src/components/roles/Role_Admin.jsx): `nha-khoa-frontend/src/components/roles/Role_Admin.jsx`
- [Login and registration](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-frontend/src/components/auth/LoginPage.jsx): `nha-khoa-frontend/src/components/auth/LoginPage.jsx`

### Identity and users

- [Authentication routes](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/controller/AuthController.java): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/controller/AuthController.java`
- [Registration and login](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/AuthService.java): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/AuthService.java`
- [JWT service](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/security/JwtService.java): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/security/JwtService.java`
- [User routes](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/controller/UserController.java): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/controller/UserController.java`
- [User management](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/UserService.java): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/UserService.java`

### Dental care

- [Appointment routes](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/controller/LichHenController.java): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/controller/LichHenController.java`
- [Appointment management](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/LichHenService.java): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/LichHenService.java`
- [Clinical records and prescriptions](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/MedicalRecordService.java): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/MedicalRecordService.java`
- [Invoices](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/InvoiceService.java): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/InvoiceService.java`

### Clinic operations

- [Staff attendance](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/ChamCongService.java): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/ChamCongService.java`
- [Equipment maintenance](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/BaoTriService.java): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/BaoTriService.java`
- [Dental services](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/DichVuService.java): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/DichVuService.java`
- [Service routes](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/controller/DichVuController.java): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/controller/DichVuController.java`

### Domain data

- [Clinic entities](https://github.com/khoathaycuoi/btl-java/tree/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/entity): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/entity`
- [Data repositories](https://github.com/khoathaycuoi/btl-java/tree/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/repository): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/repository`
- [Person and staff entities](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/entity/ConNguoi.java): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/entity/ConNguoi.java`

### Other components

- **Clinic user**
- [Clinic backend](https://github.com/khoathaycuoi/btl-java/blob/main/nha-khoa-backend/src/main/java/com/nhakhoa/backend/NhaKhoaBackendApplication.java): `nha-khoa-backend/src/main/java/com/nhakhoa/backend/NhaKhoaBackendApplication.java`

## Connections

- Clinic user → Portal and roles: uses portal (evidence: `nha-khoa-frontend/src/App.jsx`)
- Portal and roles → Login and registration: renders login (evidence: `nha-khoa-frontend/src/App.jsx`)
- Portal and roles → Auth API client: logs in (evidence: `nha-khoa-frontend/src/App.jsx`)
- Portal and roles → User API client: loads profile (evidence: `nha-khoa-frontend/src/App.jsx`)
- Portal and roles → Admin dashboard: selects role view (evidence: `nha-khoa-frontend/src/App.jsx`)
- Admin dashboard → User API client: loads profile (evidence: `nha-khoa-frontend/src/components/roles/Role_Admin.jsx`)
- Auth API client → Clinic backend: HTTP requests
- User API client → Clinic backend: HTTP requests
- Clinic backend → Authentication routes: serves routes
- Authentication routes → Registration and login: delegates
- Registration and login → JWT service: generates token (evidence: `nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/AuthService.java`)
- Registration and login → Data repositories: uses repositories (evidence: `nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/AuthService.java`)
- User routes → User management: delegates (evidence: `nha-khoa-backend/src/main/java/com/nhakhoa/backend/controller/UserController.java`)
- User management → Data repositories: reads and updates (evidence: `nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/UserService.java`)
- Appointment routes → Appointment management: delegates (evidence: `nha-khoa-backend/src/main/java/com/nhakhoa/backend/controller/LichHenController.java`)
- Appointment management → Data repositories: queries appointments (evidence: `nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/LichHenService.java`)
- Service routes → Dental services: delegates (evidence: `nha-khoa-backend/src/main/java/com/nhakhoa/backend/controller/DichVuController.java`)
- Equipment maintenance → Data repositories: reads and writes (evidence: `nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/BaoTriService.java`)
- Registration and login → Person and staff entities: creates people (evidence: `nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/AuthService.java`)
- Appointment management → Clinic entities: uses clinic entities (evidence: `nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/LichHenService.java`)
- Clinical records and prescriptions → Data repositories: uses data
- Invoices → Data repositories: uses data
- Staff attendance → Data repositories: uses data (evidence: `nha-khoa-backend/src/main/java/com/nhakhoa/backend/service/ChamCongService.java`)
- Dental services → Data repositories: uses data
- Admin dashboard → Clinical records and prescriptions: renders records pages (evidence: `nha-khoa-frontend/src/components/roles/Role_Admin.jsx`)
- Admin dashboard → Invoices: renders invoices page (evidence: `nha-khoa-frontend/src/components/roles/Role_Admin.jsx`)
- Admin dashboard → Dental services: renders services page (evidence: `nha-khoa-frontend/src/components/roles/Role_Admin.jsx`)
