microservicesclean-architecture

Do I need presenter in Clean Architecture?


I'm trying to implement Clean Architecture in a microservice, this service returns JSON response. Do I need a presenter to present the response DTO or should I just send it back to the client?


Solution

  • In Clean Architecture the presenter is the component which converts the response model of a use case interactor into a response object which is most convenient for the view (e.g. it may format float number into strings with correct precision).

    In case of an API service the presenter would do the same: conversation between service internal data structures and external data contracts (API).

    For simple services the internal and external DTOs might be the same. In this case you could omit the presenter initially and introduce it later when needed.