Pallethaven: inventory and purchase orders for a small retailer

Pallethaven: inventory and purchase orders for a small retailer

00 Markdown

Stock levels with low-stock flags and movement history, purchase orders emailed to suppliers and received line by line, all live.

Run it yourself

Get the finished app on your own machine, ready to change however you like.

VS Code Command Palette⇧⌘P
pallethaven -scaffold=elementscode/demo-pallethaven

Press 'Enter' to confirm your input or 'Escape' to cancel

Press ⇧⌘P in VS Code and choose Elements: New App. Then paste this line and press Enter.

New to Elements? Install Elements first.

The code

How it's built

Pallethaven needed stock counts that change as people work, a history behind every number, purchase orders sent to suppliers by email, receiving line by line and a morning list of what to reorder. Each of those is a part of Elements, so the agent spent its 19 minutes on the shop itself.

What Elements gave the app

  • Live stock and orders. Products, stock movements, purchase orders and their lines are LiveTables. When a delivery is received, the stock list, the product's history and the order's status update on every open screen.
  • A history behind every number. Every change to a count goes through one function that adjusts the stock and records why: a count, damage, a sale or a receipt against a purchase order.
  • Purchase orders by email. Sending an order marks it sent and queues a job in the same transaction, so the supplier's email goes out once the order is saved as sent. Staff then receive it line by line, and the order moves to partly or fully received.
  • A morning digest. A one-line cron schedule runs a job at 7am that emails each manager the products at or under their reorder point.
  • Server calls as function calls. Creating orders, adding lines, receiving stock and editing products call server functions straight from the page with @rpc.
  • Data and roles from SQL. Migrations define the shop and seed two logins, three suppliers, forty products and four orders, one in each status. Sessions and roles let staff count and receive stock and give managers the orders and product edits.

What the project server gave the agent

The project server runs alongside the agent and answers as soon as a file is saved: it type-checks the templates, TypeScript and SQL, applies migrations and reruns the tests, so every question came back right away and the agent kept building.

What shipped

The app type-checks with zero errors and all 33 tests pass. Every page works on desktop and phone.

Comments· 0

Join the community

Get a weekly digest of new posts.

Sign up