Slide 1

Slide 1 text

Micro Frontends OR frontend, backend, ! happyend the nitty gritty details

Slide 2

Slide 2 text

Michael Geers Frontend Engineer naltatis on Twitter & GitHub micro-frontends.org Bremen, Germany e-commerce

Slide 3

Slide 3 text

Frontend Monolith Black Diamond Royal Library, Copenhagen

Slide 4

Slide 4 text

faster feature development

Slide 5

Slide 5 text

1. what? 2. why? 3. how? 4. nitty gritty details Micro Frontends "

Slide 6

Slide 6 text

Where do we come from? but before …

Slide 7

Slide 7 text

The Monolith Backend Frontend era of the full-stack developer

Slide 8

Slide 8 text

Backend Frontend Backend Frontend bye bye full stack #

Slide 9

Slide 9 text

Team Inspire Team Search Team Decide Team Checkout Frontend Teaser Service Product Service Price Service Availability Service Payment Service Basket Service Customer Service API Gateway (Rest, BFF, GraphQL) Microservice Architecture Backend Frontend specialists

Slide 10

Slide 10 text

Frontend Frontend The Monolith Front- & Backend Microservices Frontend Monoliths Backend Frontend Frontend Teaser Service Product Service Price Service Availability Service Payment Service Basket Service Customer Service API Gateway (Rest, BFF, GraphQL) growing complexity no scaling

Slide 11

Slide 11 text

Micro Frontends Team Inspire Team Search Team Decide Team Checkout Backend Frontend

Slide 12

Slide 12 text

1.What are Micro Frontends?

Slide 13

Slide 13 text

Micro Frontends Definition ThoughtWorks Technology Radar https://www.thoughtworks.com/de/radar/techniques/micro-frontends Stages: Access (2016) > Trial (2017) > Adopt ⭐ (2019) … Our preferred (and proven) approach is to split the browser-based code into micro frontends. In this approach, the web application is broken down into its features, and each feature is owned, frontend to backend, by a different team. This ensures that every feature is developed, tested and deployed independently from other features. …

Slide 14

Slide 14 text

Autonomy Team Inspire Team Decide Team Checkout own tech stack independent deployments self contained

Slide 15

Slide 15 text

Team Missions „Make discovering and finding products easy.“ „Support the customer’s buying decision.“ „Make the actual buying process happen.“ Team Inspire Team Decide Team Checkout

Slide 16

Slide 16 text

& organizational technical Implications

Slide 17

Slide 17 text

2.Why Micro Frontends?

Slide 18

Slide 18 text

specialists team

Slide 19

Slide 19 text

cross functional team

Slide 20

Slide 20 text

Frontend Payment Service Content Service Operations Platform Business Attributes Service Specialist Teams Team Inspire Team Decide Team Checkout Cross Functional Teams grouped around a use case or customer need grouped around a skill or technology

Slide 21

Slide 21 text

Frontend Payment Service Content Service Operations Platform Business Attributes Service Specialist Teams Team Inspire Team Decide Team Checkout Cross Functional Teams grouped around a use case or customer need grouped around a skill or technology developing a new feature inter-team communication ⏳

Slide 22

Slide 22 text

& Development Speed

Slide 23

Slide 23 text

Customer Focus direct feedback loop no pure api teams

Slide 24

Slide 24 text

Reduced Scope everything fits
 into memory again ❤ my

Slide 25

Slide 25 text

Frontend Renovation without throwing everything away

Slide 26

Slide 26 text

2005 2010 2015 ® Polymer hyperapp ? frontend tools change fast

Slide 27

Slide 27 text

Frontend Backend Database Ruby on Rails PostgreSQL Spring Boot Java MongoDB React Vue.js GraphQL Scala Play Scala Play Scala Play MySQL S3 React → Elm Phoenix Elixir AWS Lambda Cassandra Marco Architecture Micro Architecture React Framework Switch be able to switch frameworks …

Slide 28

Slide 28 text

Frontend Backend Database Spring Boot Java PostgreSQL Spring Boot Java PostgreSQL Wonder.js v1.3 Wonder.js v1.3 Spring Boot Java PostgreSQL Spring Boot Java PostgreSQL Wonder.js v1.3 → v1.4 Wonder.js v1.3 Version Upgrade 1.3 1.4 Page Fragment 1.4 … or upgrade at your own pace.

Slide 29

Slide 29 text

Who works like this?

Slide 30

Slide 30 text

What’s our experience?

Slide 31

Slide 31 text

2 teams
 5-7 people/team 5 teams
 6-10 people/team New e-commerce platforms 5 teams
 6-8 people/team premium material goods print catalogs & 9 stores premium fashion 11 department stores 116 department stores in Germany & Belgium 2014 2016 2016

Slide 32

Slide 32 text

Project: Next Level Commerce 5 teams 7-10 people/team from 3 dev-companies fashion for best ager 15 brands in up to 12 countries ~ 65 online stores green field project after 2 month go-live with a newly created brand taschenherz.com 6 month later first migration of a real brand mona.de 2018

Slide 33

Slide 33 text

3.How to implement?

Slide 34

Slide 34 text

A Page is Owned by one Team 2 33 $ 66 $ 99 $ buy 2 1 66 $ 1 1 list home detail basket payment confirm $ $ %% Team Inspire Team Decide Team Checkout Customer Journey

Slide 35

Slide 35 text

Including Fragments from other Teams Team Decide Team Inspire Team Checkout Fragment Fragment Page

Slide 36

Slide 36 text

Server Side Integration

Slide 37

Slide 37 text

via Links 2 33 $ 66 $ 99 $ buy 2 1 66 $ 1 1 list home detail basket payment confirm $ $ %% Team Inspire Team Decide Team Checkout Customer Journey

Slide 38

Slide 38 text

Team Decide owns the page Team Inspire provides a fragment Team Checkout
 provides two fragments

Slide 39

Slide 39 text

via iframes O RLY? - bad for SEO - load performance - layout constrains - poor accessibility Disadvantages - strong isolation - work everywhere Advantages

Slide 40

Slide 40 text

via iframes Spotify web player (until early 2019) & desktop app https://labs.spotify.com/2019/03/25/building-spotifys-new-web-player/

Slide 41

Slide 41 text

SSI Server Side Includes* *or ESI Edge Side Includes - they have similar taste

Slide 42

Slide 42 text

Google Books 2001 The easiest way to import external content into a Web page is to use a server-side include.

Slide 43

Slide 43 text

Server Side Includes Server Team Decide nginx Server Team Checkout /red-tractor

Tractor

/checkout/basket /checkout/buy /red-tractor buy for 66 € 0 items 0 items

Tractor

buy for 66 €

Slide 44

Slide 44 text

Client Side Integration

Slide 45

Slide 45 text

Team Decide owns the page Team Inspire provides a fragment Team Checkout
 provides two fragments Interactivity

Slide 46

Slide 46 text

Each Fragment as a Mini Application Team Decide Team Inspire Team Checkout Fragment Fragment Page

Slide 47

Slide 47 text

Web Components Custom Elements Shadow DOM HTML Template

Slide 48

Slide 48 text

Custom Elements https://developers.google.com/web/fundamentals/getting-started/primers/customelements

Slide 49

Slide 49 text

class CheckoutBasket extends HTMLElement { connectedCallback() { this.innerHTML = 'mini basket ...';
 }
 }
 customElements.define('checkout-basket', CheckoutBasket); ()) Choo Custom Elements

Slide 50

Slide 50 text

Element Lifecycle class CheckoutBasket extends HTMLElement { constructor() {...}
 connectedCallback() {...}
 attributeChangedCallback(attr, oldVal, newVal) {...}
 disconnectedCallback() {...}
 } is created attached to DOM removed from DOM, cleanup! someone changed an attribute

Slide 51

Slide 51 text

Custom Elements v1
 API stabilized end of 2016 Browser Support in development

Slide 52

Slide 52 text


 https://github.com/webcomponents/custom-elements Browser Support with Polyfill (6KB) 11

Slide 53

Slide 53 text


 
 


Slide 54

Slide 54 text


 
 
 t_green t_green

Slide 55

Slide 55 text

the DOM is the API Teams publish their Custom Elements documentation Element-Name, Attributes, Events

Slide 56

Slide 56 text

Page Transitions

Slide 57

Slide 57 text

Only Inside a Team Team A one router per team Hard Navigation 
 Links Team B /product /list Soft
 Navigation Client Rendered /success /cart Soft
 Navigation Client Rendered

Slide 58

Slide 58 text

Across Teams meta router & router per team /product /list Soft
 Navigation Client Rendered /success /cart Soft
 Navigation Client Rendered Team A Team B App Shell increased complexity! shared runtime code harder debugging Soft Navigation 
 Client Rendered

Slide 59

Slide 59 text

Short Integration Recap Pages Fragments Server Links SSI/ESI Client App-Shell Meta-Router Web Components

Slide 60

Slide 60 text

other Libraries & Meta Frameworks https://github.com/CanopyTax/single-spa https://github.com/zalando/tailor https://github.com/opencomponents/oc Podium https://podium-lib.io meta-spa-router https://github.com/manfredsteyer/meta-router https://github.com/onerzafer/microfe-client

Slide 61

Slide 61 text

4. " nitty gritty details

Slide 62

Slide 62 text

*coherent ux & design

Slide 63

Slide 63 text

Have a Design System Tools: UIengine, Storybook, … Aspects Design Users Experience Performance Accessibility Dev Experience Contents Design Tokens (fonts, colors, …) Usable Components (buttons, …) Design System / Pattern Library

Slide 64

Slide 64 text

Shared Design System Team Inspire Team Decide Team Checkout Distributed as Versioned Package v1.1 v1.2 v1.3 v2-beta ... v2-beta v1.3 v1.1 v1.3 v2-beta v1.3 v1.1

Slide 65

Slide 65 text

+ web performance

Slide 66

Slide 66 text

Performance First measure regularly pick your metrics Tools Lighthouse Sitespeed.io WebpageTest Speedcurve … Metrics Lighthouse Scores Time to Interactive Visually Complete Page Weight …

Slide 67

Slide 67 text

integrate perf into you culture set a budget and enforce it Attribution is not always easy due to fragments & 3rd party. Page-owner is in the lead! Break the build! Discuss alternatives with team and product owner

Slide 68

Slide 68 text

make responsible tech choices large framework runtime hyperapp small runtimes

Slide 69

Slide 69 text

, quality & testing

Slide 70

Slide 70 text

testing in isolation dummy fragment product page works without fragments Team Decide owns & tests majority of the tests

Slide 71

Slide 71 text

testing in isolation header & footer are standalone fragments Team Search owns & tests dummy fragment product page works without fragments Team Decide owns & tests majority of the tests

Slide 72

Slide 72 text

testing accross boundaries cross team tests exist but are the exception Clicking here … In some cases … increments this.

Slide 73

Slide 73 text

- knowledge sharing -

Slide 74

Slide 74 text

regular rituals guildes arch frontend tracking security kubernetes … people from all teams talk on a specific topic mostly weekly

Slide 75

Slide 75 text

vertical depth . / 0 1

Slide 76

Slide 76 text

. / 0 1 How Deep Should a Vertical Team be? Frontend Backend Operations Data Science Business & Stakeholder frontend only scaling development ✔ easier rebuilds ✔ full-stack team faster development ✔ less coordination ✔ full autonomy fast trial of ideas ✔ 
 adapt quickly ✔ and these and these

Slide 77

Slide 77 text

Want to learn more? Extensive Link Collection by Elisabeth Engel @_lizzelo_ micro-frontends.org by Me @naltatis Self-Contained Systems by INNOQ Microservice Websites by Gustav Nilsson Kotte @gustaf_nk Talk: Frontend Monolith by Stefan Tilkov @stilkov Micro Frontends at DAZN by Luca Mezzalira @lucamezzalira 2

Slide 78

Slide 78 text

I’m writing a book MEAP - Manning Early Access Program this summer M A N N I N G Michael Geers follow @naltatis or @manningbooks for updates

Slide 79

Slide 79 text

Backend Frontend lets’ blur this line!

Slide 80

Slide 80 text

Backend Frontend let’s blur this line!

Slide 81

Slide 81 text

happyend Michael Geers @naltatis ! Thanks for listening!

Slide 82

Slide 82 text

Burano Pixaline
 https://pixabay.com/images/id-2522251/ Black Diamond (me) Holiday Snap 2: Tron Apionid
 https://flic.kr/p/r23SxR Drummers skeeze
 https://pixabay.com/images/id-642540/ Tocotronic Stefan Müller
 https://flic.kr/p/JCTQXd People Icons freepik
 https://www.flaticon.com/family/special/lineal-color Action Bicycling Roman Pohorecki
 https://www.pexels.com/photo/action-bicycling-bike- biking-287398/ Wooden Counter David Siglin
 https://www.pexels.com/photo/blur-blurry-bokeh-close- up-347139/ The Tool Guy Tirachard Kumtanom
 https://unsplash.com/photos/UuW4psOb388 Woodshop Igor Ovsyannykov
 https://unsplash.com/photos/iXV0i4Wo4yc HP C7000 BladeSystem pchow98
 https://flic.kr/p/7AVF23 Close up Susanne Nilsson
 https://flic.kr/p/nppBcE Unicorn d97jro
 https://pixabay.com/images/id-671593/ Browser Logos Cătălin Mariș
 https://github.com/alrra/browser-logos Lego Benny Cheezburger
 http://gph.is/1BCRCKh Tractors Manufactum
 https://www.manufactum.com/tin-toys-c193667/ Credits built with Micro Frontends