Skip to content

App Platform — Business Rules

Tổng quan

Domain này gom các cấu hình “platform-facing” trong settings, nhưng thực tế không phải một bounded context thuần nhất. Nó gồm:

  • singleton app_setting cho app khách hàng, app nhân viên, appointment, order,
  • template và channel config cho SMS, ZNS, notification,
  • 3rd_config, constant_config,
  • một nhánh bị đặt tên gây hiểu nhầm là app inventory setting nhưng thực chất là warehouse master/config.

Điểm quan trọng nhất:

  • không phải mọi thứ dưới /s/app-settings đều cùng owner dữ liệu,
  • chỉ một phần dùng singleton app_setting.id = 1,
  • phần còn lại là CRUD độc lập theo table riêng.

Nhóm nghiệp vụ

NhómVai tròVí dụ route
Global app settingConfig appointment, order, locale, customer/staff app/s/app-settings/*
Message templateCấu hình ZNS, SMS, notification template/s/app-settings/message-template/*
Provider / constant configToken vendor, OA list, 3rd config, constant config/s/app-settings/3rd-config, /s/app-settings/constant-config
App inventory settingQuản lý kho trong namespace app settings/s/app-settings/inventory*

Luồng chính

1. Global singleton setting

text
Page load
  -> đọc `app_setting(limit: 1)`
  -> cache Pinia + localStorage TTL 1 giờ
  -> user sửa field
  -> upsert lại cùng singleton record
  -> ghi lại cache

2. Template / provider config

text
Mở tab ZNS / SMS / Notification
  -> query table/channel config riêng
  -> create/update/delete bằng mutation riêng
  -> không đi qua `useSettings.updateSetting`

3. Customer / staff app

text
Mở customer-app hoặc staff-app
  -> đọc `app_setting.app_settings`
  -> render editor theo config key
  -> ghi ngược vào singleton `app_setting`

Quy tắc nghiệp vụ

Quy tắc
BR-AP-001app_setting là singleton config; FE luôn coi id = 1 là nguồn canonical cho phần global app settings.
BR-AP-002Cache global settings ở localStorage có TTL 1 giờ; nếu còn hạn thì FE ưu tiên cache trước network.
BR-AP-003Customer app và staff app dùng chung cơ chế editor, nhưng payload setting key vẫn phải giữ đúng shape của từng nhánh.
BR-AP-0043rd_config, constant_config, notification_template, zns_template không dùng cùng write path với singleton app_setting.
BR-AP-005app inventory setting về nghiệp vụ không phải “global app config”, mà là warehouse master/config screen bị đặt dưới namespace /s/app-settings.
BR-AP-006Warehouse role được redirect đặc biệt sang nhánh inventory thay vì nhìn full tree app settings.

Boundary

BoundaryGhi chú
notificationSettings chỉ cấu hình template/channel; runtime send nằm ở notification services
userNhánh inventory settings vẫn đọc branch/account state từ user module
ecommerceapp inventory setting thực chất quản lý warehouse, không phải singleton app config

Rủi ro / Findings

MứcFinding
P1app-settings đang chứa cả singleton config lẫn CRUD screen độc lập, nên tên namespace dễ làm người đọc hiểu sai ownership.
P1services tab hiện chỉ là placeholder, nhưng vẫn nằm trong cấu trúc app settings như một group thật.
P1Redirect warehouse role chỉ nhìn roles[0], không phản ánh effective role set đầy đủ.
P1CustomerAndStaffAppEditor đang có contract emit lệch với v-model, dễ làm config customer/staff app bị ghi sai shape.
P2Cache parse từ localStorage chưa có guard tốt; refresh path cũng chưa thật sự bypass cache như tên hàm gợi ý.