# jackson04-dev/dentalapp-database architecture

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

- Interactive diagram: https://gitdiagram.com/jackson04-dev/dentalapp-database
- Repository: https://github.com/jackson04-dev/dentalapp-database

## Overview

This repository is the database schema for a dental-clinic management system. Its main workflow runs from patient and staff identity through appointment scheduling and check-in, clinical records and treatment, then invoicing and payment. The schema also supports service and treatment-plan catalogs, supplier-linked products, and inventory intake and usage. The README describes these relationships and operational flows; no source excerpts were provided. Although it describes a payment table, none appears in the supplied tree, so it is not represented as a repository component.

Main entry points: [`tables/level_3/18_lich_hen.sql`](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_3/18_lich_hen.sql) (Appointments), [`tables/level_0/01_tai_khoan.sql`](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_0/01_tai_khoan.sql) (Accounts), [`tables/level_4/20_ho_so_benh_an.sql`](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_4/20_ho_so_benh_an.sql) (Medical Records), [`tables/level_4/21_hoa_don.sql`](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_4/21_hoa_don.sql) (Invoices)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and Profiles"]
  node_account[("Accounts<br/>[01_tai_khoan.sql]")]
  node_patient[("Patients<br/>[09_benh_nhan.sql]")]
  node_dentist[("Dentists<br/>[10_nha_si.sql]")]
  node_staff[("Staff<br/>[11_nhan_vien.sql]")]
  node_audit_log[("Audit Log<br/>[14_audit_log.sql]")]
end

subgraph group_catalog["Catalog and Inventory"]
  node_service[("Services<br/>[02_dich_vu.sql]")]
  node_service_detail[("Service Details")]
  node_product[("Products<br/>[03_san_pham.sql]")]
  node_supplier[("Suppliers")]
  node_product_supplier[("Supplier Products")]
  node_plan_template[("Plan Templates<br/>[05_phac_do_mau.sql]")]
  node_plan_template_detail[("Template Steps")]
  node_promotion[("Promotions<br/>[06_khuyen_mai.sql]")]
  node_stock_receipt[("Stock Receipts")]
  node_stock_receipt_detail[("Receipt Details")]
end

subgraph group_scheduling["Scheduling"]
  node_treatment_room[("Treatment Rooms")]
  node_shift[("Dentist Shifts<br/>[15_ca_lam_viec.sql]")]
  node_appointment[("Appointments<br/>[18_lich_hen.sql]")]
end

subgraph group_clinical["Clinical Care"]
  node_medical_record[("Medical Records")]
  node_treatment_service[("Treatment Services")]
  node_used_material[("Used Materials")]
  node_prescription[("Prescriptions<br/>[24_don_thuoc.sql]")]
  node_prescription_detail[("Prescription Details")]
  node_treatment_plan[("Treatment Plans")]
  node_plan_stage[("Plan Stages")]
end

subgraph group_finance["Billing"]
  node_invoice[("Invoices<br/>[21_hoa_don.sql]")]
end

node_patient_actor(("Patient / App"))
node_clinic_staff_actor(("Clinic Staff"))
node_dentist_actor(("Dentist"))

node_patient_actor -->|"registers"| node_account
node_account -->|"profiles"| node_patient
node_clinic_staff_actor -->|"creates accounts"| node_account
node_account -->|"creates profile"| node_dentist
node_account -->|"creates profile"| node_staff
node_service -->|"has offerings"| node_service_detail
node_plan_template -->|"has steps"| node_plan_template_detail
node_product_supplier -->|"links products"| node_product
node_product_supplier -->|"links suppliers"| node_supplier
node_clinic_staff_actor -->|"schedules"| node_shift
node_shift -->|"assigns room"| node_treatment_room
node_shift -->|"assigns dentist"| node_dentist
node_patient_actor -->|"books"| node_appointment
node_appointment -->|"identifies patient"| node_patient
node_appointment -->|"selects dentist"| node_dentist
node_appointment -->|"selects service"| node_service
node_dentist_actor -->|"documents visit"| node_medical_record
node_appointment -->|"starts visit record"| node_medical_record
node_medical_record -->|"records services"| node_treatment_service
node_medical_record -->|"records consumption"| node_used_material
node_medical_record -->|"records prescription"| node_prescription
node_prescription -->|"contains items"| node_prescription_detail
node_dentist_actor -->|"creates plan"| node_treatment_plan
node_plan_template -->|"seeds plan"| node_treatment_plan
node_treatment_plan -->|"defines stages"| node_plan_stage
node_clinic_staff_actor -->|"creates receipt"| node_stock_receipt
node_stock_receipt -->|"records lots"| node_stock_receipt_detail
node_stock_receipt_detail -->|"updates stock"| node_product
node_used_material -->|"deducts stock"| node_product
node_clinic_staff_actor -->|"issues invoice"| node_invoice
node_invoice -->|"references visit"| node_appointment
node_invoice -->|"may bill plan"| node_treatment_plan
node_invoice -->|"settles stages"| node_plan_stage

click node_account "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_0/01_tai_khoan.sql"
click node_patient "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_1/09_benh_nhan.sql"
click node_dentist "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_1/10_nha_si.sql"
click node_staff "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_1/11_nhan_vien.sql"
click node_service "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_0/02_dich_vu.sql"
click node_service_detail "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_1/08_chi_tiet_dich_vu.sql"
click node_product "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_0/03_san_pham.sql"
click node_supplier "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_0/04_nha_cung_cap.sql"
click node_product_supplier "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_1/12_san_pham_nha_cung_cap.sql"
click node_plan_template "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_0/05_phac_do_mau.sql"
click node_plan_template_detail "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_1/13_chi_tiet_phac_do_mau.sql"
click node_promotion "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_0/06_khuyen_mai.sql"
click node_treatment_room "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_0/07_phong_dieu_tri.sql"
click node_shift "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_2/15_ca_lam_viec.sql"
click node_appointment "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_3/18_lich_hen.sql"
click node_medical_record "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_4/20_ho_so_benh_an.sql"
click node_treatment_service "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_5/23_dich_vu_dieu_tri.sql"
click node_used_material "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_5/25_vat_tu_su_dung.sql"
click node_prescription "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_5/24_don_thuoc.sql"
click node_prescription_detail "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_6/26_chi_tiet_don_thuoc.sql"
click node_treatment_plan "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_2/17_phac_do_dieu_tri.sql"
click node_plan_stage "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_4/22_giai_doan_phac_do.sql"
click node_stock_receipt "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_2/16_phieu_nhap_kho.sql"
click node_stock_receipt_detail "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_3/19_chi_tiet_nhap_kho.sql"
click node_invoice "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_4/21_hoa_don.sql"
click node_audit_log "https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_1/14_audit_log.sql"

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_account,node_patient,node_dentist,node_staff,node_audit_log toneBlue
class node_service,node_service_detail,node_product,node_supplier,node_product_supplier,node_plan_template,node_plan_template_detail,node_promotion,node_stock_receipt,node_stock_receipt_detail toneAmber
class node_treatment_room,node_shift,node_appointment toneMint
class node_medical_record,node_treatment_service,node_used_material,node_prescription,node_prescription_detail,node_treatment_plan,node_plan_stage toneRose
class node_invoice,node_patient_actor,node_clinic_staff_actor,node_dentist_actor toneIndigo
```

## Components

### Identity and Profiles

- [Accounts](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_0/01_tai_khoan.sql): `tables/level_0/01_tai_khoan.sql`
- [Patients](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_1/09_benh_nhan.sql): `tables/level_1/09_benh_nhan.sql`
- [Dentists](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_1/10_nha_si.sql): `tables/level_1/10_nha_si.sql`
- [Staff](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_1/11_nhan_vien.sql): `tables/level_1/11_nhan_vien.sql`
- [Audit Log](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_1/14_audit_log.sql): `tables/level_1/14_audit_log.sql`

### Catalog and Inventory

- [Services](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_0/02_dich_vu.sql): `tables/level_0/02_dich_vu.sql`
- [Service Details](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_1/08_chi_tiet_dich_vu.sql): `tables/level_1/08_chi_tiet_dich_vu.sql`
- [Products](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_0/03_san_pham.sql): `tables/level_0/03_san_pham.sql`
- [Suppliers](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_0/04_nha_cung_cap.sql): `tables/level_0/04_nha_cung_cap.sql`
- [Supplier Products](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_1/12_san_pham_nha_cung_cap.sql): `tables/level_1/12_san_pham_nha_cung_cap.sql`
- [Plan Templates](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_0/05_phac_do_mau.sql): `tables/level_0/05_phac_do_mau.sql`
- [Template Steps](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_1/13_chi_tiet_phac_do_mau.sql): `tables/level_1/13_chi_tiet_phac_do_mau.sql`
- [Promotions](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_0/06_khuyen_mai.sql): `tables/level_0/06_khuyen_mai.sql`
- [Stock Receipts](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_2/16_phieu_nhap_kho.sql): `tables/level_2/16_phieu_nhap_kho.sql`
- [Receipt Details](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_3/19_chi_tiet_nhap_kho.sql): `tables/level_3/19_chi_tiet_nhap_kho.sql`

### Scheduling

- [Treatment Rooms](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_0/07_phong_dieu_tri.sql): `tables/level_0/07_phong_dieu_tri.sql`
- [Dentist Shifts](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_2/15_ca_lam_viec.sql): `tables/level_2/15_ca_lam_viec.sql`
- [Appointments](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_3/18_lich_hen.sql): `tables/level_3/18_lich_hen.sql`

### Clinical Care

- [Medical Records](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_4/20_ho_so_benh_an.sql): `tables/level_4/20_ho_so_benh_an.sql`
- [Treatment Services](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_5/23_dich_vu_dieu_tri.sql): `tables/level_5/23_dich_vu_dieu_tri.sql`
- [Used Materials](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_5/25_vat_tu_su_dung.sql): `tables/level_5/25_vat_tu_su_dung.sql`
- [Prescriptions](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_5/24_don_thuoc.sql): `tables/level_5/24_don_thuoc.sql`
- [Prescription Details](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_6/26_chi_tiet_don_thuoc.sql): `tables/level_6/26_chi_tiet_don_thuoc.sql`
- [Treatment Plans](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_2/17_phac_do_dieu_tri.sql): `tables/level_2/17_phac_do_dieu_tri.sql`
- [Plan Stages](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_4/22_giai_doan_phac_do.sql): `tables/level_4/22_giai_doan_phac_do.sql`

### Billing

- [Invoices](https://github.com/jackson04-dev/dentalapp-database/blob/main/tables/level_4/21_hoa_don.sql): `tables/level_4/21_hoa_don.sql`

### Other components

- **Patient / App**
- **Clinic Staff**
- **Dentist**

## Connections

- Patient / App → Accounts: registers (evidence: `readme.md`)
- Accounts → Patients: profiles (evidence: `readme.md`)
- Clinic Staff → Accounts: creates accounts (evidence: `readme.md`)
- Accounts → Dentists: creates profile (evidence: `readme.md`)
- Accounts → Staff: creates profile (evidence: `readme.md`)
- Services → Service Details: has offerings (evidence: `readme.md`)
- Plan Templates → Template Steps: has steps (evidence: `readme.md`)
- Supplier Products → Products: links products (evidence: `readme.md`)
- Supplier Products → Suppliers: links suppliers (evidence: `readme.md`)
- Clinic Staff → Dentist Shifts: schedules (evidence: `readme.md`)
- Dentist Shifts → Treatment Rooms: assigns room (evidence: `readme.md`)
- Dentist Shifts → Dentists: assigns dentist (evidence: `readme.md`)
- Patient / App → Appointments: books (evidence: `readme.md`)
- Appointments → Patients: identifies patient (evidence: `readme.md`)
- Appointments → Dentists: selects dentist (evidence: `readme.md`)
- Appointments → Services: selects service (evidence: `readme.md`)
- Dentist → Medical Records: documents visit (evidence: `readme.md`)
- Appointments → Medical Records: starts visit record (evidence: `readme.md`)
- Medical Records → Treatment Services: records services (evidence: `readme.md`)
- Medical Records → Used Materials: records consumption (evidence: `readme.md`)
- Medical Records → Prescriptions: records prescription (evidence: `readme.md`)
- Prescriptions → Prescription Details: contains items (evidence: `readme.md`)
- Dentist → Treatment Plans: creates plan (evidence: `readme.md`)
- Plan Templates → Treatment Plans: seeds plan (evidence: `readme.md`)
- Treatment Plans → Plan Stages: defines stages (evidence: `readme.md`)
- Clinic Staff → Stock Receipts: creates receipt (evidence: `readme.md`)
- Stock Receipts → Receipt Details: records lots (evidence: `readme.md`)
- Receipt Details → Products: updates stock (evidence: `readme.md`)
- Used Materials → Products: deducts stock (evidence: `readme.md`)
- Clinic Staff → Invoices: issues invoice (evidence: `readme.md`)
- Invoices → Appointments: references visit (evidence: `readme.md`)
- Invoices → Treatment Plans: may bill plan (evidence: `readme.md`)
- Invoices → Plan Stages: settles stages (evidence: `readme.md`)
