How to model two bounded contexts with tight coupling between them

Context

Hello, at my company we have been working with DDD for some time now. We have a monolith and some services. The bounded contexts in the monolith use HTTP calls to communicate between them or data replication/projections when it’s needed. Now we have a case where we think we have two bounded contexts, but there are a significant amount of dependencies.

This part of the domain is based on CRM integration. We have an API to store Objects and Records (same behavior as a CRM, but our implementation):

  • The aggregate Object is an arbitrary object in a CRM (with configurable fields, etc)
  • The aggregate Record is an instance of an Object.

It may seem I’m talking about OOP, but I’m not. This is the ubiquitous language in our CRM (and in others too, like Salesforce). For instance, Account would be an Object, and a specific account, would be a Record of the Object Account. Now, both Object and Record aggregates, are part of the RecordsBC bounded context. The RecordsBC contains the business logic of our own CRM-like implementation.

Due to the fact, that we are also an integration company, we also have a bounded context named CRMIntegrationBC, where our customers can choose to replicate their CRM data inside our application, keeping them synced. This is not mandatory, so one of our clients can be connected or not to a CRM.

As described, our business processes between these two bounded contexts are more or less like this:

enter image description here

So, for CRUD-related operations in the RecordsBC, if the company is integrated, we also need to replicate the data there, using the CRMIntegrationBC. We do this synchronously because we think introducing events for this is going to increase the complexity too much (we are not event-driven yet).

Question

So, I have some questions about how to model this:

Q1: Should RecordsBC and CRMIntegrationBC be separate bounded contexts?

From the beginning, I assumed they should be, because it seems the logic is quite different:

  • RecordsBC handles our own CRM business rules and features.
  • CRMIntegrationsBC handles CRM-integration things like how many users you can integrate, what objects, etc.

Nonetheless, given the high coupling between their use cases, I’m unsure about this fact.

Q2: If they indeed should be separate BC, how should communication take place?

Both of these modules live in our monolith, and we want to avoid direct import statements. For that reason, we thought that we will use a REST API to communicate both contexts:

  • To create a Record, our web/mobile clients would call POST /api/records, that would trigger the application service of creating a record in RecordsBC, which would handle the communication with CRMIntegrationsBC. Something like:
class CreateRecordService:
    def run(self, user_id, record):
        self._do_some_validation()
        # HTTP call to the API of CRMIntegrationBC
        if self._user_is_crm_integrated(user_id):
             # HTTP call to the API of CRMIntegrationBC
             self._create_record_in_crm(user_id, record)
        self._create_record(user_id, record)

Notes

Our tech stack consists of a Django monolith and some other different services (mainly fast API, and some NoseJS servers). Our BCs are set as:

src/
   shared_kernel/ # things like aggregate IDs and such
   RecordsBC/
       application/
       domain/
       infrastructure/
   CRMIntegrationsBC/
       application/
       domain/
       infrastructure/

8

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật