Oak serving board
AP-OAK-01
$48.00
On hand 14 · reserved 0 · available 14
Demonstration
This is a demonstration, not client work. It was built for this portfolio with fictional companies and data to show how I approach this kind of system. Outcomes below are illustrative targets, not achieved results.
01Interactive preview
Every query runs with tenant_id = alder; row-level security hides other tenants’ rows.
AP-OAK-01
$48.00
On hand 14 · reserved 0 · available 14
AP-LIN-02
$129.00
On hand 6 · reserved 0 · available 6
AP-MUG-03
$56.00
On hand 2 · reserved 0 · available 2
AP-SKL-04
$85.00
On hand 9 · reserved 0 · available 9
Cart
Reserved
Paid
Fulfilled
Your cart is empty. Add a product to begin.
02Context & constraints
Three fictional retail brands (Alder & Pine home goods, Kestrel Cycle Works and Lumen Botanics) share one commerce platform. Each needs its own catalog, prices, branding and stock, but the operator wants one codebase, one deployment and one on-call rotation.
The scenario is typical of groups that run several storefronts, and of B2B platforms that offer white-label shops to their own customers.
A self-initiated demonstration, not client work. In a real engagement of this shape I would own the architecture, data model, backend services, storefront and deployment.
Hard tenant isolation
A bug in one query must not expose another tenant's orders or prices. Isolation is enforced by the database, not only by application code.
No oversells at peak
Limited-stock drops attract concurrent buyers. Two customers must never both be sold the last unit.
At-least-once infrastructure
Payment webhooks, queues and client retries can all deliver the same message twice. Every step must be safe to repeat.
Small operating team
One shared deployment and observability stack, with per-tenant dashboards but no per-tenant infrastructure.
03Architecture & data flow
Step 1 / 6
Scroll sideways to see the whole diagram →
Checkout reserves stock
How a checkout holds inventory without overselling, even when many shoppers want the last unit.
Checkout reserves stock, step 1 of 6: Shopper starts checkout. The storefront posts the cart with an idempotency key generated in the browser.
04Engineering decisions
ADR-01
ADR-02
ADR-03
ADR-04
05Implementation
The reservation runs inside one transaction under the tenant's RLS policy. Locking the SKU row makes concurrent checkouts for the same item wait their turn, so the availability check and the insert can't interleave.
-- Concurrent reservations for the same SKU queue behind this lock.
SELECT on_hand FROM inventory WHERE sku_id = $1 FOR UPDATE;
INSERT INTO reservations (tenant_id, sku_id, cart_id, qty, expires_at)
SELECT current_setting('app.tenant_id')::uuid, $1, $2, $3,
now() + interval '15 minutes'
WHERE (
SELECT i.on_hand - COALESCE(SUM(r.qty), 0)
FROM inventory i
LEFT JOIN reservations r
ON r.sku_id = i.sku_id AND r.expires_at > now()
WHERE i.sku_id = $1
GROUP BY i.on_hand
) >= $3
RETURNING id; -- no row returned means "not enough stock"Payment webhooks are verified, recorded by event ID and processed once. Replays return the stored result, so a provider retry can never create a second paid order.
@Post("webhooks/payments")
async handle(@Req() req: RawBodyRequest<Request>) {
const event = this.payments.verify(req.rawBody, req.headers["stripe-signature"]);
return this.db.transaction(async (tx) => {
const first = await tx.processedEvents.insertIfAbsent(event.id);
if (!first) return { status: "duplicate" };
if (event.type === "payment_intent.succeeded") {
const order = await tx.orders.markPaid(event.data.object.metadata.orderId);
await tx.outbox.add("OrderPaid", { orderId: order.id, tenantId: order.tenantId });
}
return { status: "processed" };
});
}Catalog pages are cached at the edge with the tenant in the cache key and purged by surrogate keys when a product changes, so one tenant's update never invalidates another tenant's pages.
06Deployment
07Outcomes & lessons
What the demo shows
Illustrative — not a client resultTenant switching with isolated catalogs, stock reservation with expiry, an order state machine and the domain events each step emits.
How success would be measured
Illustrative — not a client resultZero oversells and zero duplicate orders in reconciliation reports; p95 checkout latency and error rate tracked per tenant against agreed budgets.
What is simulated
Illustrative — not a client resultPayments, fulfillment and email are simulated in the browser. No real transactions or customer data are involved.
Services
Industries
Next
Logistics control tower
Next step
Send a short brief. You’ll get a written reply from me within two business days — either a few clarifying questions, a suggested first step, or an honest “I’m not the right fit” with a pointer elsewhere.
Parth Patel
Senior full-stack engineer