Project system brief

A distributed, offline-first commerce engine written in Go 1.24 that compiles from one codebase into CLOUD (Kubernetes + PostgreSQL) and EDGE (SQLite WAL, CGO_ENABLED=0) runtime targets.

Product Context

Product Context

A distributed, offline-first commerce engine written in Go 1.24 that compiles from one codebase into CLOUD (Kubernetes + PostgreSQL) and EDGE (SQLite WAL, CGO_ENABLED=0) runtime targets.

System Problem & Scope

System Problem & Scope

Multi-outlet retail, F&B, tourism parks, and hospitality venues suffer revenue loss when cloud-tethered POS terminals stall during ISP outages, while isolated desktop POS apps create fragmented inventory and ticket fraud.

Engineering Constraints

Engineering Constraints

Running a single Clean Architecture Go codebase seamlessly across Cloud PostgreSQL and Edge SQLite WAL without CGO, guaranteeing atomic outbox sync without rejecting paid offline sales, and verifying QR tickets offline without double-redemption.

System Architecture Flow

System Architecture Flow

Clean Architecture and DDD in Go: Gin HTTP delivery with X-Idempotency-Key middleware and gorilla/websocket Hub, application usecases with strategy hooks, pure Go domain entities, and a unified SQL repository supporting PostgreSQL ($1) and SQLite (?) inside atomic transactions.

5 System Stages
Active Stage: 01
01OBSERVABILITY

Cloud Central Hub (K8s + PostgreSQL)

Active Stage
02OBSERVABILITY

Delta & Outbox Sync Engine

03OBSERVABILITY

Edge Checkout & Strategy Hooks

04OBSERVABILITY

Offline Ed25519 Gate Verifier

05OBSERVABILITY

WebSocket KDS & Turnstile Hub

STAGE 01

Cloud Central Hub (K8s + PostgreSQL)

Manages master catalog, multi-tenant coordination, Ed25519 ticket signing, and idempotent sync ingestion.

STAGE 02

Delta & Outbox Sync Engine

Pulls catalog updates (/v1/sync/pull) and pushes append-only outbox events (/v1/sync/push) asynchronously.

STAGE 03

Edge Checkout & Strategy Hooks

Executes F&B, Retail, Tourism, and Hospitality fulfillment strategies inside atomic SQLite WAL transactions.

STAGE 04

Offline Ed25519 Gate Verifier

Validates QR signatures and expiry locally without WAN, recording redemptions atomically to block double-scans.

STAGE 05

WebSocket KDS & Turnstile Hub

Broadcasts real-time kitchen tickets and gate unlock events over local outlet LAN.

Execution & Failure-Mode Explorer

How the architecture behaves under real faults

Primary stage: Delta & Outbox Sync Engine

Edge checkout writes transactions to local SQLite WAL and streams append-only outbox events with UUIDv7 IDs to the Cloud Hub.

Key Engineering Contributions

Key Engineering Contributions

Engineered unified checkout, order/folio management, and background sync workers using time-ordered UUIDv7 and the Transactional Outbox pattern. Built polymorphic FulfillmentStrategy implementations for F&B BOM recipe deduction, Retail multi-UOM/batch tracking, Tourism Ed25519 QR verification, and Hospitality Open Folio room charges. Configured multi-stage Distroless Docker builds (CGO_ENABLED=0) alongside Cloud Kubernetes HPA and Edge K3s PVC deployment manifests.

Reliability & Integrity Guarantees

Reliability & Integrity Guarantees

Ensured through atomic transaction boundaries (WithTransaction), idempotency middleware, atomic redeemed_tickets insertion for offline gate scans, and Physical Reality Wins reconciliation alerting via STOCK_DISCREPANCY_ALERT.