Domain Event
ELI5 — The Vibe Check
A domain event is something meaningful that happened in your business. Not 'row updated in users table' but 'UserRegistered' or 'OrderShipped.' It speaks the language of the business, not the database. Other parts of the system react to these events to do their thing.
Real Talk
A domain event is a record of something significant that occurred in the domain model, expressed in ubiquitous language. It captures a state change with its context (who, what, when, why) and is typically immutable. Domain events enable loose coupling between aggregates, bounded contexts, and services in domain-driven design architectures.
Show Me The Code
class OrderShipped {
constructor(
public readonly orderId: string,
public readonly trackingNumber: string,
public readonly shippedAt: Date,
public readonly carrier: string
) {}
}
eventBus.publish(new OrderShipped(order.id, 'UPS123', new Date(), 'UPS'));
When You'll Hear This
"When an order ships, we publish an OrderShipped domain event that triggers email and inventory updates." / "Domain events should describe what happened, not what to do — 'OrderPlaced' not 'SendConfirmationEmail'."
Related Terms
Aggregate Root
An aggregate root is the boss entity that controls a group of related objects. Want to add an item to an order?
Domain-Driven Design (DDD)
DDD says your code should speak the same language as the business.
Event Bus
An event bus is a highway for events — services publish events onto the bus, and any service that cares about that event picks it up.
Event Sourcing
Instead of storing 'balance: $100', event sourcing stores 'deposited $200, withdrew $50, withdrew $50'.