Contracts & events
Shared interfaces are the boundaries between modules. Build against the contract, not another group’s implementation.
Frozen contracts
Frozen from day 3. A change needs an issue labelled contract-change, approval from every group whose module uses it, and the instructor's merge.
Integration styles
| Style | When to use | Example | Location |
|---|---|---|---|
| Interface call (synchronous) | You need an answer now | Orders asks Cart for the items: CartServiceInterface::getItems() | app/Contracts |
| Event (asynchronous) | Something happened and others may react | Orders fires OrderPlaced; Inventory deducts stock | app/Events |
| External API / webhook | Talking to a system outside the app | Payment gateway posts to /payments/webhook | Payments, Notifications, Shipping |
Interfaces 12
OrderServiceInterface
createFromCart($userId)
find($orderId)
updateStatus($orderId, $status)
hasPurchased($userId, $productId)
Checkout & Orders
Group 6
InventoryServiceInterface
deductStock($order)
restoreStock($order)
lowStock()
Inventory & Stock
Group 8Two modules
ShippingServiceInterface
getShippingFee($address)
getTracking($orderId)
Shipping & Tracking
Group 9Two modules
VoucherServiceInterface
apply($code, $subtotal)
redeem($code, $orderId)
Vouchers & Discounts
Not assigned in this section
Events
| Event | Fired by | Listeners |
|---|---|---|
OrderPlaced | Checkout & Orders Group 6 | inventory: deduct stock notifications: confirmation email shipping: create shipment vouchers (stub): redeem |
PaymentConfirmed | Payments Group 7 | orders: set status to Paid notifications: receipt |
OrderCancelled | Checkout & Orders Group 6 | inventory: restore stock notifications: notice |
OrderShipped | Shipping & Tracking Group 9Two modules | orders: set status to Shipped notifications: tracking email |
StockLow | Inventory & Stock Group 8Two modules | dashboard: alert notifications: admin email |
Core tables
| Table | Owner | Columns |
|---|---|---|
| users | Users & Auth Group 1 | id, name, email, password, role (customer/admin) |
| categories | Product Catalog Group 2 | id, name, slug, parent_id |
| products | Product Catalog Group 2 | id, category_id, name, slug, description, price, stock, image, is_activeonly Inventory writes stock |
| orders | Checkout & Orders Group 6 | id, user_id, status, subtotal, discount, shipping_fee, total, payment_method, address_id |
| order_items | Checkout & Orders Group 6 | id, order_id, product_id, product_name, quantity, unit_price |