Design, develop, and test software systems using the MIM (Module - Infrastructure - Module) architecture and foundational modular design principles.
100
Quality
100%
Does it follow best practices?
Impact
100%
1.25xAverage score across 5 eval scenarios
We have a modular e-commerce system with two main features: Orders and Inventory. When a customer places an order, the Orders system needs to verify if the requested items are available in stock before finalizing the transaction.
The Inventory module is complex and its internal database schema and data management methods change frequently. We want to ensure that the Orders module is as loosely coupled as possible to the Inventory module. Specifically, we must avoid a "leaky" design where the Orders team has to understand the internal data structure or implementation details of the Inventory team.
Your task is to implement the stock-check step in the Orders module. This interaction should be stable, encapsulated, and should not create a fragile dependency on the internal workings of the other module.
The following file is provided for reference:
=============== FILE: src/Inventory/InventoryService.ts =============== export class InventoryService { constructor(private repo: any) {}
async checkStock(itemId: string, quantity: number): Promise<boolean> { const item = await this.repo.findItem(itemId); return item && item.quantity >= quantity; } }
Orders module.Orders module interacts with the Inventory module.Orders module should NOT have any direct access to the Inventory module's internal repository or data models.