Should I duplicate model and database of master data across services in microservice

microservices

We are a fintech startup that trying to re-build monolith php to microservice. As typical web app, we use to manage master data in admin page. How do i distribute this master data through microservice? We build a two API management service. One for the frontend user entry point other for admin/backend user entry point.
We create a Loan service for front-end user and an administration service for back-end user. Loan service will use loan promo, city, country data which are also managable from admin servicd. Should we duplicate the model and database of loan promo, city and country from admin service to loan service? Or should we put those master data in loan service? I also read about saga pattern that maybe we can use it. After any update from admin service will trigger update on loam service.

We are still designing and figuring how to implement it best. Any advice or input I really appreciate.

Best Answer

The short answer is 'No', you should not just duplicate the data. The right thing to do will depend on how you have designed your microservice architecture. For example, if you were using Domain-Driven Design, you would have a Bounded Context for each service that defines the Domain Model as needed by that service. Data that is changed by other services that is relevant to this service can be consumed by subscribing to the relevant events published by the services that change the data. This article regarding Bounded Contexts in Microservices may be helpful to you.

Related Topic