0. the brief

Sa-Diira makes handmade leather bags in Ghana and wanted an online store that felt like a proper boutique fashion site, not a bolted-on Instagram checkout. The requirements were simple to state and less simple to build: guest checkout for people who just want to buy a bag without making an account, real accounts for repeat customers with order history, stock that's actually live, and an admin dashboard non-technical staff could run day to day.

1. architecture

Stack:
  • React (TypeScript) frontend
  • Node.js + Express API
  • PostgreSQL on Neon (serverless Postgres) via Prisma ORM
  • Clerk for authentication (guest + account flows)
  • Cloudinary for product image storage and on-the-fly transformations

Clerk turned out to be the right call specifically because of the guest checkout requirement — it handles anonymous sessions that can later convert into a real account without losing the cart, which would have been a real headache to hand-roll.

2. features

Shipped:
  • Guest and account checkout with a persistent cart
  • Live stock — a sold-out item disables itself across every open tab, not just on refresh
  • Admin dashboard for products, inventory, and order status
  • Cloudinary-driven responsive product images, no manually exporting five sizes per photo
  • Order history and status tracking for logged-in customers

3. a challenge — the last item in stock

The scenario that worried me most was two guests adding the last unit of the same bag to their cart at the same time. A naive 'check stock, then decrement' does this in two separate steps — exactly the kind of gap a race condition lives in.

Do the check-and-decrement as a single atomic database operation, not two round trips. Prisma lets you express this as one conditional update — if it affects zero rows, you know someone beat you to it, and you can bounce the customer back to an 'out of stock' state cleanly.

4. the code

const result = await prisma.product.updateMany({
  where: { id: productId, stock: { gt: 0 } },
  data: { stock: { decrement: 1 } },
});

if (result.count === 0) {
  throw new OutOfStockError(productId);
}

5. what i learned

Guest checkout is deceptively hard — the moment you say 'no account required' you still need somewhere to hang a cart, an order, and a way to look that order up later, all without a login. Clerk's anonymous-to-authenticated session handling did most of that heavy lifting. On the media side, letting Cloudinary handle resizing and format negotiation (serving WebP/AVIF automatically) cut page weight enough that it was worth doing on day one instead of retrofitting it later.