Commit 20f527a6 by Murlidhar Fichadia

initial commit

parents
# Inventory & Order Processing System
Build a backend API for a simple inventory and order processing system.
## Scenario
In this system, we are building an e-commerce platform that supports concurrent order processing and real-time inventory management. Customers can place orders for multiple products at once. Stock must be managed accurately — even when multiple customers attempt to order the same low-stock item simultaneously. Orders can also be cancelled, which must restore stock reliably.
## Requirements
### Data Model
Design and migrate the following (add columns as you see fit, but these are the minimum):
- **products**`id`, `name`, `sku`, `price`, `stock_quantity`, `timestamps`
- **orders**`id`, `user_id`, `status` (`pending`/`confirmed`/`cancelled`), `total_amount`, `timestamps`
- **order_items**`id`, `order_id`, `product_id`, `quantity`, `unit_price`, `timestamps`
### Features to Build
#### 1. Place an Order
- Accept a list of products and quantities via a `POST` endpoint.
- Validate that each product exists and has sufficient stock.
- Stock levels must be accurate at all times — if an order cannot be fulfilled in full, nothing should be reserved.
- Stock figures must never go negative — regardless of how many requests arrive simultaneously.
- Return the created order with its items and the calculated total.
#### 2. Cancel an Order
- Only `pending` or `confirmed` orders may be cancelled.
- Cancelling must restore stock for all items in the order.
#### 3. List Orders
- Return a paginated list of orders for a given user, including the items in each order and the associated product details.
- The endpoint will be called frequently and must stay fast as order history grows.
#### 4. Low Stock Report
- A single endpoint that returns all products where `stock_quantity` is below a configurable threshold (default: `5`).
### Things to note:
- New order statuses may be introduced in the future (e.g. `processing`, `dispatched`, `refunded`) — consider how easily your design accommodates that.
- A customer's order history can grow significantly over time — the orders listing endpoint should stay fast whether a customer has 10 orders or 10,000.
- Multiple customers can attempt to purchase the same product at exactly the same time — your implementation should handle this gracefully.
- The low stock threshold should be adjustable without touching or redeploying the codebase.
- Each endpoint should respond with consistent, predictable JSON — think about how a frontend or mobile client would consume your API.
- Please provide a README describing how to set up and run the application locally, how to run the test suite, and a brief explanation of the key decisions you made and why.
- Laravel 9+ and PHP 8+ must be used.
## Bonus:
- Add unit/integration tests (Use PhpUnit or Pest testing suite for testing).
Please make sure this project is completed at least one working day before your interview.
The completed project should be submitted by pushing the code to GitHub and a link emailed to HR.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment