Industrial Cash Management Edge System
Edge Computing & IoT

Problem & Solution
In the high-stakes retail environment of Thailand, cash remains a dominant payment method. However, traditional POS systems are often paralyzed by two factors: unreliable internet connectivity and the technical complexity of communicating with specialized hardware. When the cloud goes down, sales stop. Furthermore, without real-time, hardware-level validation, businesses are vulnerable to internal fraud and denomination discrepancies that are only discovered during end-of-day reconciliations.
I architected a Local-First Edge System that serves as a high-performance bridge between physical cash hardware and the cloud. By implementing low-level TCP event-driven communication, the system maintains deterministic control over Glory Cash Infinity devices (CI-10, CI-50, RK-10). This allows shops to process sales, refunds, and expenses with zero latency, regardless of internet status. The system acts as a 'Security Sentinel' validating cash inventory at the hardware level between every single transaction, ensuring that the physical cash in the machine always matches the digital record in the Cweetlabs Cloud Platform. This hybrid architecture ensures zero operational downtime, reduces cash management time by 70%, and enables building automated kiosk solutions on top of the system, as demonstrated in the LPG Self-Ordering system.
Key Features & Business Impact
- Deterministic TCP Hardware Control: Direct, low-latency communication with Glory CI-series and RK-10 devices.
- Internet-Independent Operations: Full support for sales, refunds, and cash management during total network outages.
- Real-Time Fraud Detection: Hardware-level inventory validation between every transaction to ensure cash parity.
- Automated Expense Workflows: Configurable dispensing limits and digital approval chains for shop operational costs.
- Seamless Cloud Parity: Automatic, idempotent synchronization with the Cweetlabs Central Dashboard.
- Staff Accountability: Granular shift tracking with full audit trails for every cash input/output event.
Technical Deep Dive
Edge Architecture: TCP Event-Driven Control
The system is built on a Hardware-Abstraction Layer (HAL) designed for high-availability. Using .NET Core for the core service, I implemented an asynchronous TCP Event-Driven architecture to interface with Glory Cash Infinity devices. This allows the system to handle real-time machine telemetry—such as dispense confirmations, bill jams, and error states—without blocking the main UI thread. This edge-centric approach ensures that mission-critical POS functions are decoupled from cloud latency, providing a 'Zero-Downtime' experience for retail operators.
Security: Local RBAC & Cloud-Link JWT
Authentication is enforced through a dual-security model. Locally, the system utilizes a Physical-to-Digital RBAC (Role-Based Access Control) where staff actions are tied to specific hardware permissions (e.g., only managers can trigger 'Daily Expense' dispensing). For cloud communication, the system utilizes JWT (JSON Web Token) with automated lifecycle management. If a token refresh fails due to network issues, the system safely queues sensitive data and re-authenticates automatically once the 'Heartbeat' to the cloud is restored.
Reliability: Offline-First Persistence & Sync
To guarantee zero data loss, every hardware event is treated as an Atomic Transaction in the local PostgreSQL database. The data pipeline utilizes a Write-Ahead Logging (WAL) approach; once a transaction is secured locally, a background worker attempts to synchronize the data to the cloud using REST APIs. I implemented Idempotency Keys and incremental synchronization logic to ensure that even after extended offline periods, data is re-synced in chronological order without duplicates or consistency errors.
Integrity: Transactional Safety & Fraud Logic
The database schema is engineered for Audit-Integrity. I implemented a specialized Cash Inventory Ledger with database-level triggers that perform Snapshot Validation before and after every transaction. If a discrepancy is detected between the expected balance and the hardware's reported inventory, the system flags the transaction for immediate audit. Performance is maintained through Composite Indexing allowing for sub-second shift-closure reports even on low-spec edge hardware.
Technology Stack
NextJS
Typescript
TailwindCSS
Dotnet Core
PostgreSQL
Drizzle ORM