Service
communications

SOA/ESB/EDA/MicroService/CQRS/ES

Bounded Context & Context Mapping

Context

Domain Driven Design

Bounded Context

Dealing with Complexity, Legacy System, Separated Team corp ...

Context

Bounded Context

Context

Why we need Bounded Context ?

As we try to model a larger domain, it gets progressively harder to build a single unified model.

We build model acting as a UbiquitousLanguage

https://martinfowler.com/bliki/BoundedContext.html

Context

Recognize bounded context

Contradiction of entities

Linguistic / Business Capability

Context

For an example

Name, Profile

User

Browsing History

Receiver, Orders

Payer, CreditCardNumber

Member

Lead

Buyer

Payer

Context

For an example

Category, Labels

Product

Price, Promotion

Order

Product

SalesItem

OrderItem

Sku

Inventory

Context

conway laws

"Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization's communication structure."

Conway Laws

Context

autonomy

Every context has its database

Autonomy

Microservice

https://www.slideshare.net/kimKao/2019-0612aws-taipei-summitdeve-day2essential-capabilities-behind-microservices

Context

autonomy

https://medium.com/design-and-tech-co/implementing-domain-driven-design-for-microservice-architecture-26eb0333d72e

Context

find service boundary

4+1 Architectural View Model

https://codeopinion.com/41-architectural-view-model/

codebase/git

cloud infra/cd

communication

functionality

Context

find service boundary

4+1 Architectural View Model

https://codeopinion.com/41-architectural-view-model/

When not everything maps 1:1, that’s when it makes it a bit more challenging finding service boundaries. Focus on the scenarios.

Context

For an example

Which context do User Auth belongs ?

Context

For an example

https://ithelp.ithome.com.tw/articles/10218252/

Context

For an example

Problem-Space & Solution-Space

https://medium.com/@nikhilgupta08/problem-space-vs-solution-space-f970d4ace5c

Context

Domain Driven Design

Context Mapping

Context

Context mapping

Big mud ball /

Continuous Intergration

Context

Shared Kernel

Share models between different context

Order in Shopping context &
Recommendation context

Context Mapping

Context

Customer-Supplier

Automated Acceptance Tests

Downstream is the customer

Context Mapping

Context

Conformist

When upstream has no motivation to supply downstream

Context Mapping

Upstream is good to follow

Context

Anti-corruption Layer

Translate only data but not business logic

FACADE

Like a Service

Context Mapping

Legacy system is usually most valuable in prod.

Context

Open Host Service/
Published Language

Context Mapping

API

Protocol Buff

Context

Open Host Service/
Published Language

Context Mapping

https://zhuanlan.zhihu.com/p/31985410?fbclid=IwAR3Z6cZZtjkI-kLD_f8oJyonx3BlvqLBvu4_LCWn578oflQS_iicqJpSwKk

Context

Separate Way

e.g. Delivery state of Logistics (outsource), excel ...

Context Mapping

When we don't consider further integrations

Context

Context Mapping

Context

Context Mapping

The level of control

The cost of coordination

Context

Context Mapping

In Lower the integration mode

Lead to less communicate

More duplicated code

Context

Context Mapping

Big Context

Small Context

https://xiaoyue26.github.io/2019/07/22/2019-07/%E9%A2%86%E5%9F%9F%E9%A9%B1%E5%8A%A8%E8%AE%BE%E8%AE%A1-%E7%AC%AC7-17%E7%AB%A0%E7%AC%94%E8%AE%B0/

One Cohesive model, more clear & less transfer cost

Less abstract design required

More flexible for specific demands

Context

Context Mapping

Follow the reality to build bounded context, not the ideal.

Context

Context Mapping

Less destruction of models & less works

Context

Context Mapping

Merge Bounded Context

Separate way -> Shared kernel

Focus on the duplicated subdomain

p.398

Map the term

Start from the small and easy part

Context

Context Mapping

Merge Bounded Context

Shared kernel ->
Continuous Intergration

One big team or Two small team (which is good)

Be careful about core domain

Context

Context Mapping

Merge Bounded Context

Eliminating Legacy System

1. Pick one functionality from legacy to new system

2. Make sure we have enough auto tests

3. Implementation

Context

Context Mapping

Distillation

Don't split contexts by any other thing isn't related to logic

Context

Context Mapping

Context

Context Mapping

Insurance Company Example

https://github.com/ContextMapper/context-mapper-examples/tree/master/src/main/cml/insurance-example

Context

Context Mapping

Bounded Context vs Subdomain

Implementation & protection of models

Represent the definition for subdomain

Business capability

Implementation

How we carry out these concepts

Concept v.s. Architecture

Service-Oriented Architecture

Implementations

From concepts to implementations

Enterprise Service Bus

Implementations

From concepts to implementations

Event-Driven Architecture

Implementations

From concepts to implementations

Microservice

Implementations

From concepts to implementations

中台模式

Implementations

From concepts to implementations

CQRS

Implementations

From concepts to implementations

Event Sourcing

Implementations

From concepts to implementations

Event Communications

How distributed system communicate to each others

Choreography
v.s. Orchestration

Choreography

Orchestration

&

Event communications

How distributed system communicate to each others

command

events

https://microservices.io/patterns/data/saga.html

Event communications

How distributed system communicate to each others

https://solace.com/blog/microservices-choreography-vs-orchestration/

Event communications

How distributed system communicate to each others

TypeScript Ver. POC: https://github.com/guAnsunyata/ts-tram-saga

Event communications

How distributed system communicate to each others

https://www.youtube.com/watch?v=Fso2OyguRuQ

Event communications

How distributed system communicate to each others

https://www.youtube.com/watch?v=Fso2OyguRuQ

Message Queue Server

message queue

Challenges

https://github.com/OptimalBits/bull

Message Queue Server

message queue

Compare to all potential solutions

NATS

Introduce NATS

NATS

Introduce NATS

NATS

Introduce NATS

NATS

Introduce NATS

Subject

Subscription

Queue Group

Durable Name

Decoupling

Decouping

Help us more efficiency

A Microservice way

Decoupling

Help us more efficiency

Event Sourcing (CDP)

ML use cases

Help us more efficiency

Domain Event

https://github.com/CodelyTV/php-ddd-example/blob/master/src/Mooc/Courses/Domain/Course.php

ML use cases

Help us more efficiency

Model

Domain Driven Design

Model Evolution

Model

model

https://www.jianshu.com/p/39c557f5b87f

Model

model

Model

model

Model

model

Model

model

Model

model

https://ithelp.ithome.com.tw/articles/10218943

Model

model

Model

model

Location

Model

model

Model

model

Model

Domain Driven Design

Choosing context mapping

External System

Different Model

Deployment

Event/Command - Cross Domain communications

By guansunyata

Event/Command - Cross Domain communications

  • 433