I want to create a multi-layered backend architecture with a REST layer and GraphQL layer later on.
So let's say you would start with the basic layers controller, service, repository would it make sense to create request/response interfaces for each layer?
When creating a user you might come up with
- create-user DTO => controller request => holding username and password from the body
- user DTO => controller response => user object sent back to the client
- create-user BO => service request => request data coming from the controller
- user BO => service response => user object coming from the service
- create-user DAO => repository request => request data coming from the service
- user DAO => repository response => the database user
So each layer would define its own input and output data. Would this be considered best practise or are there any better ideas?
It would also be possible to create a separate library for each layer and the controller would consume the service library.