I have a couple of web applications that write to their own databases. They also share a few entities, for example, the customer entity. My business case is such that the same field for the same record can be updated around the same time in both the applications. It brings in dual sources of truth. How can one ensure data consistency and integrity in such a scenario? What's the best integration architecture to work with here? Is optimistic concurrency achievable in such a distributed architecture with multiple databases? What are some architectural ideas/themes that one could explore here to ensure that we have some form of data consistency going on even if the consistency model needs to be eventual?
What complicates matters here a bit is that both of the web applications are SaaS applications who's read and write APIs to their databases are tightly coupled to their respective front end UIs. So, it is difficult to decouple the UI from the database and segregate the read and write pipelines to maybe read and write from a distributed commit log in a event sourcing based architecture.
Any help here would be deeply appreciated. Thanks in advance...