{"id":39847,"date":"2020-08-25T00:25:13","date_gmt":"2020-08-25T07:25:13","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/premier-developer\/?p=39847"},"modified":"2020-08-25T07:52:37","modified_gmt":"2020-08-25T14:52:37","slug":"scaling-user-experiences-with-micro-frontends","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/premier-developer\/scaling-user-experiences-with-micro-frontends\/","title":{"rendered":"Scaling User experiences with Micro frontends"},"content":{"rendered":"<p><!--StartFragment --><\/p>\n<p class=\"pf0\"><span class=\"cf0\"><a href=\"https:\/\/www.linkedin.com\/in\/slobodanstipic\/\">Slobo Stipic<\/a> is a Senior Software Engineer building cross platform and cross canvas controls with our Windows Experience group.<\/span><\/p>\n<hr \/>\n<div id=\"MainContent\">\n<p id=\"pragma-line-2\">Users expect software to be approachable and familiar on any device they use. Modern user experiences are cross platform spanning the web, apps, and operating systems putting users in the center.<\/p>\n<p id=\"pragma-line-4\"><img decoding=\"async\" class=\"alignnone size-full wp-image-39848\" src=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/08\/center.png\" alt=\"Image center\" width=\"522\" height=\"489\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/08\/center.png 522w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/08\/center-300x281.png 300w\" sizes=\"(max-width: 522px) 100vw, 522px\" \/><\/p>\n<p id=\"pragma-line-6\">Naturally, this increases the system complexity challenging the traditional monolithic software architecture and horizontal engineering organizational structure.\nA proven engineering approach of tackling complexity is decomposition into more granular and comprehensible parts. This has proven successful in breaking down large backend services into many smaller single purpose-built micro services. As we extend this pattern up the stack to frontend, we enter the world of Micro frontends. In their simplest form, they consist of UX which enables user interaction and a backend service that supports the UX controls. Canonical example is a shopping cart found on the web, Windows Store and Xbox apps. Another familiar example is a login screen in Windows Settings, Outlook iOS, and others. Despite their diverse functionality all Micro frontends are characterized by common traits:<\/p>\n<ul id=\"pragma-line-9\">\n<li id=\"pragma-line-9\">UX coherence &#8211; look and feel is familiar and consistent across UX canvases (web, apps, operating systems)<\/li>\n<li id=\"pragma-line-10\">Deployed independently of the host UX canvas<\/li>\n<li id=\"pragma-line-11\">Service driven or service delivered<\/li>\n<li id=\"pragma-line-12\">Owned by a single engineering + business team across UX canvases<\/li>\n<\/ul>\n<p id=\"pragma-line-14\">Micro frontends are appealing architecture pattern because of the benefits they provide to users, engineering, and business organizations.<\/p>\n<table id=\"pragma-line-16\">\n<thead>\n<tr id=\"pragma-line-16\">\n<th id=\"pragma-line-16\">User<\/th>\n<th id=\"pragma-line-16\">Engineering<\/th>\n<th id=\"pragma-line-16\">Business<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr id=\"pragma-line-18\">\n<td id=\"pragma-line-18\">Familiar user experience<\/td>\n<td id=\"pragma-line-18\">Engineering agility<\/td>\n<td id=\"pragma-line-18\">Experimentation across UX canvases<\/td>\n<\/tr>\n<tr id=\"pragma-line-19\">\n<td id=\"pragma-line-19\">Cohesive look and feel across UX canvases<\/td>\n<td id=\"pragma-line-19\">Controlled feature rollout across UX canvases<\/td>\n<td id=\"pragma-line-19\">Faster time to market<\/td>\n<\/tr>\n<tr id=\"pragma-line-20\">\n<td id=\"pragma-line-20\">Higher perceived quality<\/td>\n<td id=\"pragma-line-20\">Engineering efficiency through code reuse<\/td>\n<td id=\"pragma-line-20\">Faster response to user feedback<\/td>\n<\/tr>\n<tr id=\"pragma-line-21\">\n<td id=\"pragma-line-21\"><\/td>\n<td id=\"pragma-line-21\">Security, compliance, and dependency management<\/td>\n<td id=\"pragma-line-21\">Cost saving<\/td>\n<\/tr>\n<tr id=\"pragma-line-22\">\n<td id=\"pragma-line-22\"><\/td>\n<td id=\"pragma-line-22\">Localization, globalization, accessibility<\/td>\n<td id=\"pragma-line-22\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 id=\"micro-frontend-architecture\">Micro frontend architecture<\/h2>\n<p id=\"pragma-line-26\">In Windows Experiences group we are betting and investing into Micro frontend architecture to scale UX across web, apps , and operating systems. Each Micro frontend provides a specific value to the user. Due to its narrow scope its design is lightweight consisting of four core components:<\/p>\n<ul id=\"pragma-line-28\">\n<li id=\"pragma-line-28\">UX controls<\/li>\n<li id=\"pragma-line-29\">Backend for frontend microservice (BFF)<\/li>\n<li id=\"pragma-line-30\">Telemetry event collector (TEC)<\/li>\n<li id=\"pragma-line-31\">Deployment service<\/li>\n<\/ul>\n<p id=\"pragma-line-33\"><img decoding=\"async\" class=\"alignnone size-full wp-image-39849\" src=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/08\/arch.png\" alt=\"Image arch\" width=\"669\" height=\"465\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/08\/arch.png 669w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/08\/arch-300x209.png 300w\" sizes=\"(max-width: 669px) 100vw, 669px\" \/><\/p>\n<h3 id=\"ux-controls\">UX Controls<\/h3>\n<p id=\"pragma-line-37\">UX controls residing inside UX\/frontend layer pictured above target various platforms and devices. They can be implemented on the same or different tech stacks while maximizing code reuse without compromising user experience. For instance, our Family Safety app written in Kotlin (Android) and Swift (iOS) has a Micro frontend that lets users to invite their family members to join the family. We call it Family Onboarding. The same feature is also available on the web at account.microsoft.com\/family and in Windows Settings. To provide the best native-like user experience we use React Native on mobile apps, but ReactJS on the web and Windows Settings. React Native and ReactJS controls are thin layers with minimal platform specific code. Due their similarity we can decouple non-React platform code into a Shared Core library.<\/p>\n<p id=\"pragma-line-39\"><img decoding=\"async\" class=\"alignnone size-full wp-image-39850\" src=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/08\/ux-high-level.png\" alt=\"Image ux high level\" width=\"372\" height=\"338\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/08\/ux-high-level.png 372w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/08\/ux-high-level-300x273.png 300w\" sizes=\"(max-width: 372px) 100vw, 372px\" \/><\/p>\n<p id=\"pragma-line-41\">This hits the sweet spot between engineering efficiency and delightful user experience on each platform. It is through Shared Core the UX layer interacts with external services such as Telemetry event collector, deployment service, and Backend for frontend (BFF) microservice.<\/p>\n<h3 id=\"backend-for-frontend\">Backend for frontend<\/h3>\n<p id=\"pragma-line-46\">BFF is specifically designed to serve Family Onboarding UX controls only. It provides many benefits:<\/p>\n<ul id=\"pragma-line-48\">\n<li id=\"pragma-line-48\">Encapsulates business logic that does not have to live in UX controls so it can be shared and updated at the cloud pace.<\/li>\n<li id=\"pragma-line-49\">Abstracts dependency API nuances such as authentication, authorization, multiple API versions\/changes, error handling, firewall, caching, throttling, etc.<\/li>\n<li id=\"pragma-line-50\">Single consistent API surface UX controls can rely on.<\/li>\n<li id=\"pragma-line-51\">Serves static assets text, images, fonts, etc.<\/li>\n<li id=\"pragma-line-52\">Encapsulates localization<\/li>\n<li id=\"pragma-line-53\">Flight backend changes and provides flights to UX Controls.<\/li>\n<\/ul>\n<p id=\"pragma-line-55\"><img decoding=\"async\" class=\"alignnone size-full wp-image-39851\" src=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/08\/bff.png\" alt=\"Image bff\" width=\"1037\" height=\"588\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/08\/bff.png 1037w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/08\/bff-300x170.png 300w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/08\/bff-1024x581.png 1024w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/08\/bff-768x435.png 768w\" sizes=\"(max-width: 1037px) 100vw, 1037px\" \/><\/p>\n<h3 id=\"telemetry-event-collector\">Telemetry event collector<\/h3>\n<p id=\"pragma-line-59\">Even though Telemetry Event Collector (TEC) is shared between dependency services and Family Onboarding Micro frontend. BFF and UX Controls alike produce telemetry events for quality of service (QoS) and business intelligence (BI) sending them to centralized TEC. Regardless of the event source, they all contain correlation vectors enabling us to correlate events and build user journeys. This is critical to understanding the Micro frontend quality and informing incident response.<\/p>\n<h3 id=\"deployment-service\">Deployment service<\/h3>\n<p id=\"pragma-line-63\">Ability to deploy new bits independently of the host canvas is a major benefit of Micro frontend architecture. Like TEC, the Deployment service can also be shared with other services. Sometimes there may be a need for more than one service depending on the target host tech stack. Family Safety app is going to use CodePush service to update React Native UX controls on Android and iPhone. Since CodePush does not support ReactJS we opted into extending BFF to serve Family Onboarding Single Page Application to Windows Settings and account.microsoft.com\/family.<\/p>\n<h2 id=\"summary\">Summary<\/h2>\n<p id=\"pragma-line-67\">As we look to the future, we see many more Micro frontends coming to Family Safety app. Our ambitions go beyond a single app. Our hope is for all appropriate future Microsoft experiences to consider Micro frontend architecture pattern.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Users expect software to be approachable and familiar on any device they use. Modern user experiences are cross platform spanning the web, apps, and operating systems putting users in the center.<\/p>\n","protected":false},"author":582,"featured_media":39850,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[4354],"tags":[51,77,62,6395,372],"class_list":["post-39847","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ux","tag-angular","tag-architecture","tag-microservices","tag-react-native","tag-user-experience"],"acf":[],"blog_post_summary":"<p>Users expect software to be approachable and familiar on any device they use. Modern user experiences are cross platform spanning the web, apps, and operating systems putting users in the center.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/39847","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/users\/582"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/comments?post=39847"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/39847\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media\/39850"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media?parent=39847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/categories?post=39847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/tags?post=39847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}