Implement a real-time inventory management system that handles multiple types of transactions while maintaining inventory consistency across multiple warehouse locations.
- Clone this repository
- Run
npm install
- Implement the required functionality in
src/inventoryManager.js
- Run tests with
npm test
- ADD: Add inventory to a location
- REMOVE: Remove inventory from a location
- TRANSFER: Move inventory between locations
- RESERVE: Temporarily hold inventory (15-minute expiration)
- COMMIT: Convert a reservation to a removal
- CANCEL: Cancel a reservation
- Process transactions in FIFO order
- Maintain inventory consistency
- Handle reservation expiration
- Support multiple warehouses
- Prevent negative inventory
- Track transaction history
{
transactionId: string,
type: "ADD" | "REMOVE" | "TRANSFER" | "RESERVE" | "COMMIT" | "CANCEL",
productId: string,
quantity: number,
locationId: string,
targetLocationId?: string,
reservationId?: string
}
- Correctness of implementation
- Transaction consistency
- Error handling
- Edge case management
- Code organization
Good luck!