Skip to content

Add Restocking tab with budget-driven recommendations#37

Open
pauly-ant wants to merge 2 commits intobeck-source:mainfrom
pauly-ant:new_features
Open

Add Restocking tab with budget-driven recommendations#37
pauly-ant wants to merge 2 commits intobeck-source:mainfrom
pauly-ant:new_features

Conversation

@pauly-ant
Copy link
Copy Markdown

Summary

A new Restocking tab where users set a budget via slider and get demand-forecast-driven restock recommendations that fit within it. Placing an order surfaces it in the Orders tab with a computed delivery lead time.

How it works

Recommendation algorithm (server/main.py): greedy budget fill. Items are scored by trend_weight * 1000 + demand_growth (increasing=3, stable=2, decreasing=1), sorted descending, then added until budget is exhausted. Unit costs come from inventory.json where available, with a fallback table for demand SKUs that don't exist there (8 of 9).

Lead time: the slowest item sets the pace for the whole shipment. Increasing-trend items ship in 7 days, stable in 14, decreasing in 21, so a mixed order gets max() of its items' lead times.

UI flow: drag slider, recommendations table live-updates, click Place Order, success banner shows order number + lead time, switch to Orders tab, new "Submitted Restocking Orders" section appears above All Orders.

Files

  • server/main.py (+110): 3 Pydantic models, 3 endpoints, priority algorithm, lead-time map
  • client/src/views/Restocking.vue (new, 305 lines)
  • client/src/views/Orders.vue (+49): Submitted Orders section (conditional render)
  • client/src/api.js (+15): three new api methods
  • client/src/main.js: route registration
  • client/src/App.vue: nav link
  • client/src/locales/en.js, ja.js: nav.restocking key
  • tests/backend/test_restocking.py (new, 14 tests)

Tests

14/14 passed in test_restocking.py, 54/54 in full backend suite. Adversarial checks (zero/negative budget, invalid trend, idempotency, 5-way concurrent POSTs) all handled correctly.

- Backend: GET /api/restocking/recommendations (greedy budget fill by
  trend priority), POST /api/restocking/orders (lead time = slowest
  item), GET /api/restocking/orders
- Restocking.vue: budget slider, live recommendation table, totals,
  Place Order button with success banner
- Orders.vue: new Submitted Restocking Orders section (conditional)
  showing lead time and expected delivery
- 14 backend tests; full suite 54/54 passing
- ARCHITECTURE.md: system overview, tech stack, data flow, filter pipeline
- CLAUDE.md: note to document non-obvious logic changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant