Niro3D sells 3D prints. You can configure a product, like a keychain with your name on it, and see the price change as you go.
That price has to be the one you pay at checkout. And I didn't want a server call every time someone changes a setting.
One package, two places
The pricing rules are a shared package. It runs in the browser for the live price and on the server to validate the order. To make that work it is pure TypeScript with no DOM and no Node globals, so it can run in either place unchanged.
The customer app, the admin and the scripts all use the same package in one monorepo, so a change that doesn't fit gets caught at compile time.
The rules add up
A price is built from rules that combine: a cost per character, size tiers, optional add-ons, dropdown surcharges, a fee for processing an uploaded image and a multiplier per material. Then minimum charges and volume discounts.
There were more edge cases than I expected, which is why it's a rule engine and not a formula.
What it doesn't cover
Uploaded models are different. Their price depends on the geometry, so a slicing service in Go works out the weight, print time and cost, and the result comes back when it's ready. Only configured products are priced by the shared package.
Quoting and ordering run on their own. A person still prints and ships.
