I am running into an issue with proper architecture when using gRPC. In a traditional DDD approach, the core project (i.e. innermost layer / domain layer) has no references to the outside layer and only really contains entities/aggregates/interfaces/value objects and so on. Actual implementation of these might go in separate layers (infrastructure/application/etc.)
With gRPC, the contract (i.e. the interface) is defined at the proto file level. But these proto files have to be compiled as server/clients in order to work. From my intro to DDD, the core layer should not really have package references (e.g. in .Net core, I am using a .Netstandard 2.1 project for my core domain project - it has no external nuget package references and is kept clean). In a normal scenario, you could build an interface specific to your domain layer for things like marker interfaces etc. in order to avoid polluting your domain layer with external dependencies. But with proto files, that is not possible.
There are three options I can choose:
- Place proto files in core project, add necessary packages in core project to compile them
- Place proto files in core project, but build them in another project (i.e. when building project, get a relative reference to the file in another project and build them)
- Utilize a shared project that has all these proto files and build them there
I am wondering what the correct approach to this is. I can see pros and cons for all but would like some information on if one approach is better than others.