Ahsan
Ahsan

Reputation: 2518

MVC Web application architectural concern

enter image description here

I have inherited an MVC application designed along the above project structure. the application uses the Unity framework for dependency injection, and the user interactions go upstream to the database in the following order View -> Controller -> ViewModels -> Repository Services -> ORM -> Database

The infrastructure components are used statically throughout the application in different layers.

My question is does this structure miss any vital components in terms of best practices? and is this in essence correct?

Upvotes: 0

Views: 78

Answers (1)

L-Four
L-Four

Reputation: 13531

You have to split the front-end part from the back-end part.

The front-end is the MVC application, consisting of models, view models, views and controllers, and in fact is your presentation layer.

The backend consists of:

  • Services layer
  • Application layer
  • Domain Layer
  • Infrastructure Layer

Basically, your controllers use the Services layer to query for information or so send commands. It gets back models, which are transformed to view models, which are passed to their dedicated views.

The Services layer uses the underlying application layer, which uses the domain layer and infrastructure layer to query information or execute commands, or do some logging and tracing and other infrastructural concerns.

Finally, if you program against interfaces and you inject instances using a IoC container, you can remove infrastructural dependencies from your domain and make everything testable and modular.

Upvotes: 1

Related Questions