Hello. I'm trying to figure out how to properly build an ASP.NET application architecture. I understand that this is often a very individual question, but still.

I looked at two options for the architecture: layered and Onion.

1. Multi-level. Studied here

enter image description here

Here I didn’t like the fact that the Data Access Layer contains both models and the logic of their storage in the database.

2. Onion architecture and DDD enter image description here

At first glance, everything is fine, but when approaching reality, questions arise.

  • They say that business logic should be in Domain. But after all for its work it is necessary to carry out operations from a DB, i.e. dependence on, conditionally, IRepository

3. Hybrid Thinking, I came to such a hybrid architecture: enter image description here

  • I intentionally took into account in it initially the support of Identity / another similar solution, because otherwise it can become difficult
  • Separate interfaces for different repositories, because Generic-repository is an antipattern , because it does not allow to take into account the features of different models.

Actually, the question

Do you think this architecture will be comfortable enough to use?

UPD

User, Role - it turns out that Domain Models are dependent on Identity, which I would like to avoid. Or is it normal to map them to DTO in the business logic layer?

  • "I didn’t like the fact that the Data Access Layer contains both models and the logic of storing them in the database." - this is not true. Tutorial on your link is lying. Models in standard 3-tier architecture lie in BL. The difference between it and Onion is mainly in how the diagram is drawn - someone did not like that the DAL is drawn below, he perceived it as “based on the base” and came up with another visualization of the same approach. - PashaPash ♦
  • DDD is a domain based approach. It doesn’t matter how the layer diagram is drawn. At the same time, business logic is an integral part of the domain. In essence, a domain is a set of entities encapsulating the logic of the domain. Those. domain == business logic. It is not clear how you could separate them in your hybrid architecture :) - PashaPash ♦
  • Sorry for the canvas in the comments, but the question in its current form - most likely offtopic, because the only honest answer to it is “maybe.” If there was a universal architecture, 100% comfortable, it would all have been accepted and used long ago. - PashaPash ♦
  • @PashaPash, I met the opinion that business logic is in services. How to implement business logic in the domain? Thick models? But the models themselves can not access the database, this is already some kind of ActiveRecord. In separate classes? - Alexey Markov
  • "Models in standard 3-tier architecture lie in BL.". Those. DTO? - Alexey Markov

0