Commerce Architecture & Specs

An event-driven, schema-first commerce engine designed for strict ACID compliance, atomic inventory locking, real-time fraud detection, and offline-capable POS.

Performance & Commerce Metrics

P50 Checkout Latency

12ms

P95 Checkout Latency

42ms

API Throughput

10,000 req/sec (Horizontally Scalable)

Offline POS Sync

idempotency-keyed order replay on reconnect (server-side dedup) + a compiled pricing engine deployed to a connected Bridge POS register for local on-device pricing

Fraud Detection Latency

<5ms per order

Inventory Lock Timeout

5 seconds (prevents deadlocks)

Recovery Email Sequence

3-step (1h, 24h, 72h) with token-based URLs

1. Schema-Driven Architecture

Every commerce entity (products, orders, customers, subscriptions, gift cards) is a strictly typed collection backed by PostgreSQL 17.

Auto-Generated APIs: The platform's dynamic routing exposes REST endpoints providing 30+ filter operators, cursor/offset pagination, and sparse fieldsets out of the box.

Infinite Extensibility: Core structured fields map to indexed SQL columns for lightning-fast querying, while dynamic attributes (like custom product specs) map to flexible JSON fields, allowing schema flexibility without requiring costly database migrations.

Multi-Location Inventory: Inventory is tracked per-location with available, reserved, and committed quantities. Location-aware availability checks run during checkout.

2. Atomic Inventory Locking

Order processing relies on strict row-level database locking to ensure inventory counts are decremented atomically, eliminating double-sell race conditions during flash sales.

The Reserve Flow: 1. Stock is verified for each item (global or per-location) 2. A row-level lock is acquired on the affected product rows 3. A 5-second lock timeout prevents deadlock accumulation under high concurrency 4. On success, the reserved quantity increments; on failure, rollback releases all locks

Deduplication: Reservations are keyed to the order, so duplicate reservation calls for the same order return the existing reservation without re-reserving.

Release on Cancellation: Order cancellations return reserved stock to the available pool automatically, under the same locking guarantee.

3. Real-Time Fraud Detection

SignalWeightDescription
IP Velocity (high)+406+ orders from the same IP in the last 24h
IP Velocity (elevated)+203-5 orders from the same IP in the last 24h
Email Velocity+204+ orders from the same email in the last 24h
High-Value Order+30Order ≥ $3,000
Elevated-Value Order+20Order ≥ $1,000
Moderate-Value Order+10Order ≥ $500
Disposable Email+30Email domain in a 56-entry disposable-domain list
Billing Mismatch+25Billing ZIP and state both differ from shipping
First Order + High Value+15No prior orders from this email, and order > $200

4. Abandoned Cart AI Recovery

StepDelaySubject PatternContent
Reminder1 hour"You left items in your cart"Product list + direct checkout link
Discount24 hours"Complete your order with X% off"Generated discount code + urgency
Final72 hours"Your cart is about to expire"Last chance + expiration countdown

5. Subscription Renewal Engine

Recurring billing uses status-based locking to prevent double-renewal under concurrent processing.

Status Lifecycle: active → renewing → active (success) or past_due (failure)

Concurrency Protection: The renewal process uses optimistic locking: 1. Status set to renewing 2. Verified that this attempt won the lock 3. Payment processed and order created 4. On failure, status is marked past_due and a payment-failed event is emitted

Dunning Events: Failed renewals emit a payment-failed event carrying subscription, customer, plan, and failure reason for downstream recovery workflows.

6. Native POS Hardware Integration

DeviceProtocolFeatures
Receipt PrinterESC/POS over USB/SerialLine items, QR codes, store branding
Cash DrawerPrinter DCD pin or serialKick-open via print job
Card ReaderUSB HID mag-stripe/chipMasked card number only (PCI compliance)
Barcode ScannerUSB HID keyboard wedgeReal-time product lookup
Customer DisplayUSB/SerialRunning totals, item names
Label PrinterESC/POS thermalPrice tags, shelf labels

Composes with the rest of the OS