Onion Architecture

Onion Architecture is a way of structuring software so that core business rules sit at the center, protected from databases, user interfaces, and other technical details that change far more often than the business itself.

Definition

Onion Architecture organizes a system as a set of concentric layers, or rings, with the domain model — the pure business rules and entities — at the very center. Surrounding it are domain services (business logic that operates on the model), then application services (use-case orchestration), and finally an outer ring containing infrastructure: databases, messaging, user interfaces, and third-party integrations. The single governing rule is that dependencies only point inward. Outer rings can reference inner rings, but inner rings never know the outer rings exist; where the core needs an external capability, it defines an interface, and an outer-ring component implements it. This inverts the flow of traditional layered (N-tier) architecture, where business logic typically sits in a middle layer that directly depends on a specific database schema or presentation framework below and above it. In that traditional model, a change to the database technology or the UI framework can ripple into the business logic itself. Onion Architecture deliberately breaks that coupling using dependency inversion, so the domain core remains stable and testable regardless of what technology surrounds it. While the term originates in software engineering, business and enterprise architects encounter it because it operationalizes a principle they already apply at the enterprise level: separate what is stable and differentiating (business capabilities, domain rules) from what is volatile and interchangeable (specific applications, vendors, infrastructure). Reviewing whether a proposed solution architecture honors that separation — or quietly violates it — is a legitimate and increasingly common business architecture concern during solution design reviews and technology roadmap decisions.

Origin & Context

The term was coined by software architect Jeffrey Palermo in a 2008 blog post as an alternative to conventional layered/N-tier designs that had grown brittle under technology change. It draws on the same dependency-inversion thinking behind Alistair Cockburn's Hexagonal (Ports and Adapters) Architecture and later influenced, and was influenced by, Robert C. Martin's Clean Architecture. All three belong to a family of domain-centric patterns that emerged from practitioners' frustration with business logic tangled into database and framework code.

Why It Matters

Enterprise and solution architects care because Onion Architecture directly reduces the cost and risk of technology change — a core system, integration platform, or UI framework can be replaced without rewriting the business rules underneath it. CIOs and CTOs use it as a design discipline to protect major modernization investments from becoming obsolete the moment a vendor or platform is swapped out. Business architects care because the pattern is a concrete, implementable expression of capability-based planning: it gives them a way to insist that a business capability's logic remains portable across whatever systems currently deliver it. For organizations facing frequent M&A integration, platform migration, or vendor consolidation, this separation materially shortens re-architecture cycles and lowers regression risk.

Common Misconceptions

Myth: Onion Architecture is just another name for traditional layered architecture.
Reality: The two look similar as diagrams but differ in a critical way: in traditional layered architecture, dependencies flow downward through presentation, business, and data layers, so business logic often depends on data structures. In Onion Architecture, all dependencies point inward toward the domain core, and outer layers implement interfaces the core defines — the core never depends on anything outside it.
Myth: It's a purely technical, software-engineering concern with no relevance to business or enterprise architects.
Reality: The pattern's dependency-inversion principle mirrors what business architects already demand through capability-based planning: that a capability's business logic remain independent of any single technology implementation. Reviewing whether a solution design honors this separation is squarely within an enterprise architect's remit during architecture governance.
Myth: Adopting Onion Architecture means rewriting an existing system from scratch.
Reality: It can be introduced incrementally. Teams commonly wrap legacy systems with adapters and interfaces, establishing a new protected domain core while the surrounding legacy components are replaced or modernized gradually, one adapter at a time.

Practical Example

A lead business architect at an insurance carrier was engaged on a claims modernization initiative. Working with the solution architect, she insisted the claims adjudication rules and claims domain model form the protected core, with application services orchestrating capabilities like Claims Intake and Claims Adjudication around it. External dependencies — a third-party rating engine, a document management vendor, and the legacy policy administration system — were connected through defined interfaces rather than direct calls. Midway through the program, the enterprise decided to replace the document management vendor for cost and support reasons. Because that dependency sat in the outer ring behind an interface, the integration team swapped it without touching the adjudication rules engine at all. The business architect used this as evidence in later governance reviews that capability logic had genuinely been decoupled from vendor churn, not just documented as decoupled.

Industry Applications

Financial Services
Lending and credit decision engines are kept at the domain core so channel applications (branch, mobile, web) and core banking platform replacements don't require rewriting underwriting rules.
Healthcare
Clinical decision support logic is isolated from the electronic health record vendor layer, allowing an EHR migration or vendor switch without altering clinical rule sets.
Insurance
Underwriting and adjudication rule engines are protected from policy administration system replacements, a common driver of costly re-platforming projects.

Related Terms

  • Hexagonal Architecture: a closely related domain-centric pattern (ports and adapters) often discussed alongside Onion Architecture
  • Domain-Driven Design: the methodology whose domain-modeling concepts heavily influenced Onion Architecture
  • Business Capability: the stable business construct that the Onion Architecture's domain core is designed to protect