Feature #7106
Updated by Kyle Chong 3 months ago
Refer to: docs/planning/modules/M02_Product_Data_Sync.md Implement Objective Build the POS+ Product & Master Data master-data synchronization between framework so that master-data changes can be published from the upstream master-data source, system, processed by Qube Backend Backend, and distributed to Qube Cashier POS. POS+ development must not depend on QubeBiz being completed first. During initial development, Qube Admin Portal will act as a mock QubeBiz to simulate publisher and publish master-data Add, Update and Delete events. events for testing. High-level flow: The final architecture must support: Qube Admin Portal (Mock QubeBiz) → / Future QubeBiz ↓ Kafka → Topic ↓ Qube Backend → ↓ Master Data Processing ↓ Distribution to Cashier ↙ ↘ Kafka / LAN → ↘ ↙ Qube Cashier POS ↓ Local SQLite Important Architecture Principle The synchronization design must separate: Transport Layer from Master Data Processing Layer The Cashier should not implement separate business logic for Kafka and LAN. Both delivery methods should eventually produce the same internal master-data event: Transport ↓ MasterDataEvent ↓ Validation ↓ Entity Handler ↓ SQLite For example: Kafka Consumer ──────┐ ↓ MasterDataEvent ↓ LAN Receiver ────────┘ ↓ Master Data Processor ↓ SQLite This allows POS+ to support different deployment environments without duplicating master-data logic. Upstream Flow For upstream master-data changes: Qube Admin Portal / QubeBiz development ↓ Kafka ↓ Qube Backend During POS+ development: Qube Admin Portal ↓ Create / Update / Delete ↓ Publish Master Data Event ↓ Kafka ↓ Qube Backend Qube Admin Portal is only acting as a temporary test publisher. Later: QubeBiz ↓ Kafka ↓ Qube Backend Qube Backend should not part need to change as long as QubeBiz follows the agreed event contract. Backend → Cashier Distribution Qube Backend must support distribution of this feature. Refer master-data changes to M02 planning document Cashier POS through one or more supported transports. Transport A — Kafka Qube Backend publishes the relevant cashier/store master-data event to Kafka. Cashier subscribes to the required topic and individual development subtasks processes the event. Example: Backend ↓ Kafka ↓ Cashier ↓ SQLite This approach may be suitable where Cashier POS has reliable access to the messaging infrastructure. Transport B — LAN Qube Backend distributes master-data changes directly to Cashier POS over the local store network. Example: Backend Server ↓ Store LAN ↓ Cashier 01 Cashier 02 Cashier 03 The implementation can follow the agreed POS+ LAN communication architecture. The exact protocol should be determined during development, for implementation details. example: HTTP/HTTPS API WebSocket gRPC TCP-based communication local message service other approved internal protocol The important requirement is that the Cashier ultimately receives the same MasterDataEvent structure regardless of transport. Transport Selection Transport should be configurable. For example: MasterDataTransport = Kafka or MasterDataTransport = LAN If the architecture later requires both simultaneously, the design should not prevent it. Example: Backend ↓ Master Data Distribution Service ├── Kafka Transport └── LAN Transport The master-data processing logic must not depend directly on either transport.