Layered (N-Tier) architecture organizes software into horizontal layers where each layer depends only on the layer directly below it, creating a stack with strict dependency directionality. The classic three tiers are Presentation (UI, API controllers), Business Logic (domain rules, use cases, orchestration), and Data Access (database queries, repository pattern, ORM). The four-layer variant adds an Infrastructure layer. Layered architecture is the most widely understood pattern and is the default starting point for enterprise applications — it provides clear separation of concerns and testability. Its main weakness is that business logic tends to leak into the presentation layer and data access layer grows coupled to the database schema.

Key Points

  • Strict layering enforces downward-only dependencies; relaxed layering allows any layer to call below (e.g., presentation calling data access directly) — strict is better for maintainability but requires discipline.
  • The Data Access Layer (DAL) / Repository pattern abstracts storage behind an interface — swapping from PostgreSQL to DynamoDB requires only a new repository implementation, not business logic changes.
  • Anti-pattern — Anemic Domain Model: business logic bleeds into service layers while domain objects are pure data holders (only getters/setters) — DDD aggregates solve this by putting behavior in the domain.
  • Transaction script vs. domain model: transaction scripts put all business logic in service methods (procedural), domain models put logic in entities (OO) — domain models are more maintainable at higher complexity.
  • Shared database anti-pattern: multiple services or modules accessing the same database tables directly — couples them at the data layer and prevents independent schema evolution.
  • Hexagonal/Clean Architecture is the evolved form: replaces fixed layers with a dependency-inverted onion where the domain core has zero dependencies and outer rings adapt it to infrastructure.
  • ORM (Hibernate, Prisma, SQLAlchemy) bridges the object-relational impedance mismatch but can generate N+1 queries or inefficient SQL — review ORM-generated queries in performance-critical paths.
  • Layered architecture maps naturally to team structure: frontend team owns presentation, backend team owns business logic, DBA team owns data access — aligns with Conway's Law for medium-sized organizations.

Real-World Example

Spring Framework's canonical three-layer architecture (@Controller → @Service → @Repository) is the most deployed software architecture pattern in enterprise Java, powering thousands of banking, insurance, and ERP systems globally. Its predictability and familiarity make onboarding faster than exotic patterns — a major organizational advantage for large teams with high turnover rates.