As reported: Coupang L5 Senior Software Engineer loop, Bangalore (2025), round 3 (LLD/HLD): create a UML diagram, or list the entities and the APIs, for a book shop.
Design a book shop:
Functional requirements
- Search books by title and by author. The search should be extensible to other items the shop sells, such as paper bags, copies and stationery.
- Customers can search their own purchases.
- Track inventory and items.
- Handle payments.
Non-functional requirements
- Availability.
- Strongly consistent stock inventory.
Give the entities (or a UML diagram) and the APIs; agree on any further scope first.
Code runner format: two lines in LeetCode's design format: the method names and their arguments. The harness prints the list of return values (null for the constructor, addBook, addStationery and restock). Implement BookShop with this practice scope:
addBook(id, title, priceCents, authors),addStationery(id, title, priceCents, brand)— item ids are unique.restock(itemId, qty)(only for catalogue items) andavailable(itemId)— on hand minus reserved,0for an item never stocked.search(field, query)— field"title","author"(a book's authors joined by spaces) or"brand"(stationery). Text and query are split into lower-case words on spaces; an item matches when its field contains every query word. Returns the matching ids sorted; an unknown field matches nothing.placeOrder(customerId, itemIds, quantities)— distinct item ids, quantities ≥ 1. Reserves every line or none: if any line has fewer available units than asked (or was never stocked), returns""and changes nothing. Otherwise returns the next order id ("O1","O2", …), statusRESERVED.total(orderId)— the order's total in cents,-1for an unknown order.pay(orderId, paymentToken)— the token"bad-card"is declined (statusCANCELLED, the reservation is released); any other token pays (statusPAID, stock leaves the shop). Paying an order that is no longerRESERVEDchanges nothing. Returns the status,""for an unknown order.searchPurchases(customerId, word)— ids of the customer'sPAIDorders, oldest first, that contain an item whose title, author or brand containsword(case-insensitive substring).
Python uses snake_case (add_book, place_order, …); Go uses Constructor() and exported names (AddBook, PlaceOrder, …).