Platform — Dữ liệu & bảng đọc/ghi
Platform là phần "vô hình" nối các domain. Trang này nêu các entity nguồn bên ngoài mà nó lắng nghe, và artifact dữ liệu nó tạo ra. Quy ước: 📖 READ, ✏️ WRITE.
Khái niệm liên quan bên ngoài
| Khái niệm | Là gì | Vai trò với Platform | Domain sở hữu |
|---|---|---|---|
| Entity nguồn (Account, Attendee, Invoice, Employee, Contact, CreditNote, Payment…) | Các thực thể nghiệp vụ. | Phát EntityEvent khi đổi; Platform lắng nghe để sinh notification/history. | Domain tương ứng |
| EntityType / EventType / EntityActionType | Enum định danh loại entity & hành động. | Khóa định tuyến: worker dựa vào để route. | Platform (enum) |
| NotificationEventType | Enum loại notification. | Discriminator domain notification — map tường minh ở biên. | Communication |
| NotificationJob / NotificationScheduler | Việc cần gửi + hàng đợi. | Đầu ra của notification post-processor → bàn giao cho Communication. | Communication |
| EntityEventScheduler | Lịch projection (Finance…). | Domain handler tạo để fan-out projection (Platform không đụng ở post-processor history). | Finance/Booking |
| BusinessUnit | Đơn vị. | Resolve BusinessUnitId cho job/history. | Org |
Bản đồ kho lưu trữ
| Kho | Artifact | Tác dụng |
|---|---|---|
| Azure Queue | entity-event-queue | Vận chuyển EntityEvent tới EventHandler worker. |
| Azure Table | NotificationJob | Bản ghi notification-run (PartitionKey = entity/EventKey). |
EntityHistory | Audit timeline entity (RowKey = HistoryEventKey tất định, upsert). | |
OutgoingMessage | (Communication) trạng thái gửi — tra cứu lịch sử. | |
| SQL | NotificationScheduler | Hàng đợi "có notification cần xử lý" (post-processor tạo). |
AttendeeHistory (và history theo entity) | Một số history dạng SQL theo entity. | |
| Audit store | EntityEventLog | Audit thô của event (tách biệt EntityHistory). |
⚠️
EntityHistory(Azure Table, projection) ≠EntityEventLog(audit thô) ≠BookingHistory(riêng cho booking). Xem Lịch sử & quan sát.
Bảng/artifact trong từng luồng
Luồng phát & xử lý event
| Bước | Artifact | Tác dụng |
|---|---|---|
| Service publish | entity-event-queue ✏️ WRITE | Đưa EntityEvent vào hàng đợi. |
| Worker route | (đọc message) 📖 READ | Định tuyến theo EventTypeId. |
| Domain handler | bảng domain + EntityEventScheduler ✏️ WRITE | Projection/scheduler nghiệp vụ (ngoài Platform core). |
Luồng notification post-processor
| Bước | Artifact | Tác dụng |
|---|---|---|
| Map | (đọc event/context) 📖 READ | Mapping quyết định có sinh job không. |
| Dedup + ghi | NotificationJob ✏️ WRITE (point-read dedup theo EventKey) | "1 job event-derived = 1 dòng". |
| Bắc cầu | NotificationScheduler ✏️ WRITE | Đưa vào pipeline gửi (Communication). |
Luồng history post-processor
| Bước | Artifact | Tác dụng |
|---|---|---|
| Map | (đọc state/snapshot) 📖 READ | Dựng AddEntityToHistoryModel. |
| Snapshot | Blob ✏️ WRITE | Lưu summary snapshot. |
| Upsert | EntityHistory ✏️ WRITE (InsertOrReplace theo RowKey tất định) | Audit timeline, retry ghi đè không trùng. |