Source document
docs/knowledge-index/03-RELATIONSHIP-MAP.md
Source version
0.0.0
Generated time
2026-07-06T14:59:18.203Z
Owner
Engineering (Enablement)
Audience
Internal
Status
Approved

03 — RELATIONSHIP MAP

Quan hệ giữa entity/module. Chỉ index quan hệ + dẫn nguồn (chi tiết ở travel-os/03-DOMAIN-MAP & 04-EVENT-CATALOG). Entity: 02-ENTITY-MAP.

Sơ đồ quan hệ

graph TD
  ACC[Account]-- 1:1 -->TEN[Tenant]
  TEN-- scopes -->RES[Reservation]
  TEN-- scopes -->everything[(mọi entity tenant-scoped)]
  RES-- uses -->AVA[Availability]
  RES-- snapshots -->PRI[Pricing]
  RES-- belongs to -->UNIT[Unit]-- belongs to -->LIS[Listing]
  PART[Partner]-- publishes -->LIS
  CUST[Customer]-- places -->RES
  RES-- produces -->EV[Domain Events]
  EV-- stored in -->OUT[Outbox Event]
  OUT-- feeds -->NOTIF[Notification]
  OUT-- feeds -->PAY[Payment]
  OUT-- feeds -->AFF[Affiliate]
  OUT-- feeds -->TI[Travel Intelligence]
  USR[User]-- member of (many) -->TEN
  USR-- has -->SES[Session]
  KEY[API Key]-- maps to -->TEN
  MED[Medical Tourism]-- reuses -->RES
  MED-- reuses -->PAY
  RES-. is Module #1 of .->TOS[Travel OS]

Bảng quan hệ (chuẩn)

Quan hệÝ nghĩaNguồn
Tenant owns Account (1:1)Mỗi Account có đúng một Tenant (vùng dữ liệu)travel-os/07, business-os/06
Tenant scopes Reservation (và mọi entity)Mọi entity tenant-scoped; tenant từ server-side, không từ clientbackend/AUTH-TENANT-CONTEXT
Reservation uses AvailabilityGiữ chỗ khoá Availability (chống overbook)backend/BOOKING-API
Reservation snapshots PricingGiá chốt tại thời điểm đặt (bất biến)travel-os/03
Reservation belongs to Unit → ListingUnit thuộc Listing; API nhận unitId, suy listingIdbackend/BOOKING-API
Partner publishes ListingPartner (bên cung) tạo Listing/Unit trong Catalogtravel-os/03
Customer places ReservationKhách du lịch tạo đơn (guest ẩn danh → merge khi đăng ký)travel-os/03
Reservation produces Eventsreservation.created/confirmed/cancelled…travel-os/04
Events → OutboxEvent lưu cùng transaction (at-least-once)backend/OUTBOX-HANDLERS
Outbox feeds Notification/Payment/Affiliate/Travel IntelligenceConsumer async, idempotent theo eventIdtravel-os/04
User member-of Tenant (N:M)1 user thuộc nhiều tenant + role (membership)backend/AUTH-GATEWAY
User has Session; API Key maps to TenantHai đường xác thực → tenant contextbackend/AUTH-GATEWAY
Medical reuses Reservation & PaymentVertical = composition, không fork module nềnplatform/MEDICAL-TOURISM-INTEGRATION, travel-os/02
Booking is Module #1 of Travel OSReference implementation của mọi pattern nền tảngtravel-os/00, travel-os/01

Ranh giới (không được vi phạm)