By Chason ArthurRevision 109.052Updated

Static concept preview · storefront incomplete

GardenerDirect

Keep a catalog selection separate from an accepted order.

The storefront concept connects product browsing with a reviewable request. Product versions, requested quantities, pricing and the outcome of a submission have different responsibilities.

This page uses one newly fictional product and original illustrative code. It is not a live catalog or checkout. The complete persistent storefront is not available here.

The intended workflow

The stages below explain the concept. They cannot be performed on this static page.

  1. Browse a current catalog

    Filters and product details describe the version of the catalog that was loaded. This preview supplies no catalog service.

  2. Record a requested quantity

    A selection can carry a stable product identifier, a bounded quantity and the product version it was based on.

  3. Obtain an authoritative quote

    A server must check current products, availability and pricing. A client-supplied request is not a quote or stock reservation.

  4. Confirm an exact outcome

    A submitted request needs an authoritative result. An unknown outcome must not be presented as a completed order.

A fictional request line

Original synthetic data

Product
Synthetic plant A.
Identifier
sample-plant-a.
Product version
4, an illustrative version.
Requested quantity
2. No stock is reserved.
Quote and order
Not requested. No price, total, transaction or order result is calculated.

This product is fictional. No customer, real product record, product photograph or historical commerce result is represented.

Keep the request narrow

The original example returns only the product identity, quantity and version. Its quantity range is illustrative. Authoritative pricing, stock and order decisions are outside this function.

Original illustrative example · requested-line.mjs · version 1.0.0
SHA-256 1f9886b94af1b343731d16d1804a2168e9d052a517d12ed7232f87b2ec56e423

// Original illustrative example, version 1.0.0.
// The line records a request; it does not establish price or availability.
export function makeRequestedLine(product, quantity) {
  if (!Number.isInteger(quantity) || quantity < 1 || quantity > 10) {
    throw new Error("The example accepts quantities from 1 through 10.");
  }

  return Object.freeze({
    productId: product.id,
    quantity,
    productVersion: product.version
  });
}

This complete example is educational text. It is not extracted from a private storefront and does not establish its runtime or backend behavior.

Architecture concepts

Separate read and write models

Catalog data supports browsing. A request should carry only the fields required for review, rather than copying a client-computed price into an order.

Check versions explicitly

A product can change after a page loads. A version identifier gives the authoritative service a specific state to compare before it acts.

Preserve uncertain outcomes

A missing response is not proof that nothing happened. Order completion and any retry require a defined result and recovery protocol.

What this preview does not provide

Lab discussion / GardenerDirect prototype

What would you try next?

Ask about the code, compare an approach, or describe an edge case. Reader comments are reviewed before publication.

All lab discussions

Reader comments

Open the discussion to read and add reader comments.

Read or write a comment →

Code walkthrough

Follow the implementation in code.

Use these examples alongside the steps on this page. Read the explanation before copying a snippet; source excerpts depend on the surrounding implementation, and illustrative examples are labeled.

Example 01 · Illustrative JavaScript

Use a small fictional catalog record

This illustrative record is sufficient for a requested line. It deliberately contains no price or inventory promise. An accepted order needs a separate authoritative decision.

const product = Object.freeze({
  id: "sample-plant-a",
  version: 4
});
const requestedLine = makeRequestedLine(product, 2);
Example 02 · Illustrative Node.js test

Exercise the quantity boundary

The function above accepts only whole quantities from one through ten. These local assertions check both edges and reject a fractional request.

import assert from "node:assert/strict";

assert.equal(makeRequestedLine(product, 1).quantity, 1);
assert.equal(makeRequestedLine(product, 10).quantity, 10);
for (const quantity of [0, 11, 1.5]) {
  assert.throws(() => makeRequestedLine(product, quantity));
}
Example 03 · Illustrative JavaScript

Check that the request is an immutable snapshot

A frozen requested line cannot be edited into an accepted order. The selected product’s version travels with the request so a later service can identify which catalog revision was seen.

const line = makeRequestedLine(product, 2);

console.assert(Object.isFrozen(line));
console.assert(line.productId === "sample-plant-a");
console.assert(line.productVersion === 4);
console.assert(!Object.hasOwn(line, "unitPrice"));
Example 04 · Illustrative JavaScript

Serialize a request without inventing acceptance

This example prepares text for inspection. It sends nothing and creates no order. Product price, availability, taxes and final acceptance belong to a future server-side contract.

const request = {
  items: [makeRequestedLine(product, 2)]
};

const requestText = JSON.stringify(request, null, 2);
console.log(requestText);