JomMula

Kedai: Build a Personal Marketplace · The Plan · Lesson 01

One seller, one of each

A personal marketplace is not a tiny Amazon. Meet the one-of-one item, the three spaces, and the reservation that cannot be double-sold.

8 min readExplanationno codeNext.jsUpdated October 2026

You have one chair. Two people want it. Who gets it?

That is the whole project. Not a catalog with infinite stock — a shelf with one of each. The moment you accept that, a different set of problems appears. A normal shop subtracts from a quantity. A personal shop has to decide who is holding the only chair, for how long, and what happens when they disappear.

Kedai is a one-person marketplace for exactly that: the things you are ready to let go. You list an item, share its link, a buyer reserves it, and you arrange payment and pickup on WhatsApp. No customer accounts. No cart. No online payment. One seller, one shelf, one of each.

Why “Kedai”?

A kedai is a small neighbourhood shop. It has a window, a counter, and a back room. That is the entire architecture of this project:

  • The shop window is public. Anyone can look at the shelf and open an item link.
  • The counter is where a buyer reserves one item. It is public too, but it is constrained.
  • The back room is yours. Publish, price, confirm, cancel, archive. Nobody else gets in.

The name is not decoration. It is the mental model. Every screen in the app belongs to one of those three spaces, and each space has a different permission.

The two people

There is one seller and many visitors. They never see the same screen.

The visitor

  1. 1

    Open the shop link

    The shelf shows what is available, what is on hold, and what has already found a home. No login, no account, no cart.

  2. 2

    Open an item

    Photos, condition, price, the seller's note, and one reserve form. The item has its own shareable URL.

  3. 3

    Reserve it for 24 hours

    Name, email, optional phone, pickup or post, and a note. The server reads the price from the item and snapshots it into the reservation.

  4. 4

    Continue on WhatsApp

    The receipt opens a prefilled message: reference, item, price, handover. Payment and pickup are arranged there.

  5. 5

    Wait for confirmation

    The buyer may click “I've paid”, but that is a claim. The item stays pending until the seller confirms the money arrived.

  6. 6

    Collect the item

    Once the seller confirms, the item is sold. The receipt keeps the history, and the shelf shows the stamp.

The seller

  1. 1

    Log in

    One admin, a real session, a rate-limited login. There are no customer accounts anywhere in the system.

  2. 2

    Create an item

    Write the title and note, choose the condition, set the price, and upload the photos. It starts as a draft.

  3. 3

    Publish it

    A draft is invisible. Publishing makes the item and its shareable link appear on the shelf.

  4. 4

    Watch the reservations

    The back room shows the buyer, the claim, the hold window, and the email status.

  5. 5

    Confirm the sale

    After checking the payment, the seller confirms. The item becomes sold exactly once.

  6. 6

    Cancel or extend

    If the buyer disappears, cancel the hold or give them another 24 hours. An expired hold releases the item automatically.

The three spaces

Here is the model to keep for the rest of the project. Everything else is implementation detail.

The three spaces

A shop has a window, a counter, and a back room.

The database is the lock

Anyone can look

The shelf and the item pages. No login, no account, no cart. This is the link the seller shares.

What it can do

  • Browse every published item.
  • Open a shareable item link.
  • See the price, condition, photos, and status.
  • See whether an item is available, reserved, or sold.

What it must never do

  • See who reserved an item.
  • See buyer emails or phone numbers.
  • Change a price or a listing.

Who can do what?

ActionWindowCounterBack room
Browse the shelf
Reserve one item
See buyer details
Confirm a sale
Change a price
Publish or archive
The shop window is a read. The counter is a constrained write. The back room is an authorized write. Three spaces, three different rules.

The important part is the asymmetry:

  • The shop window is a public read. It is marketing.
  • The counter is a public write, but it can only create one pending reservation per item. It cannot confirm a sale.
  • The back room is an authorized write. It is the only place that can turn a reservation into a sale.

If you remember one sentence from this lesson, make it this one:

The counter can hold the chair. Only the back room can sell it.

The item lifecycle

An item is not a product with a stock count. It is a single object moving through a small set of states:

draft ──publish──▶ available ──buyer reserves──▶ reserved ──seller confirms──▶ sold
                       ▲                              │
                       │                              ├──seller cancels──┐
                       │                              └──hold expires────┤
                       └──────────────────────────────────────────────────┘

Two rules matter more than the diagram:

  • A pending reservation is a hold, not a sale. The item is reserved, the buyer has a reference, and the seller still has to confirm the money.
  • A hold has a deadline. After 24 hours, the reservation expires and the item returns to the shelf. A shop that forgets to release stale holds slowly stops selling.

We will build both as database constraints and conditional updates, not as if statements scattered through the UI.

Try the whole flow

This demo is the project in miniature. It has no backend, no real payments, and no real email — but every state transition is the one we will build for real.

Kedai

One seller. One-of-one things.

The public shelf · one of each

Things looking for a second life.

Reserve one for 24 hours. Pay and collect on WhatsApp. When it's gone, it's gone.

6 items
A personal shop, not a multi-vendor marketplace. One seller, one shelf, one of each. No accounts, no cart, no online payment.

Demo only · no real payments, no real email

Click through it in this order:

  1. Open an item and reserve it with any name and email.
  2. Read the receipt. Open the WhatsApp preview. Click I’ve paid.
  3. Switch to Back room. Notice that the reservation is still pending — the claim did not change it.
  4. Click Confirm sale. Watch the item become sold and the receipt update to confirmed.
  5. Go back to the shop. The item now carries a Sold stamp.
  6. Reset the demo, open another item, and click Demo: let another buyer click first. Try to reserve again. The item is already held.

What is actually hard here

Uploading a photo and listing an item is the easy part. The Gallery Blog project already taught that. Kedai adds four problems that are mostly about state, not UI:

  1. The stock is one. Two buyers can click reserve at the same time. One must win; the other must see an honest “just reserved” state. A quantity count cannot save you here.
  2. The hold expires. Time is part of the state. A reservation that is pending forever is a shop that never sells the chair again.
  3. The price must be frozen. An item can cost RM 180 today and RM 150 next week. A reservation created today must still be RM 180 forever.
  4. Only the seller can confirm. A buyer’s claim is useful information, not a payment. The interface must make the difference impossible to miss.

That is why the database is not just a list of items. It is the source of truth for who is holding which item, until when, and why.

The state machine

The reservation is the heart of the system. It only moves in a few directions, and every move has a guard.

pending ──seller confirms──▶ confirmed
   │
   ├──buyer or seller cancels──▶ cancelled
   └──24 hours pass────────────▶ expired

The item moves with it:

available ──reserve──▶ reserved ──confirm──▶ sold
     ▲                     │
     └──cancel or expire───┘

Two rules matter more than the diagram:

  • Only pending can become confirmed. Not cancelled, not expired, not confirmed again.
  • Email status is separate from reservation status. A confirmed sale with a failed receipt is still confirmed. The buyer is entitled to the item; the email is just how they find out.

We will build both as explicit database constraints and conditional updates, not as promises in a component.

The stack

N

Next.js 16.4

The app

App Router, React Server Components, Server Actions, and Route Handlers. One project for the shelf, the back room, and the upload ticket.

Why this?

It is the natural next step after React and Express — and it makes the server/client boundary explicit, which is exactly what this project is about.

Ne

Neon

The source of truth

Postgres for items, photos, reservations, receipts, admin sessions, and the audit trail. A second branch for tests.

Why this?

Reservations need real transactions. A partial unique index is the difference between one hold and two.

R2

Cloudflare R2

The photo shelf

One public bucket for item photos. The browser uploads directly with a five-minute ticket; the server makes the variants.

Why this?

S3-compatible, cheap egress, and simple. The photos are public marketing; the back room is the private part.

Re

Resend

The last mile

Transactional email for the buyer's receipt and the seller's alert. Idempotency keys make a retry safe; failures are recorded.

Why this?

Email is the most fragile part of the flow. It needs its own status, its own retry, and its own audit event.

Ve

Vercel

Hosting

A Next.js deploy with a Neon integration, environment variables, cron, and logs.

Why this?

One origin, no CORS between the app and its API, and a cron for expiry. The R2 bucket stays the only file store.

What we are not building

This matters because the interesting engineering is not in the shop UI. It is in the moment two people want the same chair, and in the moment the first one disappears.

The five promises

These are the invariants the rest of the project will protect. We will turn them into database constraints, conditional updates, and tests.

  1. The price comes from the item. The browser never sends an amount.
  2. One item has at most one pending reservation. The database enforces it.
  3. Only the seller can confirm a sale. A buyer’s claim is recorded, not trusted.
  4. An expired hold releases the item. Time is part of the state.
  5. An item with history is archived, never hard-deleted. The shop keeps its memory.

Your mission

the plan's verify step

No code yet. Write the one-sentence promise of Kedai in your own words. Then list three things that must never happen in this system. Finally, click through the demo and find the exact moment the item becomes reserved — and the exact moment it becomes sold. Who is allowed to cause each one?

If you can explain why the WhatsApp click does not equal a sale, you are ready for the next lesson.

Recap

Kedai sells physical, one-of-one items. The unit is an object, not a stock count.

Three spaces: public shop window, constrained counter, private back room.

The reservation is the heart: pending → confirmed, cancelled, or expired.

The price is snapshotted; only the seller can confirm; the hold expires.

The interesting problems are unique stock, time, and trust — not the product grid.

Next: before we write the real screens, we design the shop window. One HTML mockup, no framework, so the layout has to earn its place before the code does.

02

Up next

Design the shop window

Before the real app, build a single-file Kedai mockup: the shelf, the item, the receipt, and the dark back room.

Read now