πŸ‘¨β€πŸ’Ό Welcome to the Inventory Manager! This is a practical React app that uses TypeScript classes for the core business logic. You'll implement the classes in a utilities module to power the UI.

Getting Started

🐨 Open
src/classes.ts
and implement the classes, interfaces, and methods. Every 🐨 comment is something for you to fill in.
🐨 Open
src/app.tsx
and look for TODO callouts in the UI. As you implement the class logic, those TODOs will turn into real data.

Running the App

npm run dev

What to Implement

In src/classes.ts

  1. Inventory base class with private fields
  2. Interfaces for Sellable and Trackable behaviors
  3. Inheritance for Electronics, Clothing, and Perishable items
  4. Method overriding for descriptions and pricing
  5. Composition with logger implementations and InventoryManager

In src/app.tsx

  1. Replace the placeholder item objects with real class instances
  2. Wire InventoryManager + loggers so the Inventory Actions panel shows live data

Concrete examples (suggested fixtures)

Use these field values (constructor shape is up to you) so the UI has something concrete to show:

Electronics β€” Laptop

Fields: name: 'Laptop', basePrice: 1000, brand: 'Nova', model: 'X15', serialNumber: 'SN-100', location: 'Aisle 3', discountPercent: 10
Observable results:
  • getDescription() includes the name, brand, and model
  • calculatePrice(2) β†’ 1800 with those price/discount values
  • getTrackingInfo() includes serial and location details
  • updateLocation('Warehouse') is reflected in later tracking info

Clothing β€” Hoodie

Fields: name: 'Hoodie', basePrice: 40, size: 'M', color: 'Navy', discountPercent: 0
  • getDescription() includes the name, size, and color
  • calculatePrice(1) β†’ 40 when discount is 0

Perishable β€” Apples

Fields: name: 'Apples', basePrice: 3, expirationDate: '2026-08-01'
  • getDescription() includes the name and expiration date

Logging + InventoryManager

Logger.log(message: string): string returns the same message it received (no required prefix). ConsoleLogger also prints that message. InMemoryLogger stores that same message for getLogs().
const manager = new InventoryManager(new ConsoleLogger())
manager.receiveStock('Laptop', 5)
// log output mentions receiving Laptop / 5

const memoryLogger = new InMemoryLogger()
new InventoryManager(memoryLogger).shipStock('Hoodie', 2)
memoryLogger.getLogs().length // >= 1

Tips

πŸ’° Start with the base InventoryItem class. Many other classes depend on it.
πŸ’° For sellable pricing, combine basePrice, order quantity, and discountPercent so the Laptop example above yields 1800 for quantity 2.
πŸ’° Use the logger classes to see the effects of dependency injection.

No Tests, No Solutions

πŸ“ This is practice time! There are no tests or solutions. Experiment, make mistakes, and build confidence by applying what you've learned.

Please set the playground first

Loading "Inventory Manager"
Login to get access to the exclusive discord channel.
Loading Discord Posts