<arch.design/>
Principles/Layered (N-Tier) Architecture
{ }CodeArchitecturebeginner1990n-tiermvcseparation-of-concerns

Layered (N-Tier) Architecture

Organise code into horizontal layers (Presentation, Business Logic, Data Access) where each layer only calls the one below it.

5/5
{ }
Operates at: Code level

Inside a codebase — classes, modules, files

Interactive visualization

Live
Visualise:
Clientbrowser / appPresentationController · API · UIBusiness LogicService · Use Case · DomainPersistenceRepository · DAO · ORMDatabaseSQL · NoSQL · Cache↓ req↑ res

The Golden Rule

Each layer only calls the layer directly below it. A request travels downward; a response returns upward. No layer skips another; no inner layer knows about the outer ones.

Click any layer to explore
Request flows down through each layer; response returns back up.

How it works

Layered architecture is the most widely used architectural pattern. It divides an application into logical layers, each with a well-defined role. The classic three-tier model: Presentation (UI), Business Logic (Services), and Data Access (Repositories/DAOs).

Requests flow downward through layers; responses travel back up. Strict layering means a layer only calls the layer directly beneath it. Relaxed layering allows skipping layers for performance.

Why it matters

Layered architecture is the default starting point for most applications — it's easy to reason about, maps to common team structures, and is supported by every major framework.

When to use

  • Standard web applications and APIs
  • Teams organised by technical function (frontend, backend, data)
  • Applications with clear separation between UI and data logic

When NOT to use

  • When layers become meaningless pass-throughs with no logic
  • High-performance systems where inter-layer calls add unacceptable overhead

Trade-offs

+

Simple, universally understood structure

Can lead to 'sinkhole anti-pattern' — empty layers just passing calls

+

Easy to test each layer independently

Changes to data model often cascade through all layers

In production

Most enterprise apps

Spring MVC, Django, Rails all enforce layered patterns by convention

SAP

ERP systems built on strict three-tier client/server architecture

Industry adoption

5/5Ubiquitous — used at virtually every scale-focused company.

Related principles