Inspiration
For a small e-commerce brand, every purchase order is a bet. Order too much and your cash is locked in inventory for months; order too little and you stock out right when demand peaks. Tariff announcements, supplier delays, and prepayment demands keep changing the odds — yet most brands still make these calls in a spreadsheet, with operations and finance working from separate numbers.
Large enterprises have planning suites like Kinaxis or SAP IBP. Brands doing a few million dollars a year have Excel and gut feel. We wanted to give them something better: know the odds before you order.
What it does
Lading is a purchase-decision copilot for small and mid-sized brands that source from overseas factories.
- Compare order options side by side. Enter 2–3 candidate order quantities and Lading simulates each one, showing cash runway (P10 / P50 / P90), stockout probability, expected profit, and worst-case loss, plus a fan chart of cash over time against your safety line.
- Turn headlines into model inputs. Paste a tariff announcement or supplier news. An LLM extracts structured parameter changes (affected HTS code or supplier, new rate, likelihood) with the exact quoted sentence as evidence. Nothing enters the model until you approve it.
- Explain the recommendation. Lading recommends an option and explains the trade-off in plain language, including a counterfactual: "If you order 8,000 units and the tariff increase happens, your cash runs below the safety line in 1 of 4 scenarios."
How we built it
Lading has two layers with a strict rule: numbers come only from the deterministic engine; the LLM only handles language.
Simulation engine (Python + NumPy). A daily Monte Carlo simulation over a 120-day horizon with 1,000 paths and a fixed random seed. For each path:
$$S_t = \min(D_t,\ I_{t-1}), \qquad I_t = I_{t-1} - S_t + Q \cdot \mathbb{1}[t = L]$$
$$C_t = C_{t-1} + (P - m)\,S_t - F - \text{Pay}_t$$
where $S_t$ is units sold, $I_t$ inventory, $C_t$ cash, $Q$ the order quantity, $L$ the lead time, $P$ the price, $m$ per-unit platform and fulfillment fees, $F$ daily fixed costs, and $\text{Pay}_t$ the prepayment, balance, tariff, and freight payments due that day.
Uncertainty comes from four sources:
- Daily demand $D_t$, bootstrapped from the M5 (Walmart) sales dataset and scaled to the brand
- Lead time $L$, drawn from a lognormal distribution per supplier
- Tariff rate $\tau$, which jumps to a new rate with probability $p$, based on USITC HTS rates and extracted signals
- Supplier default with probability $r$, which forfeits the prepayment
The recommendation is rule-based:
$$Q^* = \arg\max_{Q}\ \mathbb{E}[\Pi(Q)] \quad \text{s.t.} \quad \text{Runway}_{P10}(Q) \ge \text{safety line}$$
LLM layer (Claude API). Extracts structured signals from text, writes explanations from the engine's output, and drives the UI narrative.
Stack. FastAPI backend, React + Recharts frontend.
Challenges we ran into
- Keeping the LLM away from the math. Early versions produced explanations with numbers that didn't match the simulation. We now check every number in an explanation against the engine's output and suppress any explanation that doesn't match.
- Extracting signals without inventing them. News rarely states a clean parameter. We required a verbatim quote for every extracted change, and the model must answer "no quantifiable impact" instead of guessing.
- Making uncertainty readable. A single "expected profit" number hides the real risk. Getting fan charts and percentile cards to be understood in seconds took several iterations.
- Realistic data without real customers. We built a synthetic brand with suppliers and cash positions, and grounded its demand in real retail sales patterns from M5.
Accomplishments that we're proud of
- A full loop from a news headline to an updated, explained purchase recommendation
- Fully reproducible results: the same inputs always produce the same numbers
- Explanations that someone without a finance background can follow
What we learned
- Operations and finance decisions in a supply chain are the same decision. A prepayment to a factory is effectively an unsecured loan to that supplier.
- LLMs are most valuable as translators between the messy outside world and a structured model, not as calculators.
- Showing distributions instead of point estimates changes the decisions people make.
What's next for Lading
- Pilot with real brands through CSV import of inventory, orders, and supplier terms
- Integrations with ERP and e-commerce platforms (Shopify, Amazon Seller Central)
- Event replay and alerts when a tariff change or supplier delay hits in-transit orders
- A supplier negotiation simulator to test prepayment, MOQ, and price trade-offs before talking to the factory
- Multi-SKU portfolio optimization under a shared cash constraint
Built With
- agent
- fastapi
- human-in-the-loop
- leaflet.js
- postgresql
- python
- react.js