Skip to content
All work

A US pool-equipment retailer

Order routing for suppliers that each take orders a different way

I worked on the system that picks a supplier for each online order, usually the cheapest one able to fill it, and keeps stock in sync across the retailer's suppliers and its own warehouse.

Industry
Online retail
My role
Full-stack engineer: architecture, routing, integrations and operator tools
Years
2025 to 2026
Status
Live, and I still work on it Checked 15 Nov 2026
scheduled jobs keeping orders and stock in sync
17
supplier connection types built
5

The problem

The retailer sells pool equipment online. Its stock comes from several wholesale suppliers and its own warehouse.

The suppliers share no catalog, no stock feed format and no common way to take an order.

There was no single place that said which supplier had a part in stock or which one was cheapest. If an order never reached a supplier, nothing flagged it.

Supplier data also changes all the time. Part numbers get reissued, items go out of stock and come back, and sometimes one part number is attached to two different products.

A fixed mapping between a store product and a supplier product goes stale within days. A wrong link means ordering the wrong part.

What I worked on

I worked on the operations system the business runs on. Every order placed on the Shopify store comes into it.

It checks stock and cost at all four sources, and usually sends the order to the cheapest one that can fill all of it. When no single supplier can, it splits the order. Tracking comes back from the supplier and goes out to the customer.

The suppliers work in different ways. One has a JSON API. Another took orders over an older SOAP service, and later that supplier moved to a REST API.

The newest publishes prices over an XML API and drops a full stock file on an FTP server four times a day. It only accepts orders as a CSV sent by email.

Its order confirmations arrive later as reply emails, and the system is built to read them and match each one to its order. That supplier now takes orders too, from price sync through email ordering.

The main design rule: every supplier’s data is saved first, as the supplier sent it. A separate step then works out which store product it belongs to.

That keeps each supplier’s quirks in one place, and every link can be checked again later.

Right before it picks suppliers for a batch of orders, the system refreshes stock for just those products, so the choice is made on fresh numbers.

How it works

  • Routing usually picks the cheapest supplier that can fill the whole order, or splits the order across suppliers when none can.
  • The retailer’s own warehouse competes for orders too. It wins ties, and it gets orders from its own region when it can fill them.
  • Supplier connections: a JSON API, SOAP and later REST for one supplier, XML, FTP files and email in both directions.
  • Stock sync adds up supplier stock into the quantity the store shows, and keeps a history of stock changes.
  • New supplier products link to store products automatically, with guards that stop reissued part numbers flipping the link back and forth.
  • 17 scheduled jobs share one wrapper: a database lock so the same job never runs twice at once, an on/off switch, and a manual run button.
  • A warehouse module covers bins, stock, purchase orders, fulfillment and returns for the in-house warehouse.
  • An order timeline shows everything that happened to one order, step by step.
  • An order that fails to send a set number of times raises one alert, never a repeat.
  • Store tools handle product publishing, cost and price sync, bundles, and AI-written image alt text.

What didn’t work

At first, saving first was just how most imports worked. It became a hard rule after a real failure.

One import path skipped the save and used the supplier’s live response directly. An order was later sent to that supplier based on a stock number that was never saved anywhere.

The order failed with no log and no alert. I rewrote that path to save first and applied the rule to every import.

Where it is now

It runs the retailer’s order flow today, and I am still extending it.

It was built in stages: order fulfillment and stock sync first, then the job scheduler and catalog tools, then a second supplier and split orders, then the in-house warehouse and store automation.

Each new supplier goes through the same steps: save its data first, link it, and only then let it compete for orders.

Under the hood

  • A slow join, fixed from the query plan. Linking the newest supplier’s catalog used a join on either of two keys. The query plan showed it would build about 101 million rows, so I replaced it with two plain joins combined, which can use indexes.
  • A character set mismatch. I also found that a mismatch between MySQL character sets (utf8mb3 and utf8mb4) on the joined columns blocked every index, and wrote it down.
  • A large sync inside a time limit. A full price sync for that supplier covers about 110,000 rows and takes about 6 minutes, inside App Engine’s 10 minute request limit. It runs in segments with several batches at once, on its own database pool, and every write is an upsert, so a rerun never doubles anything. The FTP stock feed retries with backoff.
  • Alerts that fire once. Before the stuck-order alert is sent, the job claims it in one atomic update (UPDATE ... WHERE notified IS NULL). Two runs at once can’t both send it.
  • Races and ambiguity. Parallel bundle webhooks write through one upsert, so they can’t create duplicates. When a lookup matches more than one product, the API returns the candidates instead of quietly taking the first.
  • Tests that stay repeatable. The stock refresh sits at the start of the job, not inside the routing logic, so the routing tests run on fixed data. Credentials are also stripped from every HTTP error where it is raised.

What I’d tell a founder in the same spot

If you ship from several suppliers, plan for most of the work to sit on the supplier side, because each one sends data differently and changes it without warning.

Keep a raw copy of what every supplier sends before you act on it, so when an order goes wrong you can see exactly what the system knew at the time.

And set up one alert per failed order from the first week, so nothing sits unnoticed.

How it fits together

  1. 1. Code A store order comes in from Shopify
  2. 2. Code Stock is refreshed for just the products in the batch
  3. 3. Code The cheapest source that can fill the order is picked, or it splits
  4. 4. Code The order goes out by API or as a CSV by email
  5. 5. Code Confirmations and tracking are read back and sent to the customer
  6. 6. A person A person checks any order that raised a stuck-order alert
How one store order gets to a supplier and back, with a person stepping in only when an order gets stuck.

Built with

  • TypeScript
  • React
  • Node.js (Express)
  • MySQL
  • Google App Engine
  • Shopify Admin API
  • SOAP, REST, FTP and IMAP
  • GitHub Actions

Have someone technical who should look at this first? Send this to your technical person, or point them to the five-minute version for technical readers.

Next case study AI video engine, from persona to finished video A short-form video content business

Contact

Something like this in your business?

Book 15 minutes and tell me what your team does by hand. I'll tell you what I'd build first, and what I'd skip.

Scaylar's services are on scaylar.com.