Prescription lens selection that follows rules, not guesses
A 10-step prescription-lens walkthrough that makes an optometrist's choices from a readable ruleset, so every lens offered is one the rules allow and the cart charges for exactly what the shopper picked.
Deterministic rules engine · Prescription upload · Catalogue sync · Multi-platform commerce
- product
- Lens Journey
- platform
- VARAi
- role
- CTO & forward-deployed AI engineer
Results
- Lens-journey suites, Sep 2026 (recorded runs of 1,431 and 1,772)
- 1,500+ tests
- One live single-vision ruleset on a Magento optical retailer
- 10 steps · 140 options · 129 SKUs
- Distinct selection paths through that ruleset, before prescription values vary them
- 1,800+ paths
- Display-price lookup for 166 lens SKUs, moved to the master catalogue
- 10–15 s → ~1 ms
- Tenant-agnostic test generators any ruleset opts into with one line
- 6 rule packs
Problems solved
01Half-rim frames offered the wrong lens
- broke
- A thin 1.50-index lens that cannot go in a half-rim frame was still offered for one, on three lens paths.
- changed
- A generic rule now proves that each frame type removes the lens indices it cannot take, on every step that offers an index.
- proof
- Its first run found the three leaks in the live ruleset; rimless had been caught, half-rim had not.
02Prescription powers rounded on the order file
- broke
- SPH −2.25 was written as −2.3, so the lab would have made the wrong lens.
- changed
- Powers are written exactly, and any value that is not a quarter-dioptre step is refused instead of rounded.
- proof
- An existing test had encoded the wrong value; it now asserts the exact power.
03The summary and the cart disagreed
- broke
- The summary showed an upgraded prescription lens while the cart submitted the original stock SKU at the old total.
- changed
- Upgraded selections now carry the SKU the cart reads, totals are recomputed from the final selections, and Add to Cart locks when no matching SKU exists.
- proof
- Five regression tests cover the four cart-path bugs; 140 of 140 unit tests pass.
04A blank prescription could reach checkout
- broke
- The continue gate checked which tab was open, not the values, so a blank or failed upload could proceed.
- changed
- One flow: the manual form is always visible, an uploaded photo or PDF fills those fields in place, and the gate checks values only.
- proof
- The architecture record (ADR-274) lists the five field failures and the single flow that replaced them.
05Rulesets and the price route must agree
- broke
- A ruleset can offer a lens the store's price route would refuse, and nobody finds out until a shopper does.
- changed
- A guard checks every SKU a published ruleset can send against the price route's real rule.
- proof
- It runs before release, so a mismatch fails the build instead of the checkout.
06Prices took 10–15 seconds to appear
- broke
- 166 option prices were fetched in four serial pages, each falling back to about 13 serial store searches.
- changed
- Display prices now read from the master catalogue first, with the live store fetched in parallel only for currency conversion or a miss.
- proof
- Production query plan: all 166 SKUs in about 1.1 ms; the cart still sets the authoritative charge.
07Re-uploading a prescription duplicated the purchase
- broke
- Recovering from a failed photo attach added a second frame-and-lenses line instead of fixing the first.
- changed
- Recovery now repairs the original cart line in place and leaves the cart untouched if the retry also fails.
- proof
- Reproduced by hand as two cart items before the fix; one line after.
Where a wrong answer costs money or a patient's eyesight, the decision belongs in a rule you can read and a test that proves it, not in a model's guess.
stack · JavaScript · TypeScript · React · Node.js / Express · PostgreSQL · JSON rulesets · Jest · Playwright · Magento (PHP module) · Shopify · Gemini on Vertex AI (Rx reading only)
More from VARAi
- P-01AI Designer & Material StudioLive AI design chat · AI that acts, not just answers · 3D materials · Render automationChat → live 3DDesign mode changes materials, lighting and exposure in the scene; Apply or Reject each change in the chat
- P-02Virtual try-onBrowser AR · 3D rendering · Storefront integration · Production reliability38.3 s → 57 msOne documented gallery-query benchmark
- P-03AI search and recommendationsAI search · Recommendations · Redis caching · Magento integration~2 s → ~50 msRepeat queries served from the Redis cache, skipping AI routing and the store's API
- P-04Store analysis and catalogue syncCatalogue sync · Data mapping · Shopify · Magento · Human approval43 products · 1,605 variantsLive run on a heritage British eyewear store; 6 accessories excluded and named
Need a senior AI engineer who can own delivery?
Tell me what you're building and where it breaks. I reply to every message myself.
Contract CTO · Principal AI engineering · Forward-deployed AI engineering · Enterprise AI architecture