Use case · E-commerce

A catalog and order desk in one place.

Products, variants, categories, search, recommendations, carts, orders, and fulfilment events are documents and events. NonoDB keeps the catalog searchable and the order flow consistent without a search cluster and a message broker.

CatalogVariantsSearchRecommendationsInventoryOrdersEvents

Catalogs are documents. Orders are events.

A product has optional attributes, localized text, images, variants, and category-specific fields. An order is a state machine with side effects: payment, email, stock, and fulfilment. NonoDB handles both shapes without forcing them into the same rigid table.

Product data that changes

Keep attributes, variants, and category-specific fields as documents.

Search next to stock

Text, fuzzy, and vector search read the same live documents as checkout.

One writer, clear stock

Conditional updates reserve stock without a race between checkout requests.

No dual writes

Order events commit with the order, so payment and email cannot drift.

E-commerce feature map

Store needNonoDB featureWhat you get
Flexible product dataJSON documentsDifferent attributes per category without a migration for every field.
Fast catalog screensUnique and compound indexesLook up by SKU, category, status, price, and recency.
Product searchBM25 text indexRank products by relevance across a denormalized search_text field.
Typo-tolerant searchFuzzy index“headfones” still finds “headphones”.
Similar productsVector indexExact top-K similarity for recommendations and “more like this”.
Variant selectionVariants collection + indexPrice and stock per SKU without duplicating the whole product.
Cart expiryTTL collectionsAbandoned carts clean themselves up after a week.
Stock reservationAtomic find_and_modifyDecrement stock only when enough units are available.
Order automationTransactional outbox eventsPayment, email, and fulfilment consumers react to committed changes.
ReportingSQL and aggregationRevenue by status, product, or period without an export job.
Multi-tenant storefrontstenant_id plus vault collectionsWorkspace isolation in queries; encrypt sensitive payment metadata.
Existing stackMongoDB wire endpointReuse PyMongo, Node.js, or Go drivers inside the supported subset.
OperationsBackups, replication, GUIRestore, fail over, and support the store from one system.

The data model

Keep product content and SKU-level stock separate. A product page is one product plus its variants; a checkout is an order plus events.

CollectionPurposeUseful fields
productsSellable product and searchable content.sku, name, slug, description, search_text, category_id, brand, attributes, price, currency, status, embedding
variantsSKU-level price and stock.product_id, sku, options, price, stock, barcode, tenant_id
categoriesNavigation and breadcrumbs.name, slug, parent_id, path, tenant_id
ordersCheckout and fulfilment state.customer_id, items, total, currency, status, payment_status, shipping, created_at
cartsShort-lived shopping carts.customer_id, items, updated_at, tenant_id
_eventsOrder, payment, and fulfilment events.type, doc_id, payload, created_at

Core store workflows

1. Make catalog screens fast

Index the fields behind category pages, SKU lookup, and price filters. Enforce one SKU per tenant for products and variants.

{"op":"create_indexes","coll":"products","indexes":[
  {"fields":["tenant_id","sku"],"unique":true},
  {"fields":["tenant_id","category_id","status","updated_at"]},
  {"fields":["tenant_id","price"]}
]}
{"op":"create_indexes","coll":"variants","indexes":[
  {"fields":["tenant_id","sku"],"unique":true},
  {"fields":["tenant_id","product_id"]}
]}
{"op":"find","coll":"variants",
 "filter":{"tenant_id":"acme","product_id":"p_123"},
 "sort":[["price",1]],
 "limit":50}

2. Add search and recommendations

Build one search_text field from the product name, brand, category, and description. Text search ranks it; fuzzy search handles typos. Vector search is exact top-K over the indexed field — ideal for a focused catalog, not a substitute for a dedicated billion-vector service.

{"op":"create_text_index","coll":"products","field":"search_text"}
{"op":"create_fuzzy_index","coll":"products","field":"name"}
{"op":"create_vector_index","coll":"products","field":"embedding","dims":384,"metric":"cosine"}
{"op":"search","coll":"products","field":"search_text",
 "query":"wireless headphones",
 "filter":{"tenant_id":"acme","status":"active","category_id":"audio"},
 "limit":20}
{"op":"vector_search","coll":"products","field":"embedding",
 "vector":[0.12,-0.03,0.44],
 "filter":{"tenant_id":"acme","status":"active"},
 "limit":8}

3. Reserve stock safely

A conditional update decrements stock only when the requested quantity is available. If no document matches, the item is out of stock. Write the order after the reservation and reconcile abandoned reservations in a worker.

{"op":"find_and_modify","coll":"variants",
 "filter":{"tenant_id":"acme","sku":"SKU-1","stock":{"$gte":2}},
 "update":{"$inc":{"stock":-2}},
 "new":true}

4. Expire abandoned carts

Carts are temporary. Set a collection TTL for new carts and let the maintenance worker remove them. Do not use TTL for orders or inventory.

{"op":"create_collection","coll":"carts","ttl_seconds":604800}
{"op":"insert","coll":"carts",
 "doc":{"_id":"cart_123","tenant_id":"acme","customer_id":"c_1",
        "items":[],"updated_at":"2026-05-01T12:00:00Z"}}

Order events and reporting

Enable events for order status and payment changes. Payment, email, and fulfilment consumers read the outbox and keep their own checkpoints. Delivery is at-least-once, so handlers must be idempotent.

{"op":"set_collection_events","coll":"orders",
 "enabled":true,"fields":["status","payment_status"]}
{"op":"watch","coll":"_events","types":["orders.update"],
 "filter":{"payload.after.payment_status":"paid"},"after":"01J..."}
{"op":"aggregate","coll":"orders","pipeline":[
  {"$match":{"tenant_id":"acme","status":{"$ne":"cancelled"}}},
  {"$group":{"_id":"$status",
             "orders":{"$sum":1},
             "revenue":{"$sum":"$total"}}},
  {"$sort":{"revenue":-1}}
]}
Stock and orders need a deliberate flow. NonoDB gives you serialized writes and conditional updates, but an order and its stock decrement are still separate steps. Use a reservation state, an idempotent worker, and reconciliation for abandoned checkouts.

Where another tool fits better

Catalog, search, stock, and events in one binary.

Run the store on one database.