Project

General

Profile

Feature #7106

Updated by Kyle Chong 3 months ago

Refer to: 

 docs/planning/modules/M02_Product_Data_Sync.md 

 Objective 

 Build the POS+ master-data synchronization framework so that master-data changes can be published from the upstream system, processed by Qube Backend, and distributed to Qube Cashier POS. 

 POS+ development must not depend on QubeBiz being completed first. 

 During development, Qube Admin Portal will act as a mock QubeBiz publisher and publish master-data events for testing. 

 The final architecture must support: 

 Qube Admin Portal / 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 
         ↓ 
       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 need to change as long as QubeBiz follows the agreed event contract. 

 Backend → Cashier Distribution 

 Qube Backend must support distribution of master-data changes to 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 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 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.

Back