I have this project on github
My problem is that I'm not sure if I'm applying hexagonal architecture correctly.
I have made a project that is responsible for managing a to-do list, where I can work with an API or locally.
- In the domain layer, I have the Task interface.
- In the application layer, I have the use cases.
- In the ports folder, I have an interface that, according to hexagonal architecture, is responsible for connecting to the infrastructure layer.
- In the infrastructure layer, I have two files: one that connects to the API and another that works locally.
In the services layer, I have two files:
- A factory service where I create two static methods to choose whether to work locally or with the API, and another where I implement the interface from the port.
I don't really understand why there are so many files to generate, for example, in the use cases. From the hook, I call the use cases, but I could also call the methods of taskService.
The problem is that I'm not sure if I'm doing it right. For example:
Where should I manage whether the calls were successful or if there was an error?
Where should I use Zod to check that the received data matches the interface?
Can someone explain to me if I'm doing this correctly?