I am learning DDD and am confused with one specific question. In my bounded context, I have UseCase that requires me to get data from an external API.I know it doesn't matter if it's an API or database we just create repositories for the entity and abstract the implementation away in the infrastructure layer.
The problem is that the type of data I am retrieving from the external API is not persisted in my Database anywhere.
What I have done is following
Application Layer
SyncListingsUseCase
Domain Layer
ListingEntity
PosListingEntity
Infrastructure Layer
PosListingRepositoryHTTP
ListingRepostorySQL
I get the POSListing from the RestAPI in the application layer from the PosListingRepositoryHTTP and then sync some of its attributes with ListingsEntity that are retrieved from ListingsRepositorySQL and persist Listing Entity.
You see I don't have PosListingEntity in my Local so my question was if I am not persisting it in my local DB can I still create an entity that maps to an external system?
As the concerns would define, the storage has nothing to do with how the domain is mapped. The representation of domain into infrastructure is a concern of the respected layer. If you want to retrieve some data using HTTP and some over SQL, the outcome should be a system recognizable object that the application layer and the domain layer can interact with. You can definitely have persistence across different systems.
In most distributed systems that have cloud self-managed databases, the data is actually retrieved over TCP socket connections. So even if you use HTTP to retrieve data, it is almost similar to that with networking sugar on top.