# tuanno1825-max/ktv-pat architecture

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

- Interactive diagram: https://gitdiagram.com/tuanno1825-max/ktv-pat
- Repository: https://github.com/tuanno1825-max/ktv-pat

## Overview

This is a Vietnamese karaoke-room booking and customer-management web application. Customers register or sign in, browse venues, place and track reservations, then use account, VIP, review, and community features; staff manage bookings, refunds, venues, and revenue. Express routes coordinate Mongoose models, with signed-cookie session middleware controlling internal access. The excerpts and source index establish route-to-model and server-to-router wiring; browser API connections and several unsampled capabilities are shown as unverified rather than asserted.

Main entry points: [`server.js`](https://github.com/tuanno1825-max/ktv-pat/blob/main/server.js) (Express Server), [`routes/quan-ly-tai-khoan-routes.js`](https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/quan-ly-tai-khoan-routes.js) (Account Management), [`routes/don-hang-routes.js`](https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/don-hang-routes.js) (Booking and Orders), [`models/nguoi-dung-model.js`](https://github.com/tuanno1825-max/ktv-pat/blob/main/models/nguoi-dung-model.js) (Customer Records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Customer and Staff UI"]
  node_booking_ui["Booking UI<br/>[datphong.js]"]
  node_account_ui["Customer Account UI<br/>[tai-khoan-khach.js]"]
  node_community_ui["Community UI<br/>[cong-dong.js]"]
  node_orders_ui["Order Admin UI"]
  node_refund_ui["Refund Admin UI"]
  node_revenue_ui["Revenue UI"]
  node_venues_ui["Venue Admin UI<br/>[quan-ly-quan.js]"]
  node_vip_ui["VIP Offers UI<br/>[uu-dai-vip.js]"]
end

subgraph group_api["Application Routes"]
  node_server["Express Server<br/>[server.js]"]
  node_auth_routes["Authentication Routes<br/>[xac-thuc-routes.js]"]
  node_venue_routes["Venue Routes<br/>[quan-routes.js]"]
  node_order_routes["Booking and Orders<br/>[don-hang-routes.js]"]
  node_revenue_routes["Revenue Routes"]
  node_refund_routes["Refund Routes"]
  node_review_routes["Review Routes<br/>[danh-gia-routes.js]"]
  node_forum_routes["Community Routes<br/>[dien-dan-routes.js]"]
  node_accounts_routes["Account Management"]
end

subgraph group_domain["Domain Data"]
  node_venues[("Venue Records<br/>[admin-models.js]")]
  node_orders[("Booking Records<br/>[don-hang-models.js]")]
  node_users[("Customer Records")]
  node_reviews[("Review Records<br/>[danh-gia-model.js]")]
  node_forum[("Forum Posts<br/>[dien-dan-model.js]")]
  node_refunds[("Refund Records<br/>[hoan-tien-model.js]")]
  node_notifications[("Notifications<br/>[thong-bao-model.js]")]
  node_password_requests[("Password Requests")]
  node_internal_accounts[("Staff Accounts")]
  node_vip_payments[("VIP Payments")]
  node_counter[("Customer ID Counter<br/>[bo-dem-model.js]")]
end

subgraph group_access["Identity and Access"]
  node_session["Session Middleware<br/>[xac-thuc-noi-bo.js]"]
end

node_customer(("Customer"))
node_staff(("Staff"))
node_mongo[("MongoDB")]

node_server -->|"mounts"| node_auth_routes
node_server -->|"mounts"| node_venue_routes
node_server -->|"mounts"| node_order_routes
node_server -->|"mounts"| node_revenue_routes
node_server -->|"mounts"| node_refund_routes
node_server -->|"mounts"| node_review_routes
node_server -->|"mounts"| node_forum_routes
node_server -->|"mounts"| node_accounts_routes
node_server -->|"uses"| node_session
node_server -->|"connects"| node_mongo
node_auth_routes -->|"reads and writes"| node_users
node_auth_routes -->|"reads"| node_orders
node_auth_routes -->|"reads"| node_internal_accounts
node_auth_routes -->|"uses"| node_password_requests
node_order_routes -->|"reads and writes"| node_orders
node_order_routes -->|"checks customer"| node_users
node_order_routes -->|"uses venue"| node_venues
node_order_routes -->|"uses"| node_notifications
node_order_routes -->|"checks session"| node_session
node_refund_routes -->|"reads and writes"| node_refunds
node_refund_routes -->|"reads"| node_orders
node_refund_routes -->|"reads"| node_users
node_refund_routes -->|"reads"| node_notifications
node_refund_routes -->|"checks access"| node_session
node_forum_routes -->|"reads and writes"| node_forum
node_forum_routes -->|"reads"| node_users
node_forum_routes -->|"uses venue"| node_venues
node_forum_routes -->|"uses"| node_notifications
node_forum_routes -->|"reads session"| node_session
node_accounts_routes -->|"manages"| node_users
node_accounts_routes -->|"summarizes"| node_orders
node_accounts_routes -->|"deletes"| node_notifications
node_accounts_routes -->|"updates"| node_refunds
node_accounts_routes -->|"manages"| node_reviews
node_accounts_routes -->|"manages"| node_forum
node_accounts_routes -->|"reads"| node_password_requests
node_revenue_routes -->|"reads"| node_orders
node_venue_routes -->|"manages"| node_venues
node_venue_routes -->|"uses"| node_reviews
node_review_routes -->|"manages"| node_reviews
node_review_routes -->|"uses"| node_venues
node_review_routes -->|"checks booking"| node_orders
node_review_routes -->|"uses"| node_users
node_users -->|"allocates IDs"| node_counter
node_customer -.->|"requests pages"| node_server
node_staff -.->|"requests pages"| node_server
node_booking_ui -.->|"calls API"| node_order_routes
node_account_ui -.->|"calls API"| node_auth_routes

click node_booking_ui "https://github.com/tuanno1825-max/ktv-pat/blob/main/public/js/datphong.js"
click node_account_ui "https://github.com/tuanno1825-max/ktv-pat/blob/main/public/js/tai-khoan-khach.js"
click node_community_ui "https://github.com/tuanno1825-max/ktv-pat/blob/main/public/js/cong-dong.js"
click node_orders_ui "https://github.com/tuanno1825-max/ktv-pat/blob/main/public/js/quan-ly-don-hang.js"
click node_refund_ui "https://github.com/tuanno1825-max/ktv-pat/blob/main/public/js/quan-ly-hoan-tien.js"
click node_revenue_ui "https://github.com/tuanno1825-max/ktv-pat/blob/main/public/js/quan-ly-doanh-thu.js"
click node_venues_ui "https://github.com/tuanno1825-max/ktv-pat/blob/main/public/js/quan-ly-quan.js"
click node_vip_ui "https://github.com/tuanno1825-max/ktv-pat/blob/main/public/js/uu-dai-vip.js"
click node_server "https://github.com/tuanno1825-max/ktv-pat/blob/main/server.js"
click node_auth_routes "https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/xac-thuc-routes.js"
click node_venue_routes "https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/quan-routes.js"
click node_order_routes "https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/don-hang-routes.js"
click node_revenue_routes "https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/doanh-thu-routes.js"
click node_refund_routes "https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/hoan-tien-routes.js"
click node_review_routes "https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/danh-gia-routes.js"
click node_forum_routes "https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/dien-dan-routes.js"
click node_accounts_routes "https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/quan-ly-tai-khoan-routes.js"
click node_venues "https://github.com/tuanno1825-max/ktv-pat/blob/main/models/admin-models.js"
click node_orders "https://github.com/tuanno1825-max/ktv-pat/blob/main/models/don-hang-models.js"
click node_users "https://github.com/tuanno1825-max/ktv-pat/blob/main/models/nguoi-dung-model.js"
click node_reviews "https://github.com/tuanno1825-max/ktv-pat/blob/main/models/danh-gia-model.js"
click node_forum "https://github.com/tuanno1825-max/ktv-pat/blob/main/models/dien-dan-model.js"
click node_refunds "https://github.com/tuanno1825-max/ktv-pat/blob/main/models/hoan-tien-model.js"
click node_notifications "https://github.com/tuanno1825-max/ktv-pat/blob/main/models/thong-bao-model.js"
click node_password_requests "https://github.com/tuanno1825-max/ktv-pat/blob/main/models/yeu-cau-mat-khau-model.js"
click node_internal_accounts "https://github.com/tuanno1825-max/ktv-pat/blob/main/models/tai-khoan-models.js"
click node_vip_payments "https://github.com/tuanno1825-max/ktv-pat/blob/main/models/goi-vip-thanh-toan-model.js"
click node_counter "https://github.com/tuanno1825-max/ktv-pat/blob/main/models/bo-dem-model.js"
click node_session "https://github.com/tuanno1825-max/ktv-pat/blob/main/middleware/xac-thuc-noi-bo.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_booking_ui,node_account_ui,node_community_ui,node_orders_ui,node_refund_ui,node_revenue_ui,node_venues_ui,node_vip_ui toneBlue
class node_server,node_auth_routes,node_venue_routes,node_order_routes,node_revenue_routes,node_refund_routes,node_review_routes,node_forum_routes,node_accounts_routes,node_mongo toneAmber
class node_venues,node_orders,node_users,node_reviews,node_forum,node_refunds,node_notifications,node_password_requests,node_internal_accounts,node_vip_payments,node_counter toneMint
class node_session toneRose
class node_customer,node_staff toneIndigo
```

## Components

### Customer and Staff UI

- [Booking UI](https://github.com/tuanno1825-max/ktv-pat/blob/main/public/js/datphong.js): `public/js/datphong.js`
- [Customer Account UI](https://github.com/tuanno1825-max/ktv-pat/blob/main/public/js/tai-khoan-khach.js): `public/js/tai-khoan-khach.js`
- [Community UI](https://github.com/tuanno1825-max/ktv-pat/blob/main/public/js/cong-dong.js): `public/js/cong-dong.js`
- [Order Admin UI](https://github.com/tuanno1825-max/ktv-pat/blob/main/public/js/quan-ly-don-hang.js): `public/js/quan-ly-don-hang.js`
- [Refund Admin UI](https://github.com/tuanno1825-max/ktv-pat/blob/main/public/js/quan-ly-hoan-tien.js): `public/js/quan-ly-hoan-tien.js`
- [Revenue UI](https://github.com/tuanno1825-max/ktv-pat/blob/main/public/js/quan-ly-doanh-thu.js): `public/js/quan-ly-doanh-thu.js`
- [Venue Admin UI](https://github.com/tuanno1825-max/ktv-pat/blob/main/public/js/quan-ly-quan.js): `public/js/quan-ly-quan.js`
- [VIP Offers UI](https://github.com/tuanno1825-max/ktv-pat/blob/main/public/js/uu-dai-vip.js): `public/js/uu-dai-vip.js`

### Application Routes

- [Express Server](https://github.com/tuanno1825-max/ktv-pat/blob/main/server.js): `server.js`
- [Authentication Routes](https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/xac-thuc-routes.js): `routes/xac-thuc-routes.js`
- [Venue Routes](https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/quan-routes.js): `routes/quan-routes.js`
- [Booking and Orders](https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/don-hang-routes.js): `routes/don-hang-routes.js`
- [Revenue Routes](https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/doanh-thu-routes.js): `routes/doanh-thu-routes.js`
- [Refund Routes](https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/hoan-tien-routes.js): `routes/hoan-tien-routes.js`
- [Review Routes](https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/danh-gia-routes.js): `routes/danh-gia-routes.js`
- [Community Routes](https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/dien-dan-routes.js): `routes/dien-dan-routes.js`
- [Account Management](https://github.com/tuanno1825-max/ktv-pat/blob/main/routes/quan-ly-tai-khoan-routes.js): `routes/quan-ly-tai-khoan-routes.js`

### Domain Data

- [Venue Records](https://github.com/tuanno1825-max/ktv-pat/blob/main/models/admin-models.js): `models/admin-models.js`
- [Booking Records](https://github.com/tuanno1825-max/ktv-pat/blob/main/models/don-hang-models.js): `models/don-hang-models.js`
- [Customer Records](https://github.com/tuanno1825-max/ktv-pat/blob/main/models/nguoi-dung-model.js): `models/nguoi-dung-model.js`
- [Review Records](https://github.com/tuanno1825-max/ktv-pat/blob/main/models/danh-gia-model.js): `models/danh-gia-model.js`
- [Forum Posts](https://github.com/tuanno1825-max/ktv-pat/blob/main/models/dien-dan-model.js): `models/dien-dan-model.js`
- [Refund Records](https://github.com/tuanno1825-max/ktv-pat/blob/main/models/hoan-tien-model.js): `models/hoan-tien-model.js`
- [Notifications](https://github.com/tuanno1825-max/ktv-pat/blob/main/models/thong-bao-model.js): `models/thong-bao-model.js`
- [Password Requests](https://github.com/tuanno1825-max/ktv-pat/blob/main/models/yeu-cau-mat-khau-model.js): `models/yeu-cau-mat-khau-model.js`
- [Staff Accounts](https://github.com/tuanno1825-max/ktv-pat/blob/main/models/tai-khoan-models.js): `models/tai-khoan-models.js`
- [VIP Payments](https://github.com/tuanno1825-max/ktv-pat/blob/main/models/goi-vip-thanh-toan-model.js): `models/goi-vip-thanh-toan-model.js`
- [Customer ID Counter](https://github.com/tuanno1825-max/ktv-pat/blob/main/models/bo-dem-model.js): `models/bo-dem-model.js`

### Identity and Access

- [Session Middleware](https://github.com/tuanno1825-max/ktv-pat/blob/main/middleware/xac-thuc-noi-bo.js): `middleware/xac-thuc-noi-bo.js`

### Other components

- **Customer**
- **Staff**
- **MongoDB**

## Connections

- Express Server → Authentication Routes: mounts (evidence: `server.js`)
- Express Server → Venue Routes: mounts (evidence: `server.js`)
- Express Server → Booking and Orders: mounts (evidence: `server.js`)
- Express Server → Revenue Routes: mounts (evidence: `server.js`)
- Express Server → Refund Routes: mounts (evidence: `server.js`)
- Express Server → Review Routes: mounts (evidence: `server.js`)
- Express Server → Community Routes: mounts (evidence: `server.js`)
- Express Server → Account Management: mounts (evidence: `server.js`)
- Express Server → Session Middleware: uses (evidence: `server.js`)
- Express Server → MongoDB: connects (evidence: `server.js`)
- Authentication Routes → Customer Records: reads and writes (evidence: `routes/xac-thuc-routes.js`)
- Authentication Routes → Booking Records: reads (evidence: `routes/xac-thuc-routes.js`)
- Authentication Routes → Staff Accounts: reads (evidence: `routes/xac-thuc-routes.js`)
- Authentication Routes → Password Requests: uses (evidence: `routes/xac-thuc-routes.js`)
- Booking and Orders → Booking Records: reads and writes (evidence: `routes/don-hang-routes.js`)
- Booking and Orders → Customer Records: checks customer (evidence: `routes/don-hang-routes.js`)
- Booking and Orders → Venue Records: uses venue (evidence: `routes/don-hang-routes.js`)
- Booking and Orders → Notifications: uses (evidence: `routes/don-hang-routes.js`)
- Booking and Orders → Session Middleware: checks session (evidence: `routes/don-hang-routes.js`)
- Refund Routes → Refund Records: reads and writes (evidence: `routes/hoan-tien-routes.js`)
- Refund Routes → Booking Records: reads (evidence: `routes/hoan-tien-routes.js`)
- Refund Routes → Customer Records: reads (evidence: `routes/hoan-tien-routes.js`)
- Refund Routes → Notifications: reads (evidence: `routes/hoan-tien-routes.js`)
- Refund Routes → Session Middleware: checks access (evidence: `routes/hoan-tien-routes.js`)
- Community Routes → Forum Posts: reads and writes (evidence: `routes/dien-dan-routes.js`)
- Community Routes → Customer Records: reads (evidence: `routes/dien-dan-routes.js`)
- Community Routes → Venue Records: uses venue (evidence: `routes/dien-dan-routes.js`)
- Community Routes → Notifications: uses (evidence: `routes/dien-dan-routes.js`)
- Community Routes → Session Middleware: reads session (evidence: `routes/dien-dan-routes.js`)
- Account Management → Customer Records: manages (evidence: `routes/quan-ly-tai-khoan-routes.js`)
- Account Management → Booking Records: summarizes (evidence: `routes/quan-ly-tai-khoan-routes.js`)
- Account Management → Notifications: deletes (evidence: `routes/quan-ly-tai-khoan-routes.js`)
- Account Management → Refund Records: updates (evidence: `routes/quan-ly-tai-khoan-routes.js`)
- Account Management → Review Records: manages (evidence: `routes/quan-ly-tai-khoan-routes.js`)
- Account Management → Forum Posts: manages (evidence: `routes/quan-ly-tai-khoan-routes.js`)
- Account Management → Password Requests: reads (evidence: `routes/quan-ly-tai-khoan-routes.js`)
- Revenue Routes → Booking Records: reads (evidence: `routes/doanh-thu-routes.js`)
- Venue Routes → Venue Records: manages (evidence: `routes/quan-routes.js`)
- Venue Routes → Review Records: uses (evidence: `routes/quan-routes.js`)
- Review Routes → Review Records: manages (evidence: `routes/danh-gia-routes.js`)
- Review Routes → Venue Records: uses (evidence: `routes/danh-gia-routes.js`)
- Review Routes → Booking Records: checks booking (evidence: `routes/danh-gia-routes.js`)
- Review Routes → Customer Records: uses (evidence: `routes/danh-gia-routes.js`)
- Customer Records → Customer ID Counter: allocates IDs (evidence: `models/nguoi-dung-model.js`)
- Customer → Express Server: requests pages
- Staff → Express Server: requests pages
- Booking UI → Booking and Orders: calls API
- Customer Account UI → Authentication Routes: calls API
