intermediate

Layered architecture

Separate presentation, application, domain, and infrastructure responsibilities while keeping dependency direction and transaction boundaries explicit.

Layered architecture organizes presentation, application, domain, and infrastructure tiers with explicit dependency direction. It is a pragmatic default for many enterprise apps when teams need familiar structure and transaction boundaries align with use cases. Layers are logical; physical deployment may still be monolithic.

On interviews: map a feature through layers on a whiteboard. Explain where DTO mapping happens and why domain should not call upward.

Common pitfalls: strict layers that forbid legitimate cross-cutting concerns; presentation logic leaking into application services; database schema driving domain design.

The trade-off is flexibility versus complexity—know when the simpler path is enough.

Checklist:

  • Each layer has documented responsibilities.
  • Dependencies point inward toward domain.
  • Cross-layer types mapped at boundaries.
  • Integration tests span realistic layer collaborations.