The copy that heals itself

A marketplace that sells a brand's products keeps a copy of the brand's store. The same codebase keeps that copy two different ways, and the slower one is the one that is right by morning.

4 min readGlitz · Catalogue stage

A creator marketplace lives on products it does not own. A brand connects its store, the products appear, creators share links to them, and buyers check out. No brand will keep a second product list by hand, so the platform keeps a copy of the catalogue and has to keep that copy honest when the brand changes a price, renames a product or stops selling it.

There are two ways to keep a copy in step with a source you do not control. The source tells you when something changes, or you go and look. This codebase does both, for different stores, and the comparison teaches more than either one alone.

Push: the Shopify connector

Shopify was the first storefront, and it uses webhooks. Connecting a store registers nine topics: products created, updated and deleted, inventory levels, orders, fulfilments, refunds, and the app being uninstalled. Every delivery is signed. The handler recomputes the signature over the raw request body, not the parsed JSON, and compares the two in constant time after checking their lengths match. That check is there because a short signature makes the comparison throw, and a crash reads as a broken app to the store's review probes. Every delivery also carries an id. The id is recorded, and a delivery seen before is acknowledged and ignored. A price change in the store reaches the marketplace in seconds.

The cost is what happens when a delivery never arrives, or arrives and fails. The handler answers 200 either way, on purpose, so the store does not retry forever, and it writes an alert for a person to read. A nightly job visits every connected store. It re-registers any webhook that has gone missing and compares two numbers: active products in the store and visible products on the marketplace. If they differ by more than five percent it raises an alert. It re-fetches nothing. Its own header comment says it re-syncs products that have drifted, and the code beneath the comment does not. A lost price update stays lost until the brand edits that product again or asks for a re-sync. A lost delete is noticed only if enough of them pile up to move the count.

Pull: the five that came after

WooCommerce, Wix, BigCommerce, Magento and Squarespace were added between 17 September and 3 October 2026, and none of them uses webhooks. Every six hours a scheduled job re-imports each connected store from the top. Anything the store no longer lists is hidden on the marketplace side, but only if the run finished without a single failed page. A flaky response halfway through a catalogue therefore cannot archive the half that was never read. The decision is written at the top of each connector: poll every six hours, add webhooks when a store needs faster inventory than that.

That copy can be six hours stale. It is also never wrong for longer than six hours, whatever went missing, because there is nothing to go missing. No delivery can be dropped. The job just looks again.

Why a stale copy is allowed

Either strategy would be dangerous if the copy decided what anyone pays. It does not. A buyer who taps a creator's link lands in the brand's own cart, with the variant and quantity in the address, so the store charges its own current price. The commission is worked out from the line items on the order the store reports back, not from the price the marketplace has on file. A product the marketplace has hidden pays no commission even if an order for it arrives anyway. The copy decides what a creator sees and what a buyer is shown on the way in. The store decides the money. That split is what turns six hours of staleness, or a missed webhook, into an out-of-date picture rather than a wrong charge.

What it costs

The Shopify copy is the freshest of the six and the only one that cannot heal. The fix is not exotic. Give its nightly job the same full re-import and the same clean-run rule the other five already have, and keep the webhooks for speed: push for latency, pull for correctness. Until that lands, the comment and the code disagree, and the comment is the one a reader believes.

The second cost is structural. The shared pieces live in the Shopify folder: encrypting store keys, the import lock, the rule that a brand's own archive outranks the store's. Every newer connector imports them from there. It works, and it is a seam by folder rather than by interface. As of 7 November 2026 that directory holds 4,222 lines and 13 of the platform's 111 functions, under one vendor's name, with five other vendors depending on it.

Why it belongs on this page

The anatomy row for this stage said import, sync and reconcile, and that the brand does nothing after connecting. Both were less true than they sounded. The reconcile counts, and the Shopify import runs when the brand asks for it. The five connectors that took the safer road were written months after the first, by the same person who wrote the first one and the checkout that makes a stale copy harmless. Seeing the gap took one read of the six folders side by side. That read is only cheap when one person owns all of them.

More notes
  • The webhook that credits twiceA payment processor delivers every result at least once. The interesting engineering is in what happens when your side fails halfway through.
  • A ledger you can edit from a route handler is not a ledgerWhy every movement of value on the payments platform goes through a Postgres function, and what it costs to keep it that way.
  • Four rows that were not theirsHardening multi-tenant row-level security in four reversible phases, verified by impersonating a member and counting what they could see.
  • The bug inside the fixA payout race, the fix for it, the bug inside that fix, and why it is the best argument I have for one person owning the whole path.
  • The sale that arrives with no referrerA creator shares a link on Instagram, the buyer taps it, installs the app and purchases. Nothing in that chain carries the creator's name across. Here is what does.
  • The minimum that belongs to someone elseHeld commissions are released to creators once a brand's payout minimum is met. Group the money by creator, the obvious way, and one brand's minimum ends up holding another brand's money.
  • The commission that must not mint twiceA buyer pays and the platform owes a creator a commission. Between those two facts sit a colluding pair, a call that arrives twice, and a cart with three items on one payment.
  • The rule that has to be written twiceFirestore security rules do not cascade to subcollections. Forget that in one place and a single query returns every private message on the platform.
  • Thirty days in the ledgerSplitting a payment at charge time is simpler and wrong: a refund after the creator is paid is a clawback nobody enjoys. Holding the money creates a different set of problems, and each piece of machinery around the hold answers one of them.
  • Arbitrary but consistentA gym's assessment answers become rules that swap an exercise for a member before a session. Two rules can disagree about the same movement. The code says who wins, and the comment admits how.
  • The number that ducked every thresholdA deposit arrives from a browser carrying two numbers. The platform scored one of them and charged the other, and every limit it had was measuring the wrong figure.
  • The second one tells you the shapeHigh-risk merchants get dropped by processors, so the platform cannot be welded to one. The interface that makes a processor swappable could not be designed before the second one existed.
  • A key you did not makeA device fingerprint is a hash the browser computes and the server has to take on faith. The useful question is not whether to trust it, but what a server does once it accepts that it cannot.
  • The template never learns your nameA trainer builds a workout once and runs it for a room of people who are not the same. The data model that survived is three tables with a one-way street between them, and the model it replaced was the obvious one.
  • The ledger was rightA team sale splits one commission between two people. The split was recorded correctly everywhere a person could look, and the code that sent the money would have paid the wrong one.
  • Zero was not a ceilingA creator can write their own commission rate, so the server caps it at what the brand agreed to. For most of the catalogue the cap never ran, because those products carried no commission of their own.
  • Smaller than it wasOn 27 September the gym's movement library lost 4,724 lines and gained one field. What came out was a theory of how movements relate. What replaced it was a trainer writing the relation down.
  • The toast that could not fireA trainer taps Mark All and the whole room's round is recorded. From October 2025, if every one of those saves failed, the app said nothing, because a failed save and a deliberate skip had become the same value.
  • The ceiling is a thousand rowsA comment beside the member totals names their ceiling: tens of thousands of sets, and then it gets slow. The query under it has no range, and the API it calls stops at a thousand rows without saying so.
  • Spent, but not on anythingEvery deposit required a texted code, and each code could be spent once. Nothing recorded which deposit spent it, so the dispute packet that cited those codes was counting texts, not approvals. Now each spent code carries the checkout it approved.
  • No exceptions notedThe platform could generate a certificate of its own controls for underwriters, and every result in it was the same fixed string. Re-reading it for this page found that. It now counts what the guard actually decided.