I have a doubt about the architecture of the app I am working on. It is built like this following modules:
module-app
module-domain
module-rest
module-rest-api
module-rest-client
In the module-rest-api
I store the DTO
s of my controllers. But now i have to add others DTO
s to call an external client.
So the question is, where do i have to implement those external DTO, in the module-rest-api
or inside the external client package
into the module-app
?
I would appreciate some help, thank you.
There's no one answer here because where you put those DTO's very much depends on personal preference.
For example, you could have a module-dto. In the module-dto you could have a number of packages and divide them by purpose e.g.
com.mycompany.project.dto.outbound. //for external requests
com.mycompany.project.dto.inbound. //for incoming api requests
This way you can just import your dto module anywhere. I've always maintained my DTO's is a standalone module for this very reason that I can just use it then from anywhere then.