<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: StoreFlux</title>
    <description>The latest articles on DEV Community by StoreFlux (@storeflux).</description>
    <link>https://dev.to/storeflux</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4207347%2F2a8ef658-848f-45d9-9289-b7d5cb592cbb.png</url>
      <title>DEV Community: StoreFlux</title>
      <link>https://dev.to/storeflux</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/storeflux"/>
    <language>en</language>
    <item>
      <title>Invoice PDFs in a Multi-Tenant Backend: Who Can Download What, and Where the Edges Are</title>
      <dc:creator>StoreFlux</dc:creator>
      <pubDate>Mon, 16 Nov 2026 14:17:10 +0000</pubDate>
      <link>https://dev.to/storeflux/invoice-pdfs-in-a-multi-tenant-backend-who-can-download-what-and-where-the-edges-are-1ld2</link>
      <guid>https://dev.to/storeflux/invoice-pdfs-in-a-multi-tenant-backend-who-can-download-what-and-where-the-edges-are-1ld2</guid>
      <description>&lt;p&gt;An invoice PDF looks trivial until you add tenants, customers, and drafts. Then every download is an access-control decision. Here is how we handle it in StoreFlux, and where the edges are.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who can download what
&lt;/h2&gt;

&lt;p&gt;There are two download routes. Staff use the admin route, and customers use the storefront route for their own orders. Both run the same query handler.&lt;/p&gt;

&lt;p&gt;The handler resolves the invoice first. For an order, it looks up the invoice that belongs to that order and the current tenant. If no invoice exists, the answer is not found, because there is nothing to render.&lt;/p&gt;

&lt;p&gt;Then it checks ownership. A super admin can read across tenants. Everyone else must match the invoice's tenant, or the request throws an unauthorized tenant error.&lt;/p&gt;

&lt;p&gt;A customer gets one more rule. They can only open invoices where the invoice's user is them, and a draft is never shown to a customer. For anyone else, the handler returns nothing, which becomes a not-found response. We chose not-found over forbidden on purpose, because a forbidden answer would confirm that the invoice exists.&lt;/p&gt;

&lt;h2&gt;
  
  
  Built from the record
&lt;/h2&gt;

&lt;p&gt;The PDF is rendered from the invoice record, its line items, and the refund information for the order, so the figures match what the order says. The dates use the tenant's own time zone, so a store's invoices do not shift by a day because the server runs somewhere else.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rendering
&lt;/h2&gt;

&lt;p&gt;We use QuestPDF under its Community license, behind an interface (IInvoicePdfRenderer). The interface means the renderer can be swapped or tested without touching the handler.&lt;/p&gt;

&lt;p&gt;One setting matters for stores that sell in more than one script. QuestPDF normally fails the whole document when a character has no glyph in the fonts it can see. We turn that check off, so a name in a script with no installed font shows a placeholder for those characters instead of failing the invoice. The container image installs DejaVu and Noto fonts for this.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this does not claim
&lt;/h2&gt;

&lt;p&gt;A PDF exists only where an invoice record exists. Invoices are created by hand or when an order is confirmed, depending on how the store is set up. We do not create a PDF for every order automatically.&lt;/p&gt;

&lt;p&gt;The wording and due dates on these invoices are marked in our code as needing finance review. We do not claim the layout is a tax-compliant invoice in every country.&lt;/p&gt;

&lt;h2&gt;
  
  
  Open question
&lt;/h2&gt;

&lt;p&gt;If you have shipped invoices across countries: how do you handle numbering and required fields when the rules change by jurisdiction? I would like to see what has worked in practice.&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>pdf</category>
      <category>ecommerce</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Hot take: a discount in your abandoned cart email trains shoppers to wait</title>
      <dc:creator>StoreFlux</dc:creator>
      <pubDate>Thu, 12 Nov 2026 15:10:48 +0000</pubDate>
      <link>https://dev.to/storeflux/hot-take-a-discount-in-your-abandoned-cart-email-trains-shoppers-to-wait-46jc</link>
      <guid>https://dev.to/storeflux/hot-take-a-discount-in-your-abandoned-cart-email-trains-shoppers-to-wait-46jc</guid>
      <description>&lt;p&gt;Most abandoned carts are not decisions. Someone got distracted, the page was slow, or they meant to come back later. A reminder catches some of them. The question is what the follow-up teaches.&lt;/p&gt;

&lt;p&gt;Here is the sequence we shipped in StoreFlux, and the part I am not sure about.&lt;/p&gt;

&lt;h2&gt;
  
  
  The sequence
&lt;/h2&gt;

&lt;p&gt;Three emails, measured from the cart going quiet. The defaults are one hour, 24 hours, and 72 hours. The sweep checks each cart before it sends, and it stops the moment the shopper completes an order, so nobody gets a reminder about a purchase they already made. Each stage is recorded, so re-running the sweep does not send the same stage twice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the discount goes
&lt;/h2&gt;

&lt;p&gt;The discount can only be issued on the third email. It also needs two things to be true: the store has the include-coupon setting on, and the Coupons module is enabled for that tenant. If either is off, the third email goes out without a code.&lt;/p&gt;

&lt;p&gt;We put it last on purpose. A discount in the first email tells people the price drops if they wait a day. That is a lesson we did not want to teach.&lt;/p&gt;

&lt;h2&gt;
  
  
  The other side
&lt;/h2&gt;

&lt;p&gt;I can see the argument against us. For some shoppers, a cart from three days ago is a second chance, and a discount is what gets them to finish. Holding the discount until the end may mean the offer arrives after the shopper has already moved on, while the people who would have bought anyway get nothing extra.&lt;/p&gt;

&lt;p&gt;I do not think there is a clean answer. That is why this is a discussion post, not a feature announcement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Questions
&lt;/h2&gt;

&lt;p&gt;Does a recovery discount train shoppers to abandon carts on purpose? If it does, where would you draw the line: no discount at all, a discount only for returning customers, or a smaller one at the end? What has actually worked or failed on your own store?&lt;/p&gt;

&lt;p&gt;Tell me in the comments. I would rather hear a strong disagreement than a polite nod.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>ecommerce</category>
      <category>saas</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Smart Collections Without a Query Engine: Rules That Write Plain Membership Rows</title>
      <dc:creator>StoreFlux</dc:creator>
      <pubDate>Tue, 10 Nov 2026 19:13:15 +0000</pubDate>
      <link>https://dev.to/storeflux/smart-collections-without-a-query-engine-rules-that-write-plain-membership-rows-4gh8</link>
      <guid>https://dev.to/storeflux/smart-collections-without-a-query-engine-rules-that-write-plain-membership-rows-4gh8</guid>
      <description>&lt;p&gt;Collections in most shops start as hand-picked lists. Someone adds products one by one, and the list goes stale as soon as stock changes or a new product arrives. Smart collections fix that with rules. The interesting part is how we built them, because we deliberately did not build a query engine.&lt;/p&gt;

&lt;h2&gt;
  
  
  A rule is a small, closed set
&lt;/h2&gt;

&lt;p&gt;A rule is a field, an operator, and a value. The fields are title (contains or equals), tag (is or is not), category (is), price (at least or at most), on sale (yes or no), in stock (yes or no), and new arrival (within 1 to 365 days). A collection matches all of its rules or any of them.&lt;/p&gt;

&lt;p&gt;Validation rejects an unknown field, an operator the field does not support, a price that is not a number, a category that is not an id, and a new arrival window outside 1 to 365. Those checks run before anything is written, so a bad rule never becomes a collection that silently matches nothing.&lt;/p&gt;

&lt;p&gt;Because the set is closed, every rule is evaluated in memory against a product's facts: title, tags, category, price, compare-at price, whether any variant is available, and creation time. We do not translate rules into SQL. The logic stays in one place and is easy to test.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preview before you save
&lt;/h2&gt;

&lt;p&gt;The editor calls a preview endpoint with the draft rules. It returns the count of matching products and a sample of up to twelve names, and it saves nothing. A store owner can check that a rule like tag is summer, price at most 50 matches what they expect before the collection goes live.&lt;/p&gt;

&lt;h2&gt;
  
  
  It writes the same rows as a manual collection
&lt;/h2&gt;

&lt;p&gt;A refresh writes the same membership rows a manual collection uses. The admin, the storefront, and the counts already read those rows, so none of them needed to change. A refresh works out the wanted set, removes members that no longer match, and adds the new ones, newest first. Running it twice changes nothing, so it is safe to retry.&lt;/p&gt;

&lt;h2&gt;
  
  
  When it runs
&lt;/h2&gt;

&lt;p&gt;A background job starts five minutes after the process boots, then refreshes every ten minutes. It takes a distributed lock first, so only one instance does the work in a multi-instance deployment. Saving rules also applies them straight away, and an admin can trigger a refresh by hand.&lt;/p&gt;

&lt;p&gt;The ten minute delay is a real trade-off. A product that sells out can stay in a collection for up to ten minutes. We chose that over re-evaluating on every stock change, which would touch the whole catalogue constantly for every tenant.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;p&gt;Each refresh loads at most 20,000 active products per tenant, and the collection is computed only from those. The cap is a constant in the code, not a setting. A catalogue larger than that will not get a complete smart collection, so stores that big should stick to manual collections for now.&lt;/p&gt;

&lt;p&gt;Rules cannot reference metafields, order history, or customer segments. Manual collections still cover anything the rules cannot express.&lt;/p&gt;

&lt;p&gt;If you have built collection rules differently, I would like to compare approaches in the comments.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
      <category>ecommerce</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Branding a Multi-Tenant Admin From One Color: How the Palette Is Built</title>
      <dc:creator>StoreFlux</dc:creator>
      <pubDate>Sun, 08 Nov 2026 16:29:32 +0000</pubDate>
      <link>https://dev.to/storeflux/branding-a-multi-tenant-admin-from-one-color-how-the-palette-is-built-590a</link>
      <guid>https://dev.to/storeflux/branding-a-multi-tenant-admin-from-one-color-how-the-palette-is-built-590a</guid>
      <description>&lt;p&gt;Every store on StoreFlux gets its own admin dashboard, and store owners want it to look like their brand, not ours. That means the admin has to be themeable from a few inputs, and it has to stay readable when someone picks a color that is too light, too dark, or the wrong shade of blue.&lt;/p&gt;

&lt;p&gt;This is how the Admin Branding page works, and how the palette is built.&lt;/p&gt;

&lt;h2&gt;
  
  
  One input, eleven shades
&lt;/h2&gt;

&lt;p&gt;The store owner picks a primary color. The admin generates an 11-step scale from it, labelled 50 to 950, the same shape Tailwind uses. The generator converts the hex color to HSL, keeps the hue and saturation, and sets lightness at fixed targets: 96% for step 50, falling to 20% for step 950.&lt;/p&gt;

&lt;p&gt;Lightness alone can make the ends of a scale look neon or muddy. So the generator lowers saturation at the very light and very dark steps, by 15 points near the top and 10 near the bottom, with a floor so those colors never turn grey.&lt;/p&gt;

&lt;h2&gt;
  
  
  Applied as CSS variables
&lt;/h2&gt;

&lt;p&gt;The palette is written as CSS custom properties on the root element. The primary color drives the indigo, blue, and sky utilities, and the accent drives violet and purple. Because the utilities read those variables, the whole admin picks up the brand without changing component code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Readable by design
&lt;/h2&gt;

&lt;p&gt;Brand colors are easy to get wrong. The branding page shows the contrast ratio between text and background colors, so a store owner can see when sidebar text is hard to read. The sidebar preview is a copy of the real sidebar layout, so what you see while editing matches what gets saved.&lt;/p&gt;

&lt;h2&gt;
  
  
  Corners, presets, and per-browser looks
&lt;/h2&gt;

&lt;p&gt;Corner style maps to a radius scale (sharp, default, or rounded) applied to the same variables used across the UI. Six presets set colors, sidebar, typeface, and corners together, so a store owner can start from a complete look and adjust from there.&lt;/p&gt;

&lt;p&gt;Staff can also pick one of four ready-made looks for their own browser. That changes only how that browser displays the admin, not the store's branding.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this does not cover
&lt;/h2&gt;

&lt;p&gt;Admin Branding changes the admin dashboard. Storefront theme colors are a separate setting on the store and this page does not change them. Keeping them separate means a store's branding work does not silently change what customers see.&lt;/p&gt;

&lt;p&gt;If you have handled tenant theming in a different way, I would like to compare notes in the comments.&lt;/p&gt;

</description>
      <category>react</category>
      <category>css</category>
      <category>saas</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Abandoned Carts Only Recover If Something Follows Up: How Our Cart Sequence Works</title>
      <dc:creator>StoreFlux</dc:creator>
      <pubDate>Sun, 08 Nov 2026 09:15:12 +0000</pubDate>
      <link>https://dev.to/storeflux/abandoned-carts-only-recover-if-something-follows-up-how-our-cart-sequence-works-4i7p</link>
      <guid>https://dev.to/storeflux/abandoned-carts-only-recover-if-something-follows-up-how-our-cart-sequence-works-4i7p</guid>
      <description>&lt;p&gt;Most abandoned carts are not a decision to leave. Someone got distracted, the page felt slow, or they meant to come back and forgot. A single reminder catches some of them. A sequence catches more, as long as it stops the moment the shopper buys.&lt;/p&gt;

&lt;p&gt;Here is how the cart recovery sequence in StoreFlux works, using the default timings.&lt;/p&gt;

&lt;h2&gt;
  
  
  The schedule
&lt;/h2&gt;

&lt;p&gt;There are three emails. The defaults are 1 hour, 24 hours, and 72 hours (60, 1440, and 4320 minutes). The first is a gentle reminder, the second is a second nudge the next day, and the third is the one that can carry a recovery discount. Each stage's timing is configurable per store.&lt;/p&gt;

&lt;h2&gt;
  
  
  It stops when they buy
&lt;/h2&gt;

&lt;p&gt;Before each send, the sweeper checks whether the cart has converted to an order. If the shopper completed checkout, the remaining emails are not sent. Nobody gets a reminder about a purchase they already made.&lt;/p&gt;

&lt;h2&gt;
  
  
  The discount is opt-in, and gated
&lt;/h2&gt;

&lt;p&gt;The third email can issue a recovery coupon, but only when two things are both true: the store has the include-coupon setting turned on, and the Coupons module is enabled for that tenant. If either is off, the third email goes out without a code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Safe to re-run
&lt;/h2&gt;

&lt;p&gt;The sweep runs in batches (up to 200 carts per pass) and processes only stores that have recovery enabled. Each send is tracked, so re-running a pass does not email the same shopper twice for the same stage.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this is not
&lt;/h2&gt;

&lt;p&gt;This is a sequence of three emails with a clear stop condition. It is not a prediction model and it does not guess who will buy. We chose the simple version on purpose: it is easy to reason about, easy to turn off, and it never emails someone who has already bought.&lt;/p&gt;

&lt;p&gt;If you have tuned cart recovery timings on your own store, I would like to hear what worked in the comments.&lt;/p&gt;

&lt;p&gt;storeflux.store&lt;/p&gt;

</description>
      <category>ecommerce</category>
      <category>webdev</category>
      <category>saas</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>Building Subscriptions Without Storing a Single Card Number</title>
      <dc:creator>StoreFlux</dc:creator>
      <pubDate>Thu, 05 Nov 2026 20:14:39 +0000</pubDate>
      <link>https://dev.to/storeflux/building-subscriptions-without-storing-a-single-card-number-1ohd</link>
      <guid>https://dev.to/storeflux/building-subscriptions-without-storing-a-single-card-number-1ohd</guid>
      <description>&lt;p&gt;We just added recurring product subscriptions to StoreFlux (a headless commerce backend), and the design decision I want to write about is the one that felt obvious in hindsight but wasn't the first thing I reached for: we don't store a customer's card at all.&lt;/p&gt;

&lt;h3&gt;
  
  
  The instinct everyone has first
&lt;/h3&gt;

&lt;p&gt;The "normal" way to build subscriptions is to tokenize the customer's card on the gateway (Stripe customer + payment method, say), save that token, and on each billing date fire an off-session charge against it. That's a completely reasonable design. It's also one most commerce platforms already have sitting around, because it's the obvious answer.&lt;/p&gt;

&lt;p&gt;I didn't want to build that, for a fairly unglamorous reason: it's a second payment path. Checkout already has a payment path — tested, handles declines, handles 3D Secure challenges, handles webhooks, handles every gateway-specific weirdness we've already run into. A separate off-session billing path duplicates all of that, badly, because off-session charges can't show the customer a 3DS challenge if one gets triggered. You end up with checkout's payment logic and subscription-billing's payment logic silently diverging over time as each gets bugfixed independently.&lt;/p&gt;

&lt;h3&gt;
  
  
  What we did instead
&lt;/h3&gt;

&lt;p&gt;A subscription doesn't store a payment method at all. On each billing cycle, a background job builds a normal cart from the subscription's line items and runs it through the exact same &lt;code&gt;CheckoutCartCommand&lt;/code&gt; a human customer's browser calls when they check out themselves. Same validation, same stock checks, same tax calculation, same payment-provider dispatch. The subscription system's job is entirely "decide when the next cycle is due and what's in it" — it has no opinion about payments at all, because it never touches that code.&lt;/p&gt;

&lt;p&gt;This means whatever payment method support checkout has, subscriptions automatically have too, with zero subscription-specific payment code. Add a new gateway to checkout, subscriptions get it for free. Fix a checkout payment bug, subscriptions get the fix for free. There's structurally no way for the two to drift apart, because there's only one.&lt;/p&gt;

&lt;h3&gt;
  
  
  The real tradeoff: no off-session silent renewal
&lt;/h3&gt;

&lt;p&gt;The honest downside is that this doesn't work for "quietly keep charging in the background with zero customer involvement," the way a tokenized-card system does. Depending on exactly how checkout is wired for a given tenant's gateway config, a renewal might need an active customer session rather than a true fire-and-forget background charge — this is store-config-dependent since it rides on whatever payment flow checkout already uses. If a tenant specifically needs true zero-touch background billing with a stored card and off-session charging, this isn't that. It's a deliberate "reuse what's already correct" design instead of a maximally-automated one, and for v1 that tradeoff made sense: fewer payment code paths beats one extra convenience feature.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why this mattered enough to write up
&lt;/h3&gt;

&lt;p&gt;PCI scope is the other half of why this felt right. Not storing card data means not being in the business of protecting card data — no vault to encrypt, no extra attack surface, nothing to accidentally leak in a backup or a log line. "We don't have the data" is a stronger security property than "we encrypted the data well." Every stored-card system is one bug away from a very bad day; a system with no stored cards doesn't have that bug available to make.&lt;/p&gt;

&lt;p&gt;Curious whether anyone else building subscription billing has made the same call, or deliberately gone the other way and found reuse wasn't worth losing silent off-session renewal. Feels like a real tradeoff either direction, not an obviously-correct one.&lt;/p&gt;

&lt;p&gt;storeflux.store if you want to see where it landed in the actual product.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>fintech</category>
      <category>security</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>Modeling Cash Drawer Variance: Event-Sourced Shifts in an Offline POS</title>
      <dc:creator>StoreFlux</dc:creator>
      <pubDate>Wed, 04 Nov 2026 16:39:13 +0000</pubDate>
      <link>https://dev.to/storeflux/modeling-cash-drawer-variance-event-sourced-shifts-in-an-offline-pos-2edg</link>
      <guid>https://dev.to/storeflux/modeling-cash-drawer-variance-event-sourced-shifts-in-an-offline-pos-2edg</guid>
      <description>&lt;p&gt;The payments side of our POS (StoreFlux, a headless commerce backend) got most of the write-up attention so far. The shift and cash-drawer accounting underneath it is smaller in scope but had its own interesting constraints, so here's how that part actually works.&lt;/p&gt;

&lt;h3&gt;
  
  
  The requirement: a real variance number, not a vibe
&lt;/h3&gt;

&lt;p&gt;A cashier opens a shift with a starting cash count. Through the shift they take cash payments, maybe pay cash out for something (a supplier delivery, petty expenses), maybe put more cash in. At close, they count the drawer again. The number that matters is: what &lt;em&gt;should&lt;/em&gt; be in there, given everything that happened, versus what's &lt;em&gt;actually&lt;/em&gt; in there. That gap is the variance, and it has to be a real computed number a manager can look at, not something eyeballed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Shifts are event-sourced, same as the rest of the till
&lt;/h3&gt;

&lt;p&gt;Everything at the register already flows through an outbox of client-generated, idempotent events (sales, refunds, product edits — covered in an earlier post). Shifts fit the same model instead of getting special-cased: &lt;code&gt;shift.opened&lt;/code&gt; (carries the starting float), &lt;code&gt;cash.moved&lt;/code&gt; (a paid-in or paid-out, with a reason), and &lt;code&gt;shift.closed&lt;/code&gt; (carries the counted-at-close amount). The shift's id is literally the register's client-generated guid for that shift — no separate id-minting round trip needed before the register can start tagging sales with which shift they belong to.&lt;/p&gt;

&lt;p&gt;Every sale and refund that happens during an open shift carries that shift id. That's what makes the expected-cash calculation possible after the fact: starting float, plus cash collected from sales in that shift, minus cash refunded, plus or minus any manual cash movements, equals what should be in the drawer. Compare that to the counted amount from &lt;code&gt;shift.closed&lt;/code&gt; and the variance falls out.&lt;/p&gt;

&lt;h3&gt;
  
  
  Doing that math in two places, correctly, is the actual hard part
&lt;/h3&gt;

&lt;p&gt;Same story as the money math elsewhere in this system: the Rust register computes an expected-cash number locally so a cashier can see it the moment they close a shift, with zero network round trip. The C# server computes the &lt;em&gt;same&lt;/em&gt; number independently once the events land, because the server is the one source of truth once everything's synced — a register's local math is a preview, not the final answer. Those two computations have to agree, or a manager ends up staring at two different "the drawer should have X in it" numbers from the same shift and trusting neither.&lt;/p&gt;

&lt;p&gt;This is handled with the same parity-testing discipline as the rest of the sync layer: replay a shift's full event sequence through both implementations and diff the result. It's not glamorous, but it's the only way I trust two independently-written pieces of arithmetic to actually match under real event orderings, including the annoying cases — multiple cash-outs in one shift, a refund that happens to land in a different shift than its original sale because it was processed offline and back-dated to the sale's actual time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Offline refunds and which shift they belong to
&lt;/h3&gt;

&lt;p&gt;That last case deserves its own mention because it was a genuine bug we caught, not a hypothetical. A refund processed while offline gets dated to when it actually happened, not when it finally syncs — otherwise a refund given during Tuesday's shift could get silently counted against Wednesday's drawer because that's when the connection came back. Getting this right means the variance calculation for a shift has to be based on "what happened during this shift's real time window," not "what the server received while this shift's status was open." Those are subtly different, and conflating them is exactly the kind of bug that doesn't show up in testing until you specifically simulate being offline across a shift boundary.&lt;/p&gt;

&lt;h3&gt;
  
  
  What a manager actually sees
&lt;/h3&gt;

&lt;p&gt;None of this is exposed as raw event data, obviously — the owner-facing side is just an endpoint that returns a shift with its expected cash, counted cash, and variance already computed, plus the list of cash movements with whatever reason the cashier entered. The accounting happens once, server-side, from the event history; nothing is recomputed differently depending on who's asking.&lt;/p&gt;

&lt;p&gt;Still open: an X-report style printable summary at shift close, and automatic variance-threshold alerts (right now a manager has to go looking at the dashboard rather than getting proactively flagged when a shift closes meaningfully short or over). Those are next.&lt;/p&gt;

&lt;p&gt;storeflux.store/#pos if you want to see where this sits in the product. Curious whether anyone else doing register/shift software has hit the same "two engines must agree on money" problem and solved it differently than parity testing.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>rust</category>
      <category>dotnet</category>
      <category>fintech</category>
    </item>
    <item>
      <title>Building an Offline-First POS That Stays Consistent With an Online Store</title>
      <dc:creator>StoreFlux</dc:creator>
      <pubDate>Mon, 02 Nov 2026 17:54:44 +0000</pubDate>
      <link>https://dev.to/storeflux/building-an-offline-first-pos-that-stays-consistent-with-an-online-store-37lh</link>
      <guid>https://dev.to/storeflux/building-an-offline-first-pos-that-stays-consistent-with-an-online-store-37lh</guid>
      <description>&lt;p&gt;We just shipped a Windows point of sale for StoreFlux (a headless commerce backend) that keeps working with no internet connection and never drifts out of sync with the online store it's attached to. Wanted to write up the actual mechanics, since "offline-first" gets used a lot as a buzzword without the plumbing behind it.&lt;/p&gt;

&lt;h3&gt;
  
  
  An outbox of idempotent events, not a sync API
&lt;/h3&gt;

&lt;p&gt;Every action at the till — a sale, a refund, a shift open/close, a stock adjustment, a product edit — gets written to a local SQLCipher database in the same transaction as the receipt and the stock change, plus one row in an outbox table. A background loop drains that outbox to the server in order. Each event carries a client-generated id, and the server only ever applies a given id once. That one property is what makes a retry safe: if the network dies mid-request and the register doesn't know whether the server got it, it just resends the same event with the same id, and worst case the server politely no-ops it instead of creating a duplicate order.&lt;/p&gt;

&lt;h3&gt;
  
  
  The register and the server agree on money, because they're tested against each other
&lt;/h3&gt;

&lt;p&gt;The till logic is written in Rust (&lt;code&gt;rust_decimal&lt;/code&gt; for the actual math), the server side in C#. Those are two different type systems making the same calculations — tax, split tenders, discounts, change — and if they ever disagree by a cent, that's a real bug, not a rounding quirk to shrug off. So there's a parity test that replays identical sales through both engines and diffs the totals, tax, and stock to the cent. It's already caught two real bugs this way: refund restock math that didn't match between the two sides, and offline refunds that were getting dated at upload time instead of at the actual time of the sale — which matters a lot once you're closing out a shift and the cash doesn't add up because a refund landed in the wrong shift.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stock is server stock plus local deltas, not an independent count
&lt;/h3&gt;

&lt;p&gt;A register doesn't keep its own authoritative stock number. It shows the last full stock pull from the server, minus whatever it's sold locally and hasn't uploaded yet. That sounds like a small detail but it's the difference between "two tills at two different shops double-selling the last unit of something" and not — because neither till is pretending to own the real count, they're both just showing a server snapshot plus their own pending deltas.&lt;/p&gt;

&lt;h3&gt;
  
  
  Counter sales can't be allowed to lie to the analytics
&lt;/h3&gt;

&lt;p&gt;This was a design decision I almost got wrong early on: should a point-of-sale order "count" the same as a website order everywhere? No — specifically not in the conversion funnel. Every order carries a channel now. Counter sales count fully in revenue, tax, and average order value (they're real money), but the website's conversion-rate and cart-abandonment numbers only look at online orders. Otherwise a slow week online looks artificially fine because the shop next door had a good Saturday, and that's actively misleading for anyone trying to diagnose their actual storefront.&lt;/p&gt;

&lt;h3&gt;
  
  
  Every receipt is also a lookup key
&lt;/h3&gt;

&lt;p&gt;The receipt number prints as a barcode (CODE128, with the module width picked based on paper size so it actually fits a 58mm roll) or a QR code depending on config. Scan that receipt back into the app — at the counter, days later — and it opens that exact sale for a reprint or a refund. It's a small thing but it removes an entire category of "customer lost their receipt, now what" friction.&lt;/p&gt;

&lt;h3&gt;
  
  
  Security assumptions for something that lives on a shop's PC, unattended
&lt;/h3&gt;

&lt;p&gt;A register activates with a one-time code and gets back a token that's stored hashed and bound to that specific machine's fingerprint, not something that's portable if someone copies a config file. The local database's encryption key lives in the OS credential store, not in a config file next to the database itself. And a register that's been offline longer than a configured grace period locks itself until it can reach the server again — better a cashier has to wait a minute for connectivity than a stolen laptop keeps ringing up sales indefinitely with no way to revoke it remotely.&lt;/p&gt;

&lt;p&gt;Live now if you want to see where it landed: storeflux.store/#pos&lt;/p&gt;

&lt;p&gt;Curious if anyone else has built something similar — specifically interested in how other people have handled the "two independent codebases computing the same money math" problem. Parity testing felt like the obvious answer once we needed it, but I'd like to hear if there's a cleaner pattern.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>rust</category>
      <category>tauri</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>Designing a Multi-Tenant SaaS So Core Features Never Get Paywalled</title>
      <dc:creator>StoreFlux</dc:creator>
      <pubDate>Sun, 01 Nov 2026 12:10:48 +0000</pubDate>
      <link>https://dev.to/storeflux/designing-a-multi-tenant-saas-so-core-features-never-get-paywalled-4519</link>
      <guid>https://dev.to/storeflux/designing-a-multi-tenant-saas-so-core-features-never-get-paywalled-4519</guid>
      <description>&lt;p&gt;A thing I kept running into while building StoreFlux (a multi-tenant commerce backend): the moment you add enough optional features, you start wanting some way to gate them per tenant. The usual answer is a feature-flag system or a plan-tier check scattered across controllers. I didn't want either, so here's what we actually built instead.&lt;/p&gt;

&lt;h3&gt;
  
  
  The rule we set first
&lt;/h3&gt;

&lt;p&gt;Core commerce — products, orders, customers, payments, inventory — is never behind a flag, a plan, or a tier. If a tenant can sign up, they get all of that, full stop. Everything else lives in a short, closed list of optional modules: realtime, AI, loyalty, referrals, B2B, coupons, gift cards, banners, SEO, social ads, carriers, API keys, webhooks. Thirteen of them right now.&lt;/p&gt;

&lt;p&gt;Every module ships &lt;strong&gt;off&lt;/strong&gt; by default for every tenant. A SuperAdmin turns one on for a specific tenant — there's no self-serve upgrade flow yet, it's deliberate and manual. The catalog itself is a single source-of-truth file mapping module keys to names/descriptions, not scattered constants.&lt;/p&gt;

&lt;h3&gt;
  
  
  Enforcement, not just UI hiding
&lt;/h3&gt;

&lt;p&gt;The thing I didn't want was a system where the backend trusts the frontend to hide a module and calls it done — that's not gating, that's decoration. So enforcement happens as an authorization attribute on the actual API controllers. Roughly 20 endpoints across the admin API carry it. If a tenant doesn't have a module enabled and somehow hits that endpoint anyway (stale UI, direct API call, whatever), they get a 403 with a specific &lt;code&gt;MODULE_DISABLED&lt;/code&gt; code, not a generic permission error.&lt;/p&gt;

&lt;p&gt;Two cases bypass the check entirely: SuperAdmin requests (they need to reach anything to manage it) and anonymous/public requests (storefront-facing endpoints aren't gated this way — that's a separate, not-yet-solved problem, more below).&lt;/p&gt;

&lt;h3&gt;
  
  
  Where the enabled-set actually lives
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Tenant.EnabledModules&lt;/code&gt; is a jsonb column — an array of the module keys that are on. Checking it on every request would mean a database hit per request, so there's a small service that caches the enabled-set in Redis for 60 seconds per tenant, invalidated immediately whenever a SuperAdmin changes the set. 60 seconds felt like a reasonable tradeoff between "changes take effect fast enough to matter" and "we're not hammering Redis on every single request."&lt;/p&gt;

&lt;h3&gt;
  
  
  The frontend side has to fail open, not closed
&lt;/h3&gt;

&lt;p&gt;This is the detail I almost got backwards. The admin panel fetches the tenant's enabled modules once on load and uses it to filter the sidebar nav and guard routes. My first instinct was: if that fetch fails, hide everything, safe default. Wrong instinct — if a flaky network blip makes that call fail, you don't want the entire optional-features section of someone's store to vanish on them. So it fails &lt;em&gt;open&lt;/em&gt;: a failed fetch just means nothing gets filtered out client-side, and the real enforcement is still sitting on the backend regardless. The frontend check is a UX nicety, not the security boundary — the API attribute is.&lt;/p&gt;

&lt;h3&gt;
  
  
  What's still unsolved
&lt;/h3&gt;

&lt;p&gt;Storefront-facing pages (the actual customer-visible store, not the admin panel) don't check module state at all yet. If a tenant has, say, loyalty disabled, the admin UI correctly hides it — but a loyalty widget baked into their storefront theme would still render, because the storefront controller is anonymous and currently ungated for this purpose. Fixing that needs resolving tenant identity from the store's slug inside an otherwise-anonymous request path, which I haven't done yet. Flagging it here mostly because "ship it, write it down, fix it later" felt more honest than pretending it's already solved.&lt;/p&gt;

&lt;p&gt;Curious if anyone else has built a similar opt-in-module system for a multi-tenant product — specifically interested in how you handled the storefront/anonymous-path version of this same gating problem, since that's the part I don't have a clean answer for yet.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>saas</category>
      <category>multitenancy</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>3 Bugs We Found Auditing Our Own Payments System (Before a Customer Did)</title>
      <dc:creator>StoreFlux</dc:creator>
      <pubDate>Sat, 31 Oct 2026 14:31:13 +0000</pubDate>
      <link>https://dev.to/storeflux/3-bugs-we-found-auditing-our-own-payments-system-before-a-customer-did-5f95</link>
      <guid>https://dev.to/storeflux/3-bugs-we-found-auditing-our-own-payments-system-before-a-customer-did-5f95</guid>
      <description>&lt;p&gt;We didn't have an incident. Nothing was on fire. We just decided to sit down and audit our own payments and refunds code the way we'd audit someone else's — assuming it was wrong somewhere, and trying to prove it.&lt;/p&gt;

&lt;p&gt;It was wrong in three places. Here's what we found.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bug 1: cancelling an order quietly leaked everything
&lt;/h3&gt;

&lt;p&gt;Checkout deducts stock, credits used gift card balance against the order, and records coupon usage — all inside one transaction, which is correct, because checkout really is one atomic operation.&lt;/p&gt;

&lt;p&gt;The problem showed up later. If that order got cancelled before it was ever paid — which happens constantly, people abandon pending COD orders, staff cancel stale carts — none of that got reversed. No restock. No gift card credit given back. No coupon usage released. The inventory number just silently drifted further from reality every time this happened, forever, with nothing in the logs to tell you it was happening.&lt;/p&gt;

&lt;p&gt;The fix was two parts. First, cancelling an order that's still unpaid now triggers the reverse of checkout — restock, gift card credit, coupon release — but only when payment status is still pending/processing/failed, never for something already paid (that goes through a real refund instead, which already had its own restock logic). Second, we added a background job that auto-cancels orders still sitting unpaid after 48 hours, because the bug wasn't really "cancel doesn't restock" — it was "nothing was watching abandoned orders at all."&lt;/p&gt;

&lt;h3&gt;
  
  
  Bug 2: our refund idempotency key wasn't actually durable
&lt;/h3&gt;

&lt;p&gt;We had an idempotency key on refunds specifically to stop a retried request from double-refunding a customer. Looked fine in the code. The problem was where it lived: generated in memory when the refund object was created, and only written to the database &lt;em&gt;after&lt;/em&gt; the actual gateway call to Stripe/PayPal already succeeded.&lt;/p&gt;

&lt;p&gt;That ordering is the whole bug. If the process died between "gateway confirms the refund" and "we save the row with that key," a retry wouldn't recognize anything — it would generate a brand new key and refund the customer a second time. The lock we already had prevented two &lt;em&gt;simultaneous&lt;/em&gt; refund requests from racing each other, but this was a sequential retry-after-crash problem, which a lock does nothing for.&lt;/p&gt;

&lt;p&gt;Fixed by restructuring into two real phases: create the refund row as "processing" and commit that to the database &lt;em&gt;before&lt;/em&gt; calling the gateway. On any retry, we look for an existing "processing" row for the same payment/amount/reason and resume that one instead of creating a fresh row with a fresh key. The crash-signature and the resume-signature are now the same thing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bug 3: return refunds never touched the actual payment gateway
&lt;/h3&gt;

&lt;p&gt;This one's embarrassing in retrospect. The RMA (return merchandise) refund flow marked the order "refunded" in the dashboard and generated something that looked like a gateway refund ID — but it was fabricated, a formatted string, not a real response from Stripe or PayPal. For every single return, regardless of how the customer originally paid.&lt;/p&gt;

&lt;p&gt;So a customer returns something, support marks the return complete, the dashboard says refunded — and the customer's actual card or PayPal account was never touched. The money just sits there until someone notices the complaint.&lt;/p&gt;

&lt;p&gt;The fix was almost insultingly simple once found: delete the fabrication, and route RMA refunds through the exact same refund command real admin-initiated refunds use — the one that actually calls Stripe or PayPal and has the idempotency fix from bug 2 baked in. One code path instead of two.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why we're posting this instead of staying quiet about it
&lt;/h3&gt;

&lt;p&gt;"We tested it" almost always means "we tested the paths we expected someone to take." The expensive bugs live in the paths that only show up under real-world weirdness — abandoned carts, process crashes mid-request, a return flow nobody stress-tested because it's not the exciting part of the system. We'd rather find those ourselves and talk about it than have a customer find one for us.&lt;/p&gt;

&lt;p&gt;If you maintain a payments system of your own — what's the equivalent story you've got? Genuinely curious what shape these bugs take in other people's systems.&lt;/p&gt;

</description>
      <category>postmortem</category>
      <category>fintech</category>
      <category>architecture</category>
      <category>postgres</category>
    </item>
    <item>
      <title>JSONB, Dynamic Columns, or a Search Engine — How Do You Store Tenant-Defined Fields?</title>
      <dc:creator>StoreFlux</dc:creator>
      <pubDate>Fri, 30 Oct 2026 20:43:53 +0000</pubDate>
      <link>https://dev.to/storeflux/jsonb-dynamic-columns-or-a-search-engine-how-do-you-store-tenant-defined-fields-5a2e</link>
      <guid>https://dev.to/storeflux/jsonb-dynamic-columns-or-a-search-engine-how-do-you-store-tenant-defined-fields-5a2e</guid>
      <description>&lt;p&gt;Been thinking about this one for a while and figured I'd actually ask instead of just assuming our answer is right.&lt;/p&gt;

&lt;p&gt;The problem: a multi-tenant product catalog where each tenant can define their own fields on a category — any name, any type, decided at runtime by the store owner, not by us. A car gets "Mileage." A t-shirt gets "Size" and "Color." Nothing hardcoded per vertical.&lt;/p&gt;

&lt;p&gt;We ended up with JSONB as the source of truth plus a separate typed index table (text/number/bool/date columns) that gets fully rebuilt from the JSONB on every save, inside the same transaction. It works, but it's a double write on every save, and the index table has no FK back to products (partitioned table, so that's off the table anyway).&lt;/p&gt;

&lt;p&gt;The other paths we looked at and didn't pick:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dynamic &lt;code&gt;ALTER TABLE&lt;/code&gt; per tenant field — ruled out fast, migrations-as-a-constant-event doesn't scale once tenants are inventing dozens of fields.&lt;/li&gt;
&lt;li&gt;Push it to Elasticsearch/Algolia and let it own filtering entirely — probably right at a much bigger scale, but didn't want a sync pipeline and eventual-consistency window before the feature even proved itself.&lt;/li&gt;
&lt;li&gt;JSONB with just a GIN index — fine for equality lookups, falls apart for numeric/date ranges on keys you don't know ahead of time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, genuine question for anyone who's solved this before: did you land somewhere different? Per-key expression indexes once a field gets used enough to justify one? CDC into something columnar? Or did pushing to a search engine turn out to be less painful than I'm assuming?&lt;/p&gt;

&lt;p&gt;Not trying to sell anything here — just comparing notes on a problem I suspect more people than us have hit.&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>architecture</category>
      <category>discuss</category>
      <category>database</category>
    </item>
    <item>
      <title>COD Isn't "Paid." It's a Receivable.</title>
      <dc:creator>StoreFlux</dc:creator>
      <pubDate>Wed, 28 Oct 2026 17:50:37 +0000</pubDate>
      <link>https://dev.to/storeflux/cod-isnt-paid-its-a-receivable-26pj</link>
      <guid>https://dev.to/storeflux/cod-isnt-paid-its-a-receivable-26pj</guid>
      <description>&lt;p&gt;Cash on Delivery looks simple from the outside: customer gets the package, customer pays the driver, order is "paid." Most systems model it exactly that way — a boolean on the order row flips from &lt;code&gt;false&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt; and everyone moves on.&lt;/p&gt;

&lt;p&gt;That's wrong, and it took a support ticket to notice why.&lt;/p&gt;

&lt;p&gt;The money the driver collected isn't actually ours yet. It's sitting with the carrier until they run their settlement cycle and transfer it over — which, depending on the carrier, can be days or weeks later. During that whole window, "paid: true" is a lie. The order is fulfilled, sure. The cash isn't.&lt;/p&gt;

&lt;p&gt;So we stopped treating it as a flag and started treating it as what it actually is: a receivable. An order moves from placed → COD pending (an open receivable on our books) → carrier payout → reconciled, and it's only "settled" once we've matched an actual payout from the carrier against that specific order's expected amount. If the carrier's payout comes in short, or an order's COD never gets matched to any payout, that's visible — not quietly absorbed into "paid: true."&lt;/p&gt;

&lt;p&gt;It's a small modeling change but it matters most for exactly the stores that rely on COD heavily, where this isn't an edge case, it's most of the order volume. A boolean can't tell you if a carrier is underpaying you on 3% of orders every month. A reconciled ledger can.&lt;/p&gt;

&lt;p&gt;Built this into StoreFlux (storeflux.store) — a backend-as-a-service for e-commerce. Curious how other people handle carrier-collected payments in their own systems — anyone doing something smarter than a straight ledger match?&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>fintech</category>
      <category>postgres</category>
      <category>ecommerce</category>
    </item>
  </channel>
</rss>
