# ngoc-quyen/datn architecture

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

- Interactive diagram: https://gitdiagram.com/ngoc-quyen/datn
- Repository: https://github.com/ngoc-quyen/datn

## Overview

DoctorCare is a web application for discovering doctors and specialties, booking appointments, and managing care; it also provides doctor and administrator workflows. The principal flow is a visitor entering the web routes, browsing doctors, selecting an appointment, and receiving booking information. Authenticated doctors manage schedules and appointments, while administrators manage doctors, users, posts, and schedules. The README documents these capabilities; some view paths it names are not present in the supplied tree. Edges follow the route declarations, sampled imports, and documented flows; unsampled implementation details are not inferred.

Main entry points: [`src/controllers/adminController.js`](https://github.com/ngoc-quyen/datn/blob/master/src/controllers/adminController.js) (Admin pages), [`src/models/index.js`](https://github.com/ngoc-quyen/datn/blob/master/src/models/index.js) (Sequelize models), [`src/routes/web.js`](https://github.com/ngoc-quyen/datn/blob/master/src/routes/web.js) (Web routes), [`src/controllers/homeController.js`](https://github.com/ngoc-quyen/datn/blob/master/src/controllers/homeController.js) (Public pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web entry"]
  node_server["App server<br/>[server.js]"]
  node_routes["Web routes<br/>[web.js]"]
  node_auth["Authentication<br/>[authController.js]"]
end

subgraph group_discovery["Care discovery"]
  node_home["Public pages<br/>[homeController.js]"]
  node_catalog["Doctor and specialty catalog"]
  node_home_data["Home data<br/>[homeService.js]"]
  node_posts["Posts<br/>[postService.js]"]
  node_search["Search indexing"]
end

subgraph group_care["Appointments and care"]
  node_patient_controller["Patient pages"]
  node_patient["Patient bookings and records<br/>[patientService.js]"]
  node_doctor_controller["Doctor pages"]
  node_doctor["Doctor services<br/>[doctorService.js]"]
  node_schedule["Schedule management<br/>[scheduleService.js]"]
  node_chat_controller["Facebook bot endpoint<br/>[botFBController.js]"]
  node_chat["Chat service<br/>[chatFBService.js]"]
end

subgraph group_admin["Operations"]
  node_admin_controller["Admin pages<br/>[adminController.js]"]
  node_users["User management<br/>[userService.js]"]
  node_customer_service["Customer service<br/>[customerService.js]"]
end

subgraph group_platform["Data and integrations"]
  node_models["Sequelize models<br/>[index.js]"]
  node_mysql[("MySQL database")]
  node_mailer["Email delivery<br/>[mailer.js]"]
  node_firebase["Firebase image storage<br/>[imgLoadFirebase.js]"]
  node_elastic["Elasticsearch config<br/>[elastic.js]"]
end

node_visitor(("Visitor or user"))

node_visitor -->|"opens app"| node_server
node_server -->|"mounts routes"| node_routes
node_routes -->|"routes auth"| node_auth
node_routes -->|"routes pages"| node_home
node_routes -->|"routes patients"| node_patient_controller
node_routes -->|"routes doctors"| node_doctor_controller
node_routes -->|"routes admin"| node_admin_controller
node_routes -->|"routes bot"| node_chat_controller
node_home -->|"requests data"| node_home_data
node_home -->|"requests specialties"| node_catalog
node_home -->|"requests doctors"| node_doctor
node_home -->|"requests posts"| node_posts
node_home -->|"uses search"| node_search
node_home -->|"requests booking info"| node_patient
node_patient_controller -->|"requests patient data"| node_patient
node_doctor_controller -->|"requests doctor data"| node_doctor
node_doctor_controller -->|"requests schedules"| node_schedule
node_doctor_controller -->|"requests posts"| node_posts
node_admin_controller -->|"manages patients"| node_patient
node_admin_controller -->|"requests data"| node_home_data
node_admin_controller -->|"manages users"| node_users
node_admin_controller -->|"manages specialties"| node_catalog
node_admin_controller -->|"requests customers"| node_customer_service
node_admin_controller -->|"manages doctors"| node_doctor
node_admin_controller -->|"manages schedules"| node_schedule
node_admin_controller -->|"manages posts"| node_posts
node_chat_controller -->|"dispatches chat"| node_chat
node_home_data -->|"queries models"| node_models
node_catalog -->|"queries models"| node_models
node_posts -->|"queries models"| node_models
node_patient -->|"queries models"| node_models
node_doctor -->|"queries models"| node_models
node_schedule -->|"queries models"| node_models
node_users -->|"queries models"| node_models
node_customer_service -->|"queries models"| node_models
node_models -->|"persists data"| node_mysql
node_patient -->|"sends booking email"| node_mailer
node_doctor -->|"sends attachments"| node_mailer
node_admin_controller -->|"uploads images"| node_firebase
node_firebase -.-> node_mysql
node_posts -->|"syncs search"| node_search
node_search -.->|"uses index"| node_elastic

click node_server "https://github.com/ngoc-quyen/datn/blob/master/src/server.js"
click node_routes "https://github.com/ngoc-quyen/datn/blob/master/src/routes/web.js"
click node_auth "https://github.com/ngoc-quyen/datn/blob/master/src/controllers/authController.js"
click node_home "https://github.com/ngoc-quyen/datn/blob/master/src/controllers/homeController.js"
click node_catalog "https://github.com/ngoc-quyen/datn/blob/master/src/services/specializationService.js"
click node_home_data "https://github.com/ngoc-quyen/datn/blob/master/src/services/homeService.js"
click node_posts "https://github.com/ngoc-quyen/datn/blob/master/src/services/postService.js"
click node_search "https://github.com/ngoc-quyen/datn/blob/master/src/services/syncsElaticService.js"
click node_patient_controller "https://github.com/ngoc-quyen/datn/blob/master/src/controllers/customerController.js"
click node_patient "https://github.com/ngoc-quyen/datn/blob/master/src/services/patientService.js"
click node_doctor_controller "https://github.com/ngoc-quyen/datn/blob/master/src/controllers/doctorController.js"
click node_doctor "https://github.com/ngoc-quyen/datn/blob/master/src/services/doctorService.js"
click node_schedule "https://github.com/ngoc-quyen/datn/blob/master/src/services/scheduleService.js"
click node_admin_controller "https://github.com/ngoc-quyen/datn/blob/master/src/controllers/adminController.js"
click node_users "https://github.com/ngoc-quyen/datn/blob/master/src/services/userService.js"
click node_customer_service "https://github.com/ngoc-quyen/datn/blob/master/src/services/customerService.js"
click node_chat_controller "https://github.com/ngoc-quyen/datn/blob/master/src/controllers/botFBController.js"
click node_chat "https://github.com/ngoc-quyen/datn/blob/master/src/services/chatFBService.js"
click node_models "https://github.com/ngoc-quyen/datn/blob/master/src/models/index.js"
click node_mailer "https://github.com/ngoc-quyen/datn/blob/master/src/config/mailer.js"
click node_firebase "https://github.com/ngoc-quyen/datn/blob/master/src/services/imgLoadFirebase.js"
click node_elastic "https://github.com/ngoc-quyen/datn/blob/master/src/config/elastic.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_server,node_routes,node_auth,node_visitor toneBlue
class node_home,node_catalog,node_home_data,node_posts,node_search toneAmber
class node_patient_controller,node_patient,node_doctor_controller,node_doctor,node_schedule,node_chat_controller,node_chat toneMint
class node_admin_controller,node_users,node_customer_service toneRose
class node_models,node_mysql,node_mailer,node_firebase,node_elastic toneIndigo
```

## Components

### Web entry

- [App server](https://github.com/ngoc-quyen/datn/blob/master/src/server.js): `src/server.js`
- [Web routes](https://github.com/ngoc-quyen/datn/blob/master/src/routes/web.js): `src/routes/web.js`
- [Authentication](https://github.com/ngoc-quyen/datn/blob/master/src/controllers/authController.js): `src/controllers/authController.js`

### Care discovery

- [Public pages](https://github.com/ngoc-quyen/datn/blob/master/src/controllers/homeController.js): `src/controllers/homeController.js`
- [Doctor and specialty catalog](https://github.com/ngoc-quyen/datn/blob/master/src/services/specializationService.js): `src/services/specializationService.js`
- [Home data](https://github.com/ngoc-quyen/datn/blob/master/src/services/homeService.js): `src/services/homeService.js`
- [Posts](https://github.com/ngoc-quyen/datn/blob/master/src/services/postService.js): `src/services/postService.js`
- [Search indexing](https://github.com/ngoc-quyen/datn/blob/master/src/services/syncsElaticService.js): `src/services/syncsElaticService.js`

### Appointments and care

- [Patient pages](https://github.com/ngoc-quyen/datn/blob/master/src/controllers/customerController.js): `src/controllers/customerController.js`
- [Patient bookings and records](https://github.com/ngoc-quyen/datn/blob/master/src/services/patientService.js): `src/services/patientService.js`
- [Doctor pages](https://github.com/ngoc-quyen/datn/blob/master/src/controllers/doctorController.js): `src/controllers/doctorController.js`
- [Doctor services](https://github.com/ngoc-quyen/datn/blob/master/src/services/doctorService.js): `src/services/doctorService.js`
- [Schedule management](https://github.com/ngoc-quyen/datn/blob/master/src/services/scheduleService.js): `src/services/scheduleService.js`
- [Facebook bot endpoint](https://github.com/ngoc-quyen/datn/blob/master/src/controllers/botFBController.js): `src/controllers/botFBController.js`
- [Chat service](https://github.com/ngoc-quyen/datn/blob/master/src/services/chatFBService.js): `src/services/chatFBService.js`

### Operations

- [Admin pages](https://github.com/ngoc-quyen/datn/blob/master/src/controllers/adminController.js): `src/controllers/adminController.js`
- [User management](https://github.com/ngoc-quyen/datn/blob/master/src/services/userService.js): `src/services/userService.js`
- [Customer service](https://github.com/ngoc-quyen/datn/blob/master/src/services/customerService.js): `src/services/customerService.js`

### Data and integrations

- [Sequelize models](https://github.com/ngoc-quyen/datn/blob/master/src/models/index.js): `src/models/index.js`
- **MySQL database**
- [Email delivery](https://github.com/ngoc-quyen/datn/blob/master/src/config/mailer.js): `src/config/mailer.js`
- [Firebase image storage](https://github.com/ngoc-quyen/datn/blob/master/src/services/imgLoadFirebase.js): `src/services/imgLoadFirebase.js`
- [Elasticsearch config](https://github.com/ngoc-quyen/datn/blob/master/src/config/elastic.js): `src/config/elastic.js`

### Other components

- **Visitor or user**

## Connections

- Visitor or user → App server: opens app
- App server → Web routes: mounts routes (evidence: `src/server.js`)
- Web routes → Authentication: routes auth (evidence: `src/routes/web.js`)
- Web routes → Public pages: routes pages (evidence: `src/routes/web.js`)
- Web routes → Patient pages: routes patients (evidence: `src/routes/web.js`)
- Web routes → Doctor pages: routes doctors (evidence: `src/routes/web.js`)
- Web routes → Admin pages: routes admin (evidence: `src/routes/web.js`)
- Web routes → Facebook bot endpoint: routes bot (evidence: `src/routes/web.js`)
- Public pages → Home data: requests data (evidence: `src/controllers/homeController.js`)
- Public pages → Doctor and specialty catalog: requests specialties (evidence: `src/controllers/homeController.js`)
- Public pages → Doctor services: requests doctors (evidence: `src/controllers/homeController.js`)
- Public pages → Posts: requests posts (evidence: `src/controllers/homeController.js`)
- Public pages → Search indexing: uses search (evidence: `src/controllers/homeController.js`)
- Public pages → Patient bookings and records: requests booking info (evidence: `src/controllers/homeController.js`)
- Patient pages → Patient bookings and records: requests patient data (evidence: `src/controllers/customerController.js`)
- Doctor pages → Doctor services: requests doctor data (evidence: `src/controllers/doctorController.js`)
- Doctor pages → Schedule management: requests schedules (evidence: `src/controllers/doctorController.js`)
- Doctor pages → Posts: requests posts (evidence: `src/controllers/doctorController.js`)
- Admin pages → Patient bookings and records: manages patients (evidence: `src/controllers/adminController.js`)
- Admin pages → Home data: requests data (evidence: `src/controllers/adminController.js`)
- Admin pages → User management: manages users (evidence: `src/controllers/adminController.js`)
- Admin pages → Doctor and specialty catalog: manages specialties (evidence: `src/controllers/adminController.js`)
- Admin pages → Customer service: requests customers (evidence: `src/controllers/adminController.js`)
- Admin pages → Doctor services: manages doctors (evidence: `src/controllers/adminController.js`)
- Admin pages → Schedule management: manages schedules (evidence: `src/controllers/adminController.js`)
- Admin pages → Posts: manages posts (evidence: `src/controllers/adminController.js`)
- Facebook bot endpoint → Chat service: dispatches chat (evidence: `src/controllers/botFBController.js`)
- Home data → Sequelize models: queries models (evidence: `src/services/homeService.js`)
- Doctor and specialty catalog → Sequelize models: queries models (evidence: `src/services/specializationService.js`)
- Posts → Sequelize models: queries models (evidence: `src/services/postService.js`)
- Patient bookings and records → Sequelize models: queries models (evidence: `src/services/patientService.js`)
- Doctor services → Sequelize models: queries models (evidence: `src/services/doctorService.js`)
- Schedule management → Sequelize models: queries models (evidence: `src/services/scheduleService.js`)
- User management → Sequelize models: queries models (evidence: `src/services/userService.js`)
- Customer service → Sequelize models: queries models (evidence: `src/services/customerService.js`)
- Sequelize models → MySQL database: persists data (evidence: `src/models/index.js`)
- Patient bookings and records → Email delivery: sends booking email (evidence: `src/services/patientService.js`)
- Doctor services → Email delivery: sends attachments (evidence: `src/services/doctorService.js`)
- Admin pages → Firebase image storage: uploads images (evidence: `src/controllers/adminController.js`)
- Firebase image storage → MySQL database
- Posts → Search indexing: syncs search (evidence: `src/services/postService.js`)
- Search indexing → Elasticsearch config: uses index
