I'm currently implementing clean architecture in my project.
My application includes various types of communication protocols (TCP, HTTPS, etc.) implemented in the infrastructure layer.
These communication protocols are responsible for handling incoming and outgoing network communications.
I need to process the incoming data and prepare outgoing data, which involves significant domain logic.
Problem:
I am unsure whether to inject domain services directly into the infrastructure layer for processing this data or to use a different approach that adheres to Clean Architecture and DDD principles.
Specifically, my questions are:
- Is it architecturally sound to inject domain services directly into the infrastructure layer for processing data?
- If direct injection is not advisable, what is the best practice for allowing the infrastructure layer (communication protocols) to interact with domain logic without violating the principles of Clean Architecture and DDD?
- Would using domain events or interface-based communication be a better approach in this scenario? How would this be structured effectively?
Additional Details:
My domain services contain the core logic for data processing.
The communication protocols in the infrastructure layer are the primary components that interact with the external world.
I would appreciate guidance on the best architectural approach for this scenario, along with any examples or patterns that might be relevant.