Middleware process pipeline for multiple data sources

if i import products data to spryker from an external API via middleware there may be the case, that this data is not new, instead it just should update existing products.
So i have to look if the product is already exists and just update the properties which are given by my inputstream.

So where in the “steps” of an middleware process pipeline the fetching of the already existing data from the database should take place?

InputStream -> json data (from api)
Validator -> ?
Mapper -> ?
Translator -> ?
OutputStream -> database write stream

My further procedure would be that the outputstream would receive a spryker product client instance, then create a customertransfer and write it to the database. But where should the logic to decide update/new product should go into?

Should i just add another inpustream as a further stage into the pipeline which loads the data from the database and “merge” it to one array?

Is there maybe an example somewhere for a similar case?

As far as i can see, the akeneo import module assumes also that the import ist just straight forward regardless of existing products !?:thinking: