The point is separation of responsibilities: each layer is responsible for its own part and calls only the layers beneath it. The presentation layer shows the interface, the logic layer enforces the business rules and the data layer stores and retrieves information. This makes the code easier to change piece by piece, so a change to one layer does not disturb the whole system.
Typical layers and the dependency rule
| Layer | Responsible for | Examples |
|---|---|---|
| Presentation | the interface: forms, pages, REST and GraphQL endpoints | Django views, React components |
| Logic | business rules and domain scenarios | services, model managers |
| Data access | saving and reading, queries, transactions | ORMs, repositories |
| Database | storing the data itself | PostgreSQL, MongoDB |
The main rule is that dependencies point downwards. The presentation layer calls the logic layer, and the logic layer calls the data layer, but not the other way round: a lower layer knows nothing about the layers above it. This breaks circular dependencies and makes it possible to change or extract the lower layers without touching the upper ones. Layers can be closed — a layer may call only the layer immediately beneath it — or open, where skipping over a layer is allowed. Closed layers keep fewer connections and behave more predictably under change; open layers save extra calls but tie the layers more tightly together.
Layers are a logical division of the code, not a physical one: all three layers can run in a single process on a single server. Deploying layers on separate machines turns them into tiers; hence the names of deployment schemes — two-tier, three-tier, n-tier. How many layers to move into separate tiers is decided by the load and by security requirements.
What it looks like in code
# request -> view (presentation) -> service (logic) -> repository (data)def create_order_view(request): dto = parse_order(request) # presentation layer order = order_service.place(dto) # business logic layer return render(request, order) # presentation layerWhen it fits and when it gets in the way
- Suits typical business applications: CRUD, admin panels, online shops, internal services.
- The structure is familiar to most teams: new developers do not have to learn the approach from scratch.
- A large body of business logic is the weak point: when it all lives in a single “middle” layer, domain rules dissolve into services without a separate domain model.
- Every request passes through all the layers, so other styles are sometimes needed for high loads.
Sources
the term is written from these pages- Microsoft — Chapter 5: Layered Application Guidelines (Application Architecture Guide)learn.microsoft.com/en-us/previous-versions/msp-n-p/ee658109(v=pandp.10)(opens in a new tab)
- Microsoft Learn — N-tier architecture style (Azure Architecture Center)learn.microsoft.com/en-us/azure/architecture/guide/architecture-styles/n-tier(opens in a new tab)
Verified 8 Nov