AlgoViz

Design an inventory management system

medium 80 min

Count goods in several places, promise them to orders without ever promising too much, ship or let go, and explain every count.

Watch lesson4:28

Requirements

What it does, and what it does not

The point: each requirement should name a method or a rule. If it names neither, it belongs to another system.

Functional

What it must do

RequirementBecomes
Goods arrive at a place, with a reasonreceive(sku, place, qty, ref)
Show how many may still be soldavailable(sku)
Promise several products, all or nonereserve(order, wanted, seconds)
Send a promised order onceship(id)
Cancel a promiserelease(id)
A promise ends by itselfexpires_at and expire_due()
Choose the place by a rule that can changePickPolicy
Say once when a line becomes lowLowStock
Explain every countMovement, append only

Rules

What must always be true

  1. 1

    0 ≤ held ≤ on hand

    For every line, after every call, also after one that failed.

  2. 2

    The sum of movements is on hand

    For every line. The ledger is the proof.

  3. 3

    Held is the sum of open promises

    For every line, the picks of all HELD reservations add up to held.

  4. 4

    One ending

    A promise leaves HELD once.

These four sentences are worth more than a diagram. They decide what a method must check, and later they become the tests.

Not functional

Speed, threads, numbers

  • Threads

    Many at once. No order may see half of another.

  • Size

    Assume 10,000 products in 5 places: 50,000 lines. They fit in memory easily.

  • Rate

    Assume 50 orders a second at peak. At 20 microseconds under the lock it is busy for 1 ms in each second.

Ask

Questions, and what each answer decides

They sayYou write
"One place only"No policy. The key is the product
"Take what is there"reserve returns what was held and what is missing
"Jam has a date"Batches inside the line
"Each item has a serial number"A set of pieces, as in the parking lot
"We may promise what arrives on Monday"Incoming as a third count, with a date
"It must survive a restart"The ledger and open promises are stored; counts are rebuilt

In scope

  • Counts by product and place
  • Reservations with an end
  • Place choice
  • Alerts and ledger

Out of scope, said aloud

  • Prices and payment
  • Suppliers and buying
  • Packing and labels
  • User accounts
  • Several machines