@mauroservienti | #apiconf2018
Designing a UI
for Microservices
Mauro Servienti | @mauroservienti
@mauroservienti | #apiconf2018
100% remote
@mauroservienti | #apiconf2018
bike rider
@mauroservienti | #apiconf2018
bananas
my favorite snack
@mauroservienti | #apiconf2018
What could
possibly go
wrong…
@mauroservienti | #apiconf2018
Let me buy a “banana holder”
@mauroservienti | #apiconf2018
Mauro Servienti
Solution Architect @ Particular Software
mauro.servienti@gmail.com
@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
“There is no spoon”
Sales
Warehouse
Shipping
Marketing
@mauroservienti | #apiconf2018
Domain Model Decomposition
services owning
their own piece of
information.
Single Responsibility Principle
@mauroservienti | #apiconf2018
How can we design something like that?
@mauroservienti | #apiconf2018
Denormalization Temptations…
Marketing Sales Shipping Warehouse
De-normalized API
Client
“Product”ViewModel…
/products/1
@mauroservienti | #apiconf2018
<rant />
That’s a cache!
@mauroservienti | #apiconf2018
Oh…and by the way…
@mauroservienti | #apiconf2018
Whatchoo talkin'
'bout, Willis?
a report
not a cache
@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
@mauroservienti | #apiconf2018
Full vertical ownership
Marketing Sales Shipping Warehouse
Doc DB
+
HTTP
DB DB
back-end back-end
Web
Proxy
API
API
Proxy to
3° party
API
1 month
cache
24 hours
cache
No cache10 minutes
cache
front-end
component
front-end
component
front-end
component
front-end
component
client shell
@mauroservienti | #apiconf2018
View Model Appender
@mauroservienti | #apiconf2018
Request matching
@mauroservienti | #apiconf2018
Composition
@mauroservienti | #apiconf2018
Full vertical ownership
Marketing Sales Shipping Warehouse
Doc DB
+
HTTP
DB DB
back-end back-end
Web
Proxy
API
API
Proxy to
3° party
API
front-end
component
front-end
component
front-end
component
front-end
component
client shell
composition gateway
Marketing
Appender
Sales
Appender
Shipping
Appender
Warehouse
Appender
@mauroservienti | #apiconf2018
Composition Gateway
@mauroservienti | #apiconf2018
is all that glitters gold?
@mauroservienti | #apiconf2018
What about grids?
@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 from
product-catalog
View
model
Component from
product-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 related
products
@mauroservienti | #apiconf2018
client-side message broker
Component from
product-catalog
Component from
sales
Component from
marketing
View
model
Component from
product-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 related
products
receive event
/products/1
@mauroservienti | #apiconf2018
Component from
product-catalog
Component from
sales
Component from
marketing
View
model
Component from
product-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 related
products
/products/1
@mauroservienti | #apiconf2018
Composition
@mauroservienti | #apiconf2018
Composition
@mauroservienti | #apiconf2018
Composition
@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”
@mauroservienti | #apiconf2018
//bit.ly/view-model-composition-demos
@mauroservienti | #apiconf2018

Designing a ui for microservices

Editor's Notes

  • #10 While showing ownership in overlay....Lots of components, or in SOA lingo services, each one owing different data. Otherwise it's a clear violation of responsibilities.
  • #13 It's very tempting to design a technical solution
  • #14 no clear ownership no easy way to (partially) invalidate it the truth from the user perspective
  • #18 It's very tempting to design a technical solution
  • #19 It's very tempting to design a technical solution
  • #20 It's very tempting to design a technical solution
  • #24 It's very tempting to design a technical solution