First of all, thanks for the interesting example, Alex.
But... I'd like to ask one question.
I've seen many attempts to implement clean architecture when working on web interfaces, but actually, I face the same problem every time.
The specific of the web development is that we want to update UI pointwise, instead of re-rendering the whole page. And usually, we use tools that allow us to do it effectively. I mean React, Redux, and MobX are the tools that allow us to do local UI updates, right? But we pay for that by using the API provided by these tools.
Let me clarify what I mean on the example of your application.
Why do you create a new cart object with a new product array here instead of mutating this? It's because React forces you to do this, isn't it? If you don't create a new copy, React will not re-render your Cart component. But it means that the logic inside the domain layer depends on the UI layer. If you decide to replace React with VueJS, or for example if you decide just to add MobX to your React application, approaches in the domain namespace will not work anymore or at least, they will not work effectively.
That's why from my point of view, clean architecture actually is not as perfect for the front-end apps as on paper.
What do you think about this?