Behind the Warehouse Curtain 🔧🚚
Description:
You are part of a logistics tech company building a Warehouse Management System (WMS)
to manage day-to-day inventory and storage operations across multiple warehouses. In a
warehouse, physical space is structured like a tree — starting from the warehouse itself and
branching down into zones, racks, shelves, bins, and so on. We call each of these a location,
and they form a nested hierarchy.
Warehouse (W-01)
├── Zone-A
│ ├── Rack-1
│ │ └── Bin-1
│ └── Rack-2
└── Zone-B
└── Bin-2
Your goal is to design a set of RESTful API endpoints to support operations like:
● Creating warehouse structure
● Storing products
● Transferring products between locations in warehouse
● Delivering products out
● Generating monthly storage bills
The system must be robust enough to:
● Handle nested warehouse locations
● Track inventory flow
● Enable warehouse billing based on product volume and duration of storage
Your Task
You need to design APIs. Each API must follow RESTful conventions, handle validations, and
return appropriate response structures.
Assumptions
1. In a real warehouse, there may be zones, racks, and bins. For this task, we simplify
this structure by assuming only 'storage' locations that can nest within each other to
any level.
2. Each product_code has a fixed volume per unit quantity, which remains constant
throughout its storage lifecycle.
3. All inventory operations and billing calculations are limited to the month of July
for simplicity and clarity.
API 1: Create Warehouse or Warehouse Location
Endpoint: POST /api/create_location
Description: Create a new location inside the warehouse hierarchy.
● If parent_location_code is null, it’s a root location and type must be warehouse
or else for child, type must be storage
● location_code must be unique across all warehouses (you can think location_code
as uniqueID it should never repeat)
● Location cannot be added if its parent_location_code doesn’t exist (eg in below
payload if warehouse W-01 is not added, then you cannot add W-01-BIN1)
Payload For Warehouse Creation:
{
"location_code": "W-01",
"parent_location_code": null,
}
Payload For Warehouse Location Creation:
{
"location_code": "W-01-BIN1",
"parent_location_code": "W-01"
}
Response:
{
"success": true,
"message": "Location created successfully",
"data": {
"location_code": "W-01-BIN1",
"parent_location_code": "W-01", // can be null for type:warehouse
"type": "storage" // or it can be warehouse
}
}
API 2: Get Warehouses in Tree Format
Endpoint: GET /api/warehouse/tree?warehouse_code=W-01
Title: View Warehouse Structure in Hierarchical Tree
Description: View Warehouse Structure in Hierarchical Tree, Fetch all locations as a tree
(warehouse → storage → storage etc.)
● Each location must contain childs.
● Build the tree by connecting each location to its parent based on their relationship.
Response:
{
"location_code": "W-01",
"type": "warehouse",
"childs": [
{
"location_code": "W-01-BIN1",
"type": "storage",
"childs": []
},
{
"location_code": "W-01-BIN2",
"type": "storage",
"childs": []
}
]
}
API 3: Add Products to Warehouse
Endpoint: POST /api/transaction/receipt
Description: Accepts a batch of products to be stored at a specific location.
● Each location_code must belong to warehouse_code (i.e) that location_code
must be located in the given warehouse only, if it belongs to another warehouse then
through error.
● Store transaction_date for future billing.
● One Location may contain multiple products (Eg, We can store P001, P002 at same
location i.e, W-01-BIN1)
Request:
{
"transaction_date": “2025-07-10”,
"warehouse_code": "W-01",
"products": [
{
"product_code": "P001",
"qty": 100,
"volume": 2.5,
"location_code": "W-01-BIN1",
},
{
"product_code": "P002",
"qty": 50,
"volume": 1.2,
"location_code": "W-01-BIN2",
}
]
}
Response:
{
"success": true,
"message": "Products added successfully"
}
{
"success": false,
"message": "Location Doesn’t belong to a specific warehouse"
}
API 4: Deliver Product Out of Warehouse
Endpoint: POST /api/transaction/delivery
Description: Product is dispatched from a specific location. It will no longer be billed.
● Validate location_code has enough stock available
● Mark the product record as delivered for billing purposes
Request:
{
"transaction_date": “2025-07-20”,
"warehouse_code": "W-01",
"products": [
{
"product_code": "P001",
"qty": 100,
"location_code": "W-01-BIN1",
},
{
"product_code": "P002",
"qty": 50,
"location_code": "W-01-BIN2",
}
]
}
Response:
{
"success": true,
"message": "Product delivered successfully"
}
{
"success": false,
"message": "Insufficient Qty at given Location"
}
API 5: Transfer Products Between Locations
Endpoint: POST /api/transaction/transfer
Description: Move product quantity from one location to another. Volume is auto-derived.
● Validate from_location_code has enough stock.
● Validate from_location_code and to_location_code belongs to same
warehouse as we can’t transfer products between different warehouses
Request:
{
"transaction_date": “2025-07-22”,
"products": [
{
"product_code": "P001",
“from_location_code”: “W-01-BIN1”,
"to_location_code": "W-01-BIN2",
"qty": 100,
},
{
"product_code": "P002",
“from_location_code”: “W-01-BIN3”,
"to_location_code": "W-01-BIN4",
"qty": 40,
},
]
}
Response:
{
"success": true,
"message": "Transfer completed successfully",
}
{
"success": false,
"message": "Insufficient Qty at given Location",
}
{
"success": false,
"message": "from_location_code and to_location_code belongs to
different warehouse",
}
Bonus API (Not Compulsory, Good If Implemented)
API 6: Generate Monthly Billing
Endpoint: GET /api/billing?warehouse_code=W-01&rates=10
Description: Calculates billing based on how long a product stayed and how much volume it
consumed.
● Calculate days_stored = transaction_date(delivery) -
transaction_date(receipt) + 1 (or 31 if not delivered for month of july)
● Sum Volume × Days × Rate.
● Show product-wise billing breakdown
● Example as it is quite complex to understand
○ Suppose Product P0001 Enters Warehouse at transaction_date - 1st (start of the
month), 100 Qty and Volume 50 CBM
○ Delivery of that Product P0001 at transaction_date - 10th, 50 Qty
○ Billing Rate: ₹10 per CBM per day
○ 1 to 10 there are total 10 days and volume Stored per day is 50CBM so
total amount for 10 days is 10 days * 50 CBM * 10 Rate = 5000₹ for 10
Days
○ 11 to 31 there are total 21 days and volume Stored is 25CBM as 50 Qty is
already Delivered and 50 Qty only left and volume for that is 25 CMB, So
total coast is 21 days * 25 CBM * 10 Rate = 5250₹ for 21 Days
○ Total Billing For This Month is 10250₹
Response:
{
"total_amount": 10250,
"details": [
{
"product_code": "P001",
"amount": 10250
}
]
}