Slide 1

Slide 1 text

Micro Frontends University of São Paulo USPCodeLab 1. July 2021 Michael Geers

Slide 2

Slide 2 text

Breaking up the Monolith

Slide 3

Slide 3 text

Ne w Tren d presented by The Frontend Monolith

Slide 4

Slide 4 text

popular architectures nowadays Michael Geers / @naltatis

Slide 5

Slide 5 text

Micro Frontends

Slide 6

Slide 6 text

Michael Geers frontend engineer naltatis Twitter & GitHub author of the book Micro Frontends in Action and the website micro-frontends.org building tailored e-commerce systems

Slide 7

Slide 7 text

The Agenda 🧙 What? 🧚 Why? 👩🏭 How? 🤹 Related Stuff

Slide 8

Slide 8 text

🧙 What are micro frontends?

Slide 9

Slide 9 text

Nov. 2016 2017 2019 source: ThoughtWorks Technology Radar

Slide 10

Slide 10 text

A De fi nition 1/3 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. … source: ThoughtWorks Technology Radar Michael Geers / @naltatis

Slide 11

Slide 11 text

A De fi nition 1/3 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. … source: ThoughtWorks Technology Radar Michael Geers / @naltatis

Slide 12

Slide 12 text

cutting

Slide 13

Slide 13 text

pages & fragments* * aka includable Micro Frontends, Podlets, Parcels, Pilets, … Michael Geers / @naltatis

Slide 14

Slide 14 text

teams can own one or more pages 2 33 $ 66 $ 99 $ buy 2 1 66 $ 1 1 list home detail basket payment confirm $ $ %% Team Inspire Team Decide Team Checkout Customer Journey Michael Geers / @naltatis

Slide 15

Slide 15 text

Team Decide Team Inspire Team Checkout Fragment Fragment Page fragments are embedded mini-applications Michael Geers / @naltatis

Slide 16

Slide 16 text

A De fi nition 2/3 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. … source: ThoughtWorks Technology Radar Michael Geers / @naltatis

Slide 17

Slide 17 text

Team Missions Michael Geers / @naltatis

Slide 18

Slide 18 text

Cross Functional Teams ux/design, frontend backend, data science, ops Self-Contained Systems separate applications that don’t rely on each other End-to-End Responsibility from user interface to database Independent Teams & Systems Michael Geers / @naltatis like a chunky microserivce, but with its own UI

Slide 19

Slide 19 text

stream-aligned teams book recommendation about structuring your organisation’s teams & systems Michael Geers / @naltatis

Slide 20

Slide 20 text

each team ships user interface Michael Geers / @naltatis

Slide 21

Slide 21 text

A De fi nition 3/3 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. … source: ThoughtWorks Technology Radar Michael Geers / @naltatis

Slide 22

Slide 22 text

Independent Deployments Michael Geers / @naltatis

Slide 23

Slide 23 text

Real World Projects

Slide 24

Slide 24 text

Klingel Group 5 teams from 4 software companies 
 15 brands, 12 countries, ~65 shops

Slide 25

Slide 25 text

Team Search category page Team Checkout mini basket Team Decide wishlist Team Account login status 
 feedback 
 support Team Inspire promotion 
 inspiration Michael Geers / @naltatis

Slide 26

Slide 26 text

Team Search navigation Team Checkout mini basket Team Decide wishlist product page Team Account login status 
 feedback 
 support Team Inspire promotion Michael Geers @naltatis

Slide 27

Slide 27 text

Team Checkout new basket entry Team Decide add-to-cart layer Team Inspire recommendations

Slide 28

Slide 28 text

Team Checkout login page Team Inspire recommendations Team Account feedback 
 support Michael Geers / @naltatis

Slide 29

Slide 29 text

PayPal

Slide 30

Slide 30 text

PayPal Egnineering Blog PayPal Michael Geers / @naltatis

Slide 31

Slide 31 text

Who uses micro frontends? logos link to the sources Michael Geers / @naltatis

Slide 32

Slide 32 text

👩🏭 How can they be implemented?

Slide 33

Slide 33 text

putting it back together

Slide 34

Slide 34 text

What needs to be integrated? Michael Geers / @naltatis

Slide 35

Slide 35 text

Spotify web player (until early 2019) & Desktop App https://labs.spotify.com/2019/03/25/building-spotifys-new-web-player/ composition with iframes Michael Geers / @naltatis

Slide 36

Slide 36 text

buy for 66 € 0 items 0 items

Tractor

buy for 66 € server Team Decide reverse-proxy (nginx, …) server Team Checkout /red-tractor

Tractor

/checkout/basket /checkout/buy /red-tractor composition on the server 
 using SSI or ESI

Slide 37

Slide 37 text


 
 
 composition in the browser with custom elements Michael Geers / @naltatis

Slide 38

Slide 38 text

class InspireReco extends HTMLElement { constructor() {...} 
 connectedCallback() {...} 
 attributeChangedCallback(attr, oldVal, newVal) {...} 
 disconnectedCallback() {...} 
 } window.customElements.define(“inspire-reco“, InspireReco) is created attached to DOM removed from DOM, cleanup! someone changed an attribute create your own custom element

Slide 39

Slide 39 text

2 33 $ 66 $ 99 $ buy 2 1 66 $ 1 1 list home detail basket payment confirm $ $ %% Team Inspire Team Decide Team Checkout Customer Journey page transitions using links Michael Geers / @naltatis

Slide 40

Slide 40 text

Linked Single Page Apps Uni fi ed Single Page App page transitions between SPAs Michael Geers / @naltatis

Slide 41

Slide 41 text

jobs of the application shell? ‣ central entry point for the user ‣ can load, start and stop all SPAs ‣ switches between SPAs if necessary Michael Geers / @naltatis

Slide 42

Slide 42 text

single-spa https://single-spa.js.org/ ‣ ready-to-use application shell ‣ most popular solution ‣ plugins for nearly all frameworks ‣ also supports composition Michael Geers / @naltatis

Slide 43

Slide 43 text

different forms of communication Michael Geers / @naltatis

Slide 44

Slide 44 text

API communication only inside a system Michael Geers / @naltatis

Slide 45

Slide 45 text

Michael Geers / @naltatis asynchronous replication between backends

Slide 46

Slide 46 text

🧚Why would I use micro frontends?

Slide 47

Slide 47 text

🥇 faster feature development …

Slide 48

Slide 48 text

three 8-person teams are more effective than one 24-person team Michael Geers / @naltatis

Slide 49

Slide 49 text

teams should be decoupled

Slide 50

Slide 50 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 Michael Geers / @naltatis

Slide 51

Slide 51 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 Features Meeting s waiting for others ⏳ Michael Geers / @naltatis

Slide 52

Slide 52 text

custome r focu s direct feedback no pure API teams

Slide 53

Slide 53 text

fronten d renovatio n without throwing everything away

Slide 54

Slide 54 text

technology change becomes a team decision Michael Geers / @naltatis

Slide 55

Slide 55 text

🤹 related stuff

Slide 56

Slide 56 text

avoid micro frontend anarchy 
 just because you can, doesn’t mean you should 🧀 🍩 🫐 🥦 🌶 🥓 🍆 🍟 🍊 🥖 Technology Radar #23 ‣ agree upon technologies ‣ make it easy to get started ‣ facilitate alignment across teams ‣ don’t over-regulate Michael Geers / @naltatis

Slide 57

Slide 57 text

🐌 performance

Slide 58

Slide 58 text

🚴 micro frontend sites can be very fast or slow - it’s mostly about good engineering all using a 
 micro frontends 
 architecture source: Textil Wirtschaft Analyses of loading performance (LCP) in German fashion e-commerce shops

Slide 59

Slide 59 text

🐘 🐘 🐘 reducing redundancy

Slide 60

Slide 60 text

smaller tools mean less redundancy larger runtime hyperapp small runtime 🐘 🦆 Michael Geers / @naltatis

Slide 61

Slide 61 text

reusing vendor libraries between systems with import maps with module federation A B C central library repository lib-1 lib-2 A B C lib-1 lib-2 peer-to-peer approach applications can reuse already loaded libraries from inside other applications applications can reference central libraries to reduce their bundle size ♻ https://github.com/systemjs/systemjs/blob/master/docs/import-maps.md https://module-federation.github.io

Slide 62

Slide 62 text

🧫 testing & quality

Slide 63

Slide 63 text

testing in isolation fragments are self-contained they can work without a page context mock fragment this page works even without fragments from others majority of tests

Slide 64

Slide 64 text

more details on how to do it M A N N I N G Michael Geers Michael Geers / @naltatis my book

Slide 65

Slide 65 text

book examples the-tractor.store

Slide 66

Slide 66 text

need more? micro-frontends.org article by Cam Jackson article by Gustaf Nilsson Kotte 
 blogposts by Florian Rappl blogposts by Luca Mezzalira 👓 awesomelist by Rajasegar Chandran Michael Geers / @naltatis

Slide 67

Slide 67 text

thank you for listening! stay healthy Michael Geers / @naltatis

Slide 68

Slide 68 text

Low Top Turnschuhe Natã Romualdo 
 https://www.pexels.com/de-de/foto/braune-low-top- turnschuhe-2904284/ Monolith 1 Jeff Hendricks 
 https://unsplash.com/photos/yIKdc86jNBs Monolith 2 Rana Osman 
 https://unsplash.com/photos/JcSsu-NF3qo Buildings Juhasz Imre 
 https://www.pexels.com/photo/apartment-architecture- buildings-business-425047/ Metal Blade Russ Ward 
 https://unsplash.com/photos/aMlbxs8SYig Man Welding Metal Kateryna Babaieva 
 https://www.pexels.com/photo/man-welding- metal-2880871/ Action Bicycling Roman Pohorecki 
 https://www.pexels.com/photo/action-bicycling-bike- biking-287398/ Running Kids (me) The Tool Guy Tirachard Kumtanom 
 https://unsplash.com/photos/UuW4psOb388 Woodshop Igor Ovsyannykov 
 https://unsplash.com/photos/iXV0i4Wo4yc Tractors Manufactum 
 https://www.manufactum.com/tin-toys-c193667/ image credits built with micro frontends