Skip to main content
InterviewHubPRO
Section Overview
Q11

Question 11 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

22%
Domain-Driven Design (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

What is a Domain Event and how does it represent business facts?

senior LevelCode ExampleSystem Design

In Simple Words: A record of something meaningful that has already happened in the domain in the past:

  • Characteristics: Immutable, named in the past tense (OrderPlaced, PaymentReceived, UserRegistered).
  • Captures the exact point-in-time snapshot of the state change:
typescript
class OrderPlacedEvent {
  public readonly occurredAt = new Date();
  constructor(
    public readonly orderId: string,
    public readonly customerId: string,
    public readonly totalAmount: number
  ) {}
}
  • Emitted by the Aggregate Root to trigger side-effects in other aggregates or downstream bounded contexts without direct coupling.