Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

integrating clean architecture with ORM

I'm trying to develop a monolithic Django application with Uncle Bob's clean architecture. The problem is I don't want to miss the powerful abilities of Django ORM but this will make a confusion at the same time. The ORM will handle the repository and data layer of application but at the same time makes problem in DTO because I don't want to transfer objects of type Django model.

Should I create a port to convert Django model objects into plain old Python objects? I think Django is not much suitable for integrating with clean architecture. I mean for a monolithic large scale application Django will have many down sides.

like image 894
Mond666 Avatar asked Oct 20 '25 03:10

Mond666


1 Answers

When you talk about Clean architecture, are you talking about hexagonal architecture ? If yes, your question is not only related to Django but to all languages.

The fundamental principle about the domain is that it should not have any dependencies. Given this principle, if a DTO is used by the ORM, it is very likely that you will have to do the mapping ORM Entities <-> Domain Model

Whatever the framework, and therefore the ORM that you use, it must not be imported into the domain which must remain agnostic in relation to everything and must therefore be coded in plain old language objects.

like image 171
slim Avatar answered Oct 21 '25 17:10

slim