Event-Driven Architecture
When one part of a system needs to react to something that happened in another, you can wire them together directly, or you can let the first announce an event that the second listens for. Event-driven architecture is the second approach raised to an organizing principle: components communicate by producing and reacting to events rather than calling each other. This page defines the pattern in general; for how it shapes user interfaces specifically, see event-driven UI, and for a runnable version see the event-driven UI example.
This is a definition of the architectural concept, not an implementation walkthrough.
What you'll learn
What event-driven architecture is
The pattern is defined by how parts communicate, not by what they do.
A definition
Event-driven architecture is a style in which components communicate by emitting and responding to events, rather than by calling one another directly. When something significant happens, a component publishes an event describing it, and any interested component reacts. The parts are connected by the flow of events instead of by direct references.
Producers, consumers, and the channel
Three roles describe almost any event-driven system.
The roles involved
A producer emits an event when something happens, without knowing who will handle it. A consumer subscribes to events it cares about and reacts. Between them sits a channel, an event bus or broker, that carries events from producers to consumers. The same three roles appear whether the system is a single page or a distributed backend, as in event streaming architecture.
Why it decouples systems
The defining benefit is what the pattern removes: direct dependencies.
Decoupling through events
Because a producer only emits an event and a consumer only listens, neither holds a reference to the other. You can add, remove, or change a consumer without touching the producer, as long as the events stay the same. This decoupling is what lets large systems grow without every change rippling outward, the same property explored in component communication.
Common messaging patterns
Event-driven systems are usually built on a couple of recurring patterns.
Publish-subscribe and queues
The most common is publish-subscribe, where producers publish to a topic and any number of subscribers receive it, ideal for broadcasting that something happened. A related pattern uses queues, where each message is handled by one consumer, suited to distributing work. Both rest on the same idea of communicating through messages rather than direct calls.
Where you see it
The pattern spans the smallest interfaces and the largest systems.
From a UI to a backend
In the browser, an event bus coordinating components is event-driven architecture in miniature, as the event-driven UI example shows. At scale, backend services emitting events to each other use the same principle to stay independent. Realtime features lean on it heavily, which is why it recurs across the interactive web cluster.
A common misconception
One mistake turns the pattern from a help into a hindrance.
Events are not always the answer
Event-driven communication is powerful, but using it everywhere makes a system hard to follow, because the flow of control becomes implicit. For a direct request that expects a direct response, a plain function call is clearer than an event. The pattern suits broadcasting that something happened to unknown listeners, not every interaction, a balance discussed in event-driven UI.
Frequently Asked Questions
What is event-driven architecture?
It is a style in which components communicate by emitting and responding to events rather than calling one another directly. A producer publishes an event when something happens, and any interested consumer reacts to it.
What are the parts of an event-driven system?
A producer that emits events, a consumer that subscribes and reacts, and a channel such as an event bus or broker that carries events between them. The same roles appear in both browser interfaces and distributed backends.
How does event-driven architecture decouple components?
A producer only emits events and a consumer only listens, so neither references the other. You can add, remove, or change a consumer without touching the producer, as long as the events stay the same.
When should I not use events?
Avoid events for a direct request that expects a direct response, where a plain function call is clearer. Using events everywhere makes the flow of control implicit and hard to follow. They suit broadcasting to unknown listeners.
Read next: the virtual DOM, or the Concepts hub.
See it applied to UIs?
Event-driven UI shows the pattern shaping a user interface.
Read: Event-Driven UI →