The idea: one order, three ways to split the work
An architecture style is a rule for how the parts of a system may talk to each other. The canvas runs the same small shop three times. Each time the same order arrives: BOOK × 2 at 12.00, so 24.00. Only the style changes:
- Layered (left): parts are stacked in layers, and a layer only calls the layer under it.
- Pipe-and-filter (top right): parts are filters in a row, joined by pipes, and data only flows forward.
- Event-driven (bottom right): parts publish events to a broker, and other parts react to them.
Blue boxes are calls and data, green boxes are answers, purple boxes are events and red boxes are errors. After a request, green parts did work and grey parts only passed the call on. Each panel's status line counts the messages.
Layers, closed and open
The classic layered (n-tier) style has four or five layers. Each has one kind of job:
| Layer | On the canvas | Job |
|---|---|---|
| Presentation | OrderController | read HTTP, write HTTP answers |
| Business | OrderService | business rules (1 ≤ qty ≤ 5) |
| Services (shared) | PricingService | work several business parts reuse |
| Persistence | OrderRepository | turn objects into rows and SQL |
| Database | MariaDB orders | store the rows |
A closed layer can't be skipped: a call must pass through it to reach the layers below. That is layers of isolation: Presentation knows nothing about SQL, so you can change the database code without touching the controller. The cost is the trip. One order goes down five layers and the answer comes back up the same way: 10 messages (Demo 1: one order, five layers).
An open layer may be skipped. Here the Services layer is a natural one to open: Business calls it only when it needs a price, and otherwise calls Persistence directly. Open layers save hops, but now Business depends on two layers below it, so changes spread further.
The architecture sinkhole
A plain read (GET /orders/1) has no business rule and nothing to price. With Services closed, Business and Services only forward the call: 10 messages, of which 4 go through layers that do nothing (Demo 2: a read sinks through). Mark Richards calls this the architecture sinkhole anti-pattern. A few such requests are normal. His rule of thumb: if more than about 20 % of requests are sinkholes, open some layers or rethink the split. The layered panel counts "sinkhole requests k of n".
Open the Services layer and the read skips it: 8 messages, one pass-through layer left (Demo 3: open the services layer). Take the Services layer down to see the other side of the choice: closed, even a read fails with 503; open, the read still works.
Pipe-and-filter
A filter reads records from its input pipe, does one job and writes the result to its output pipe. A pipe only carries data; it has no logic. The source and the sink are the two ends. The order line BOOK,2 becomes fields, is checked, gets the price 24.00 and turns into the invoice line INV-1: 5 hops, 4 filters doing real work, and no answer ever travels back (Demo 4: order as a pipeline).
Filters know nothing about each other, so you can reorder them, reuse them and add new ones. Compilers, ETL jobs, media processing and Unix shell pipelines (How the Shell Runs ls | grep foo) work this way. The weak spot is interaction: "view order" has no path in a pipeline, because nothing answers.
Event-driven, broker topology
In the broker topology there is no central controller. The Order service saves the order, publishes OrderPlaced to the broker and answers 202 Accepted at once. Payment and Inventory receive the event and work in parallel. Payment then publishes a new event, PaymentDone, which Email receives. The work is a chain of events: 7 messages, 2 events, 3 deliveries, and the client had its answer at message 3 (Demo 5: order as events).
The other topology, the mediator, puts an orchestrator in the middle that sends commands to each step in order. It is easier to follow and to handle errors in, but the mediator becomes a central part every flow depends on. How the broker hands out events is shown in Observer vs Publish–Subscribe and Kafka.
What a change touches
Press Show Impact. The yellow boxes are the parts you would edit (Demo 6: what a change touches):
| Change | Layered | Pipe-and-filter | Event-driven |
|---|---|---|---|
| add a field (a gift note) | 5 layers (4 if Services is open) | 2 filters: Parse, Format | 3 services: Order, Payment, Email |
| add a step (a fraud check) | 1 layer: Business | 0 edited, 1 new filter | 0 edited, 1 new subscriber |
Layers are cut by technical job, so a change that is about one business feature (a new field) crosses all of them. A change inside one job (a new rule) stays in one layer. Filters and event consumers only touch the data they use, and a new step is a new part, not an edit. Note the Payment service in the event row: Email reads PaymentDone, so Payment must copy the gift note into it. Event chains carry data along.
What a failure stops
Use Down / Up in Options, then send a request (Demo 7: one part down in each):
| Down | What happens |
|---|---|
| Database (layered) | the call chain is synchronous, so the error climbs through every layer: 9 messages, 503, no row |
| Price filter | the record waits in the pipe before Price (1 waiting); Parse and Validate keep working; bring Price up and it drains |
| Email service | the client still gets 202, the charge and the stock are done; PaymentDone waits in the broker until Email is back |
| Broker | the publish fails, the order is rolled back, 503: every part depends on the broker |
Choosing a style
- Layered: simple, familiar, cheap to start; good for request/answer business apps. Watch for sinkholes and for features that cut across every layer. To protect the business core from the database, invert the bottom dependency: Hexagonal Architecture.
- Pipe-and-filter: data processing in steps, batch jobs, streams. Poor for interactive requests.
- Event-driven: many independent reactions to the same fact, high load, parts that may be slow or down. Harder to follow, test and debug; the client gets "accepted", not "done".
Real systems mix them: a layered service that publishes events, or a UI layer built with MVC or MVVM. Whether the parts run in one process or many is a separate choice: Monolith vs Microservices.
What the page leaves out
Transactions across layers, the transactional outbox that makes "save and publish" atomic (Transactional Outbox and Inbox), duplicate and out-of-order events, the mediator topology in action, back-pressure when a pipe fills up, parallel and branching pipelines, layers that run on separate machines (tiers), and the cost of mapping data between layers.