Building a Serverless Storefront: From Blueprint to Real-World Commerce

See how our ComposeIt PDF invoice and receipt and email blueprint evolved into a full serverless storefront with Payload CMS, Neon Postgres, and WorkflowSDK.

By Brendon Ngirazi
ComposeItE-CommerceServerless
Building a Serverless Storefront: From Blueprint to Real-World Commerce

What started as a simple blueprint store designed to show how ComposeIt powers transactional emails with PDF attachments in the form of invoices and receipts generated dynamically and sent out the moment an order goes through, grew into a full serverless storefront built for real-world retail operations.

Along the way, the blueprint evolved from a quick document-automation demo into a practical commerce stack powered by NextJS, Shadcn, Payload CMS, Neon Postgres and Workflow SDK. It features variant-level inventory tracking, and Paynow mobile money support, tailored for small-to-growing retail businesses in Zimbabwe and beyond.

Watch our blueprint demo showing checkout, dynamic PDF invoice/receipt generation, and ComposeIt transactional email delivery in action

How It Started: A Blueprint for PDFs in Transactional Emails

In real operations, customers and finance teams expect clean, branded PDFs, an invoice and a receipt, attached directly to transactional emails. The original blueprint store had one focused goal: prove how cleanly ComposeIt can generate dynamic PDFs and dispatch dynamic transactional emails with PDF attachments as part of a checkout flow. Once that foundation worked reliably, we couldn't help but expand it into a complete serverless storefront.

What Evolved Inside the Serverless Store

As the blueprint grew into a usable storefront architecture, several practical layers came together around that core document-and-email pipeline:

1. Durable Checkout & Stock Reservations

  • Atomic stock reservation: Variants track stock, reservedStock, and lowStockThreshold per (color, size) combination so shoppers don't overbuy items currently in checkout.
  • Resilient workflows: Checkout runs through durable workflows that reserve stock, wait on payment or fulfillment hooks, handle timeouts by releasing held stock, and trigger order creation plus ComposeIt PDF and email delivery once payment/checkout conditions are met.
  • Admin visibility: Order hooks and fulfillment loops keep order statuses and payment updates synchronized even when orders are updated after creation or paid on delivery/collection.

2. Local Delivery Math & Map-Based Checkout

  • Interactive map pin & address format: Customers can pick a drop-off spot on a Leaflet map, use browser geolocation, or enter a location.
  • Haversine + override flexibility: Distances default to Haversine calculations against store/collection points, with room to override distance with an external routing API when driving distance matters, paired with configurable base fees, per-km rates, free-delivery thresholds, and max delivery radius checks.

3. Pragmatic POS & Multi-Channel Reality

  • The storefront is built primarily around online orders, where online checkout and workflow stock reservations act as the source of truth.
  • For smaller operations, occasional walk-in sales can be reconciled lightly (even under a single walk-in customer record), while busier multi-channel stores can wire in-store POS events to trigger or subscribe to store workflows so stock stays aligned.

4. Storefront & Admin Polish

  • Built with Payload CMS and Neon Postgres, complete with light and dark mode support across both the storefront and the Payload Admin dashboard.

Why This Matters for Teams Using ComposeIt

If you're adopting ComposeIt, treating transactional emails with PDF attachments as part of an end-to-end workflow, rather than an afterthought bolted onto a checkout route makes the whole system easier to reason about, test, and scale. You get clean customer documents on every order while keeping inventory, payments, and fulfillment states consistent.

Where to Go Next

  • Explore the code & docs: Check out the repository for more info and it's GETTING_STARTED.md guide for environment setup (Payload, Neon, ComposeIt, and Paynow), and info on getting started.
  • Start automating you document operation: Get started today with ComposeIt

We use cookies to ensure you get the best experience on our website. For more information on how we use cookies, please see our privacy policy.