Onion Architecture

Onion Architecture places the domain model at the center of the application. Infrastructure and UI sit on the outside.

Dependency Direction

UI / Infrastructure
Application Services
Domain Services
Domain Model

Dependencies point inward. The database, web framework, and external services depend on the application core through abstractions.

Why Use It

Compared With Clean Architecture

Onion Architecture and Clean Architecture are closely related. Both protect the domain and enforce inward dependencies. Clean Architecture often describes more explicit use case boundaries, while Onion Architecture emphasizes the domain-centered layering shape.

Reference