Excellent article. It was very enlightening to see DDD from a functional perspective. But a couple of doubts now haunts me:
let's take the ClaimsPolicy v SalesPolicy duality; how would that fit in the folder structure presented? Should there be a claims and a sales folder inside src/domain and then, inside of each, the entities and operations sub-folders? Or should we keep the structure as is, but create different files (for instance, salesPolicy.entity.ts and claimsPolicy.entity.ts, along with the other respective files)?
in which layer should transactional control be? I mean, where should a commit or rollback be placed? In classical DDD, the aggregate root works as a unit-of-work boundary of some sort; but if we abandon this, who should control the transaction? Yes, the repository could take care of that, but only if it operates upon an aggregate-root-like Entity; otherwise the controller might have to use more than one repository to accomplish its task, but doing so would come with the risk of the second one failling a commit after the first one has already commited. To better illustrate what I mean, I pose the question: in the upgradeSubscription controller example, how could we rollback subscriptionRepo.update if chargeCreditCard failed? I know chargeCreditCard is not a repository in the example, but I think the question is still valid in this scenario.