Preskoči na vsebino

Inter-Module Communication

To maintain decoupling, modules communicate using two explicit patterns: Synchronous Facades for direct reads, and an In-Memory Event Bus for side effects.


My Communication Patterns​

1. Synchronous Facades (Direct Reads & Validation)​

When a use case needs to fetch item details or check user authorization, it calls a facade method directly (items.get(itemId)). Facades expose clean domain DTOs, keeping internal database tables hidden.

2. In-Memory Event Bus (Side Effects & Decoupling)​

When an action produces side-effects — like sending push notifications, starting chat conversations, or logging audit trails — the domain module emits a typed event (BorrowAcceptedEvent).

Breaking Cyclic Dependencies

Using an in-memory event bus prevents domain logic from becoming bloated with unrelated notification code. It also prevents cyclic dependencies between modules, allowing the Borrows module to trigger actions in the Notifications module without directly importing it.