Designing a UI for Microservices - ApiConf 2018 · Designing a UI for Microservices Author: Mauro...
Transcript of Designing a UI for Microservices - ApiConf 2018 · Designing a UI for Microservices Author: Mauro...
@mauroservienti | #apiconf2018
Mauro Servienti
Solution Architect @ Particular Software
@mauroservienti
//milestone.topics.it
@mauroservienti | #apiconf2018
Does a page like that exist?Or put it in another way: does a “Product” class or aggregate exist?
@mauroservienti | #apiconf2018
Domain Model Decomposition
services owningtheir own piece of
information.Single Responsibility Principle
@mauroservienti | #apiconf2018
Denormalization Temptations…
Marketing Sales Shipping Warehouse
De-normalized API
Client
“Product”ViewModel…
/products/1
@mauroservienti | #apiconf2018
A report
• We're crossing a “boundary”• Data flow out of each service to the user
• Users are already pulling things on demand• let's benefit of that
@mauroservienti | #apiconf2018
ViewModel Composition
Marketing Sales Shipping Warehouse
Client
/products/1
PK PK PK PK
ViewModel…
@mauroservienti | #apiconf2018
Full vertical ownership
Marketing Sales Shipping Warehouse
Doc DB+
HTTPDB DB
back-end back-end
Web Proxy
APIAPI
Proxy to 3° party
API1 month cache
24 hourscache
No cache10 minutescache
front-endcomponent
front-endcomponent
front-endcomponent
front-endcomponent
client shell
@mauroservienti | #apiconf2018
Full vertical ownershipMarketing Sales Shipping Warehouse
Doc DB+
HTTPDB DB
back-end back-end
Web Proxy
APIAPI
Proxy to 3° party
API
front-endcomponent
front-endcomponent
front-endcomponent
front-endcomponent
client shell
composition gateway
MarketingAppender
SalesAppender
ShippingAppender
WarehouseAppender
@mauroservienti | #apiconf2018
View model/products/1
ProductNameA
€ 20.00
cover image
A
Supplier A
ProductNameB
€ 20.00
cover image
B
Supplier B
ProductNameC
€ 20.00
cover image
C
Supplier C
ProductNameD
€ 20.00
cover image
D
Supplier D
@mauroservienti | #apiconf2018
Component fromproduct-catalog
View model
Component fromproduct-catalog
/products/1
ProductNameA
€ 20.00
cover image
A
Supplier A
ProductNameB
€ 20.00
cover image
B
Supplier B
ProductNameC
€ 20.00
cover image
C
Supplier C
ProductNameD
€ 20.00
cover image
D
Supplier D
load relatedproducts
@mauroservienti | #apiconf2018
client-side message broker
Component fromproduct-catalog
Component from sales
Component from marketing
View model
Component fromproduct-catalog
Component from sales
Component from marketing
ProductNameA
€ 20.00
cover image
A
Supplier A
ProductNameB
€ 20.00
cover image
B
Supplier B
ProductNameC
€ 20.00
cover image
C
Supplier C
ProductNameD
€ 20.00
cover image
D
Supplier D
publish `RelatedProductsFound`
load relatedproducts
receive event
/products/1
@mauroservienti | #apiconf2018
Component fromproduct-catalog
Component from sales
Component from marketing
View model
Component fromproduct-catalog
Component from sales
Component from marketing
ProductNameA
€ 20.00
cover image
A
Supplier A
ProductNameB
€ 20.00
cover image
B
Supplier B
ProductNameC
€ 20.00
cover image
C
Supplier C
ProductNameD
€ 20.00
cover image
D
Supplier D
load relatedproducts
/products/1
@mauroservienti | #apiconf2018
Recap
• Clearly defined ownership
• SRP is respected
• Different caching strategies
• Business is much more flexible
• Select N+1 is not a concern• # of requests will be “# of services”