Back to Overview
03 / 06
PROJECT 03•enterprise distributed

Vendora Commerce Engine

Enterprise-Grade Multi-Tenant Headless Commerce Platform with Row-Level Stock Locking

Live Subdomain DemoView on GitHub
Quick Reviewer Credentials

Pre-seeded merchant panel with catalog, real-time webhooks, and variant matrices.

User: admin@vendora.storePass: merchant-root-pass

Technologies & Stack

Next.js 16React 19TypeScriptTailwind CSS v4Drizzle ORMPostgreSQLRedisReact FlowDecimal.js
vendora.parsadevstudio.ir
IDLE
Vendora Commerce Engine

System Overview & Purpose

Engineered to run hundreds of isolated merchant storefronts with atomic inventory safety, sub-millisecond edge domain rewrites, visual webhook event pipelines, and high-precision financial math.

Core Architecture

PostgreSQL row-level locking (SELECT ... FOR UPDATE) prevents flash-sale inventory overselling. Hostname edge rewriting eliminates URL redirection latency.

Performance Benchmarks

100% Atomic

Inventory Safety

Zero overselling via PostgreSQL FOR UPDATE row locks

Decimal.js

Financial Precision

Eliminates IEEE 754 binary floating-point rounding bugs

Subdomain Rewrites

Multi-Tenancy

Edge domain resolution with zero-latency proxying

Engineering Challenges & Solutions

Real software roadblocks encountered during production and their architectural resolutions.

01.

Multi-Warehouse Inventory Allocation & Row Locks

The Problem: Concurrent flash-sale checkouts across multiple fulfillment hubs triggered race conditions and negative inventory levels.
The Architectural Solution: Engineered an Atomic Allocation Service acquiring PostgreSQL row locks (.for("update")) across distributed warehouse stocks with an append-only audit trail.
Multi-Warehouse Inventory Allocation & Row Locks — Source Solutiontypescript
123456789101112131415161718192021// Atomic stock reservation across warehouses via PostgreSQL .for('update') locks
export async function allocateInventory(tx: DrizzleTx, tenantId: string, orderId: string, items: AllocationItem[]) {
  const dbInventory = await tx.select().from(inventory)
    .where(inArray(inventory.variantId, items.map(i => i.variantId)))
    .for('update'); // Exclusive transactional lock acquired

  for (const item of items) {
    const matchedInvs = dbInventory.filter(inv => inv.variantId === item.variantId);
    const totalStock = matchedInvs.reduce((acc, curr) => acc + curr.quantity, 0);
    if (totalStock < item.quantity) throw new Error('Insufficient warehouse stock');

    let remaining = item.quantity;
    for (const inv of matchedInvs) {
      if (remaining <= 0) break;
      const deduct = Math.min(inv.quantity, remaining);
      await tx.update(inventory).set({ quantity: inv.quantity - deduct }).where(eq(inventory.id, inv.id));
      await tx.insert(auditLogs).values({ tenantId, action: 'inventory.deduct', details: { orderId, deducted: [deduct.toString()] } });
      remaining -= deduct;
    }
  }
}
02.

Cryptographic Outbound Webhook Dispatcher

The Problem: Outbound merchant automation events to external servers risked packet tampering and lack of delivery traceability.
The Architectural Solution: Built an event-driven dispatcher signing stringified JSON payloads using tenant-isolated HMAC-SHA256 secrets and persisting HTTP status logs.
Cryptographic Outbound Webhook Dispatcher — Source Solutiontypescript
123456789101112131415161718// Outbound event dispatcher with isolated HMAC-SHA256 signature and delivery audit
export async function dispatchTenantWebhook(tenantId: string, triggerEvent: string, payload: Record<string, unknown>) {
  const secret = getTenantSigningSecret(tenantId);
  const bodyString = JSON.stringify({ event: triggerEvent, payload });
  const signature = createHmac('sha256', secret).update(bodyString).digest('hex');

  const res = await fetch(action.config.url, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', 'X-Vendora-Signature': 'sha256=' + signature },
    body: bodyString,
  });

  await db.insert(auditLogs).values({
    tenantId,
    action: 'webhook:' + triggerEvent,
    details: { status: [res.ok ? 'success' : 'failed'], statusCode: [res.status.toString()] },
  });
}

Interface & System Screens

High-resolution captures of the live interface and management panels.

Vendora Commerce Engine Screen 1
01
Vendora Commerce Engine Screen 2
02
Previous System
Fluxio Engine
Next System
Metricon Link Infrastructure
Back to Overview