F
PlatformCập nhật 2026-06-30 · platform/DOMAIN-MODEL.md

Domain Model — Mô hình miền lõi

Abstraction dùng chung cho mọi vertical. Nguyên tắc: Reservable Resource + Reservation, không khoá vào "Hotel/Room". Vertical extend, không thay.

Khái niệm lõi (đã hiện thực ở Booking module)

EntityÝ nghĩaVertical extend
ListingTài nguyên có thể đặt (lưu trú/villa/homestay/resort/camping...)Tour, Experience, TreatmentPackage
Inventory / UnitĐơn vị + tồn kho (loại phòng, slot)Bàn (F&B), ghế tour, slot lịch điều trị
ReservationĐơn đặt (booking)FnbOrder, Appointment/CarePlan
Guest / CustomerNgười đặtPatientProfile
ReviewĐánh giáMedicalReview (Travel Intelligence chấm trust)
PaymentThanh toán (polymorphic target)Dùng chung mọi vertical

"Booking Engine không nên biết Hotel. Booking Engine chỉ biết Reservable Resource." — nguyên tắc gốc, giữ bất biến.

Spine domain (dùng chung)

Tenant · TenantSettings · User · Role · Membership · Payment · PayoutRequest · Notification · MediaAsset · CmsPage · Coupon · AuditLog.

Cách vertical extend (ví dụ)

Reservable (lõi)
 ├─ Listing (lưu trú)            ← Booking module
 ├─ TourProduct                  ← Tour vertical
 ├─ ExperienceProduct            ← Experience vertical
 └─ TreatmentPackage             ← Medical Tourism vertical

Reservation (lõi)
 ├─ StayReservation              ← Booking
 ├─ TourReservation              ← Tour
 ├─ FnbOrder                     ← F&B
 └─ Appointment / CarePlan       ← Medical Tourism

Customer (lõi)
 └─ PatientProfile (PHI)         ← Medical Tourism

Quy tắc

  • Extend, đừng nhân bản: thêm bảng/discriminator/extension, không tạo entity song song khoá theo ngành.
  • Port cho mọi IO: repository/gateway interface; domain không biết Prisma/HTTP/LLM.
  • View-model cho UI: map domain → props; component không đụng raw data.
  • Travel Intelligence domain tách: Place/KnowledgeFact/Score/EvaluationReport sống ở engine, nối qua API/port — không trộn vào domain giao dịch.

Hiện trạng

src/lib/domain/models đã có Listing/Inventory/Reservation/Review/Guest + spine (Tenant/User/Payment...) ở mức frontend. Đây là nền để Phase 2 sinh Prisma schema và các vertical extend.