The structure of my solution is as follows
API -> BuisnessLogic - DataAccess
The API make use of services that the business logic has. Such as a Project Service. That service has a method with the following signature Task<ProjectGetDto>GetProjectById(int id). Now I've come to realise that my service can not be reused. So I added a extra 'layer' the facade layer which sits between the API and business logic as such. The business logic now only really deals with entities. The facade turns those entities into Dtos for the API to use. The services are now more repositories (i will rename these). These means I can re-use these repositories throughout my business logic.
The problem I'm struggling with is that technically anything can use that business logic. I kinda want to hide those repositories so that only the facades can see/use them. Outside of that project nothing should be able to use those repositories. There is nothing stopping the api from injecting a repositories and using that directly. So I started to look into internal classes. However with Dependency injection I just see how to make it work.
I added a extension method to add the required repositories in the business logic. Knowing that the API cannot see them. But if I try to inject a repository into a façade I get a error stating that the inject class is less accessible then the class trying to use it.
I feel like dependency injection is stopping me from encapsulating my code
The way I have got around these for now is to make the facade layer a new project and have the API reference the facade project and the facade now references the business logic. However I still feel like the business logic is not encapsulated as it could still be used in a way I don't want it to