SlideShare a Scribd company logo
Technology agnostic
microservices at SPA frontend
Vladlen Fedosov, Director of R&D @Namecheap, Inc
Mmm... Listen talk or check Instagram? 🤔
● What are microservices at Frontend and why you need to be aware?
● Possible approaches overview. Pros/Cons
● Working solution overview
● Extra tips & tricks from our experience
Vlad Fedosov
Director of R&D @Namecheap
TL;DR:
● 10 years in the industry
● Went path from Junior to Architect
● Use JS since Mootools era
● Amateur DevOps evangelist
● AWS ninja
● Believe in self-organized, cross-functional teams
“Opening the door for everyone to
a free and open Internet”
Do we have an issue here?
Problem statement...
What are Microservices?
Microservices - also known as the microservice architecture - is an architectural
style that structures an application as a collection of services that are
● Highly maintainable and testable
● Loosely coupled
● Independently deployable
● Organized around business capabilities
● Owned by a small team
What are Microservices?
Ok, got it! But what about
frontend?
JSFest 2019: Technology agnostic microservices at SPA frontend
Meet “Micro Frontends”
In short: they are Microservices architecture that was adopted for UI needs
To be more specific:
Think about web app as a composition of features which are owned by
independent teams. Each team has a distinct area of business or mission it cares
about and specialises in. A team is cross functional and develops its features
end-to-end, from database to user interface.
JSFest 2019: Technology agnostic microservices at SPA frontend
What are Micro Frontends?
Do I need Micro Fragments in my project?
No, unless:
● You have several cross-functional teams working on the same frontend app.
And they want:
○ Independent development lifecycle
○ Independent releases
○ Calm sleep at night w/o a chance of their functionality being broken by other team’s release
● You’re working on a huge enterprise app and want to get out of the golden
cage of your outdated framework.
● Bring your own case 🙋‍♂
Page (re-)composition
JSFest 2019: Technology agnostic microservices at SPA frontend
What is page composition?
Fragment 1
Fragment 2
Fragment 3
Layout
What is page composition?
Fragment 1
Fragment 2
Fragment 3
First request,
composition may
happen at
client/server side
What is page re-composition?
Different app
was loaded
State
change
2nd request,
re-composition at
client/server side
What are the options we have?
Available approaches
1. Support 1 framework, break code onto NPM modules (static/lazy loading)
2. Support multiple frameworks and
a. compose page at server side
b. compose page at client side
c. compose page at server & client side
JSFest 2019: Technology agnostic microservices at SPA frontend
Available approaches
Approach / Criteria Technology
agnostic
Code isolation SEO/SM-bots
compatible (SSR)
UX Level
1 Framework, NPM
modules
❌ Limited ✅ ✅
X Frameworks,
client side composition
✅ ✅ ❌ Limited
(longer initial load)
X Frameworks,
server side composition
✅ ✅ ✅ Limited (need to reload
page for re-composition)
X Frameworks,
isomorphic composition
✅ ✅ ✅ ✅
Let’s see what we have in
production nowadays
Our next-gen solution overview:
“Isomorphic Layout Composer”
⚠ DEMO TIME ⚠
Core technologies we used
Zalando Tailor
single-spa - JS framework for Micro Frontends
We need to go deeper...
Challenges we faced with
● Page composition & re-composition
● Routing & page transition
● Micro Frontends registry
● Dynamic code loading & updating
● SSR support
● Error reporting
● Cross-fragment communication
● Code isolation
● Guardrails
Overall architecture - System (high level)
Registry
Client Server
Router
Layout composer
(Tailor)
MS 1
MS 2
MS X
UI composition layer
(single-spa)
Template
engine
Overall architecture - Micro Frontend
App
Shared
Code
client.js
mount()
unmount()
server.js
config ←
Business logic
Client side bundle
Server bundle
Assets
Server runner
Server API
CDN
Challenges - Code Isolation
Simple rules for micro-frontend developers:
● No “window” modification, no global variables
● No DOM modifications outside assigned container
● No shared CSS, apps use Scoped CSS only
● No shared state, apps can communicate only via events
Real experience: we banned Angular as it was patching “window” & had issues if
you’re running 2+ Angular apps on the same page
Challenges - Page composition
<html>
<head>
...
</head>
<body>
<slot name="navbar"></slot>
<slot name="body"></slot>
<slot name="footer"></slot>
</body>
</html>
Challenges - Registry
Holds info about:
● Apps
● Routes
● Templates
apps: {
"@portal/news": {
spaBundle: "http://127.0.0.1:3000/dist/single_spa.js",
cssBundle: "http://127.0.0.1:3000/dist/21f11a2afc03af3d62f8.css",
ssr: { // Optional. If omitted - no rendering will be done at the server side
src: "http://localhost:3000/news/?fragment=1",
},
},
},
templates: { master: "master.template.html" },
routes: [ // Express like routes, matched in order of appearance
{
route: "/news/*",
template: "master",
slots: {
navbar: { appName: "@portal/navbar" },
body: { appName: "@portal/news" },
}
}
]
Challenges - Routing & page transition
/news/latest
Global Router: /news/*
App Router: /latest
/latest
Rule: MF App is aware about it’s own routes only.
Implementation: 2-tiered router
Challenges - Routing & page transition
But how app A can perform transition to the view within app B?
It’s simple - use built in capabilities of your framework. Nothing changes.
1. User clicks link
2. App A framework invokes history.pushState()
3. ILC listens for 'hashchange', 'popstate' & “<a>” click events
4. ILC checks if any changes to the set of the apps visible on a page needed
5. ILC performs unmounting of the old apps & mounts new ones
Challenges - Dynamic code loading
Solution of choice: SystemJS , every App should be built as AMD/SystemJS
bundle & registered in the registry.
It will be loaded as soon as it will be requested by the Global Router or as explicit
dependency in code:
● Webpack “externals”
● System.import('react')
<script type="systemjs-importmap">
{
"imports": {
"@portal/news":"http://127.0.0.1:3000/index.js",
"react": "https://cdnjs.cloudflare.com/.../index.js"
}
}
</script>
Few more advanced things...
Deploy/Rollback
We have two challenges here:
● Notify ILC about new versions of our fragments
● Synchronize versions of the code at server (SSR) & client (Browser)
But how can we solve them?
Deploy/Rollback - Notification
● Make API call to the Registry after deployment to CDN but before server
update
● Use version discovery mechanism. Example:
○ Keep metadata file at CDN with disabled HTTP cache & update it after deploy.
{
"spaBundle": "https://my-cdn.com/app-name/main.c02de4198cc732e5797a.js",
"cssBundle": "https://my-cdn.com/app-name/main.c02de4198cc732e5797a.css",
"dependencies": {
"react": "https://my-cdn.com/app-name/react.v16.0.1.js"
}
}
Deploy/Rollback - Synchronize versions
Registry
App 1: v2
ILC
App 1: v2
ILC
App 1: v1
App server
v1
App server
v2
Not all ILC instances are in
sync with Registry
App deployment in progress...
Special response header:
x-bundle-overrides
Error reporting
1. Use framework built-in capabilities, ILC listens at framework error handlers
2. Be prepared for the worst case scenario:
window.addEventListener('error', function(event) {
const moduleInfo = SystemJS.getModuleInfo(event.filename); // <---
if (moduleInfo === null) {
return;
}
event.preventDefault();
console.error( … );
newrelic.noticeError( … ); // Track errors centrally
});
Cross-fragment communication
There are 3 main options:
● Browser events.
● Shared services.
● Shared state. This solution doesn’t impose or restrict shared state between
Micro-Frontends. Bring your own if you need it.
Further improvements
● Integration of the Tailor & single-spa under single tool with unified
client/server API
● Template transition handling
● LDE improvements for our engineers
● Automated tests
● Documentation, documentation, documentation...
● Built-in monitoring
● Fragment inside fragment (parcels)
Vlad Fedosov
Director of R&D
@Namecheap, Inc
vlad.fedosov@gmail.com
Slides:
Or just scan it:
bit.ly/2BRrn8V
Source
code:
github.com/StyleT/icl
Ad

More Related Content

What's hot (20)

Web Components and PWA
Web Components and PWAWeb Components and PWA
Web Components and PWA
Manuel Carrasco Moñino
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.js
TechMagic
 
React js, node js &amp; angular js which one is the best for web development
React js, node js &amp; angular js  which one is the best for web development React js, node js &amp; angular js  which one is the best for web development
React js, node js &amp; angular js which one is the best for web development
Concetto Labs
 
Top java script frameworks ppt
Top java script frameworks pptTop java script frameworks ppt
Top java script frameworks ppt
Omkarsoft Bangalore
 
Setup ColdFusion application using fusebox mvc architecture
Setup ColdFusion application using fusebox mvc architectureSetup ColdFusion application using fusebox mvc architecture
Setup ColdFusion application using fusebox mvc architecture
Mindfire Solutions
 
AngularJS + React
AngularJS + ReactAngularJS + React
AngularJS + React
justvamp
 
Arkhitech - who we are and what we do
Arkhitech - who we are and what we doArkhitech - who we are and what we do
Arkhitech - who we are and what we do
Simobo
 
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Angular 1.x reloaded:  improve your app now! and get ready for 2.0Angular 1.x reloaded:  improve your app now! and get ready for 2.0
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Carlo Bonamico
 
Refactoring to a Single Page Application
Refactoring to a Single Page ApplicationRefactoring to a Single Page Application
Refactoring to a Single Page Application
Codemotion
 
Mvvm knockout vs angular
Mvvm knockout vs angularMvvm knockout vs angular
Mvvm knockout vs angular
Basarat Syed
 
Gwt ppt
Gwt pptGwt ppt
Gwt ppt
Monica Bubna
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
Go4Guru
 
9 Useful Things that Every Web Developer Needs to Know
9 Useful Things that Every Web Developer Needs to Know9 Useful Things that Every Web Developer Needs to Know
9 Useful Things that Every Web Developer Needs to Know
Simobo
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
Talentica Software
 
PWA basics for developers
PWA basics for developersPWA basics for developers
PWA basics for developers
Filip Rakowski
 
A Good PHP Framework For Beginners Like Me!
A Good PHP Framework For Beginners Like Me!A Good PHP Framework For Beginners Like Me!
A Good PHP Framework For Beginners Like Me!
Muhammad Ghazali
 
Angular 2 vs React
Angular 2 vs ReactAngular 2 vs React
Angular 2 vs React
Iran Reyes Fleitas
 
Frontend microservices: architectures and solutions
Frontend microservices: architectures and solutionsFrontend microservices: architectures and solutions
Frontend microservices: architectures and solutions
Mikhail Kuznetcov
 
ReactJS or Angular
ReactJS or AngularReactJS or Angular
ReactJS or Angular
boyney123
 
Overview of React.JS - Internship Presentation - Week 5
Overview of React.JS - Internship Presentation - Week 5Overview of React.JS - Internship Presentation - Week 5
Overview of React.JS - Internship Presentation - Week 5
Devang Garach
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.js
TechMagic
 
React js, node js &amp; angular js which one is the best for web development
React js, node js &amp; angular js  which one is the best for web development React js, node js &amp; angular js  which one is the best for web development
React js, node js &amp; angular js which one is the best for web development
Concetto Labs
 
Setup ColdFusion application using fusebox mvc architecture
Setup ColdFusion application using fusebox mvc architectureSetup ColdFusion application using fusebox mvc architecture
Setup ColdFusion application using fusebox mvc architecture
Mindfire Solutions
 
AngularJS + React
AngularJS + ReactAngularJS + React
AngularJS + React
justvamp
 
Arkhitech - who we are and what we do
Arkhitech - who we are and what we doArkhitech - who we are and what we do
Arkhitech - who we are and what we do
Simobo
 
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Angular 1.x reloaded:  improve your app now! and get ready for 2.0Angular 1.x reloaded:  improve your app now! and get ready for 2.0
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Carlo Bonamico
 
Refactoring to a Single Page Application
Refactoring to a Single Page ApplicationRefactoring to a Single Page Application
Refactoring to a Single Page Application
Codemotion
 
Mvvm knockout vs angular
Mvvm knockout vs angularMvvm knockout vs angular
Mvvm knockout vs angular
Basarat Syed
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
Go4Guru
 
9 Useful Things that Every Web Developer Needs to Know
9 Useful Things that Every Web Developer Needs to Know9 Useful Things that Every Web Developer Needs to Know
9 Useful Things that Every Web Developer Needs to Know
Simobo
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
Talentica Software
 
PWA basics for developers
PWA basics for developersPWA basics for developers
PWA basics for developers
Filip Rakowski
 
A Good PHP Framework For Beginners Like Me!
A Good PHP Framework For Beginners Like Me!A Good PHP Framework For Beginners Like Me!
A Good PHP Framework For Beginners Like Me!
Muhammad Ghazali
 
Frontend microservices: architectures and solutions
Frontend microservices: architectures and solutionsFrontend microservices: architectures and solutions
Frontend microservices: architectures and solutions
Mikhail Kuznetcov
 
ReactJS or Angular
ReactJS or AngularReactJS or Angular
ReactJS or Angular
boyney123
 
Overview of React.JS - Internship Presentation - Week 5
Overview of React.JS - Internship Presentation - Week 5Overview of React.JS - Internship Presentation - Week 5
Overview of React.JS - Internship Presentation - Week 5
Devang Garach
 

Similar to JSFest 2019: Technology agnostic microservices at SPA frontend (20)

Dust.js
Dust.jsDust.js
Dust.js
Yevgeniy Brikman
 
Developing high performance and responsive web apps using web worker
Developing high performance and responsive web apps using web workerDeveloping high performance and responsive web apps using web worker
Developing high performance and responsive web apps using web worker
Suresh Patidar
 
Angular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - LinagoraAngular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - Linagora
LINAGORA
 
AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)
Alex Ross
 
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"
Fwdays
 
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
David Amend
 
KiranGara_JEE_7Yrs
KiranGara_JEE_7YrsKiranGara_JEE_7Yrs
KiranGara_JEE_7Yrs
Kiran Gara
 
micro-frontends-with-vuejs
micro-frontends-with-vuejsmicro-frontends-with-vuejs
micro-frontends-with-vuejs
Oleksandr Tserkovnyi
 
Django simplified : by weever mbakaya
Django simplified : by weever mbakayaDjango simplified : by weever mbakaya
Django simplified : by weever mbakaya
Mbakaya Kwatukha
 
Treinamento frontend
Treinamento frontendTreinamento frontend
Treinamento frontend
Adrian Caetano
 
Vue Storefront - Progressive Web App for Magento (1.9, 2.x) - MM18DE speech
Vue Storefront - Progressive Web App for Magento (1.9, 2.x) - MM18DE speechVue Storefront - Progressive Web App for Magento (1.9, 2.x) - MM18DE speech
Vue Storefront - Progressive Web App for Magento (1.9, 2.x) - MM18DE speech
Divante
 
The Importance Things of Full Stack Development
The Importance Things of Full Stack DevelopmentThe Importance Things of Full Stack Development
The Importance Things of Full Stack Development
Mike Taylor
 
Web worker in your angular application
Web worker in your angular applicationWeb worker in your angular application
Web worker in your angular application
Suresh Patidar
 
Subhajit_Das_Resume_(M)2016
Subhajit_Das_Resume_(M)2016Subhajit_Das_Resume_(M)2016
Subhajit_Das_Resume_(M)2016
Subhajit Das
 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web App
Edureka!
 
Lagom : Reactive microservice framework
Lagom : Reactive microservice frameworkLagom : Reactive microservice framework
Lagom : Reactive microservice framework
Fabrice Sznajderman
 
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
Codemotion
 
Real World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVCReal World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVC
Carlo Bonamico
 
Catching-up web technologies - an endless story
Catching-up web technologies - an endless storyCatching-up web technologies - an endless story
Catching-up web technologies - an endless story
Cleber Jorge Amaral
 
Web summit.pptx
Web summit.pptxWeb summit.pptx
Web summit.pptx
171SagnikRoy
 
Developing high performance and responsive web apps using web worker
Developing high performance and responsive web apps using web workerDeveloping high performance and responsive web apps using web worker
Developing high performance and responsive web apps using web worker
Suresh Patidar
 
Angular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - LinagoraAngular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - Linagora
LINAGORA
 
AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)
Alex Ross
 
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"
Fwdays
 
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
David Amend
 
KiranGara_JEE_7Yrs
KiranGara_JEE_7YrsKiranGara_JEE_7Yrs
KiranGara_JEE_7Yrs
Kiran Gara
 
Django simplified : by weever mbakaya
Django simplified : by weever mbakayaDjango simplified : by weever mbakaya
Django simplified : by weever mbakaya
Mbakaya Kwatukha
 
Vue Storefront - Progressive Web App for Magento (1.9, 2.x) - MM18DE speech
Vue Storefront - Progressive Web App for Magento (1.9, 2.x) - MM18DE speechVue Storefront - Progressive Web App for Magento (1.9, 2.x) - MM18DE speech
Vue Storefront - Progressive Web App for Magento (1.9, 2.x) - MM18DE speech
Divante
 
The Importance Things of Full Stack Development
The Importance Things of Full Stack DevelopmentThe Importance Things of Full Stack Development
The Importance Things of Full Stack Development
Mike Taylor
 
Web worker in your angular application
Web worker in your angular applicationWeb worker in your angular application
Web worker in your angular application
Suresh Patidar
 
Subhajit_Das_Resume_(M)2016
Subhajit_Das_Resume_(M)2016Subhajit_Das_Resume_(M)2016
Subhajit_Das_Resume_(M)2016
Subhajit Das
 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web App
Edureka!
 
Lagom : Reactive microservice framework
Lagom : Reactive microservice frameworkLagom : Reactive microservice framework
Lagom : Reactive microservice framework
Fabrice Sznajderman
 
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
Codemotion
 
Real World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVCReal World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVC
Carlo Bonamico
 
Catching-up web technologies - an endless story
Catching-up web technologies - an endless storyCatching-up web technologies - an endless story
Catching-up web technologies - an endless story
Cleber Jorge Amaral
 
Ad

More from Vlad Fedosov (6)

OdessaJs 2020 - How to build your first micro frontend in a matter of minutes
OdessaJs 2020 - How to build your first micro frontend in a matter of minutesOdessaJs 2020 - How to build your first micro frontend in a matter of minutes
OdessaJs 2020 - How to build your first micro frontend in a matter of minutes
Vlad Fedosov
 
DevOps Fest 2020. immutable infrastructure as code. True story.
DevOps Fest 2020. immutable infrastructure as code. True story.DevOps Fest 2020. immutable infrastructure as code. True story.
DevOps Fest 2020. immutable infrastructure as code. True story.
Vlad Fedosov
 
Maximizing your professional value, from junior to leader
Maximizing your professional value, from junior to leaderMaximizing your professional value, from junior to leader
Maximizing your professional value, from junior to leader
Vlad Fedosov
 
XP Days 2019: First secret delivery for modern cloud-native applications
XP Days 2019: First secret delivery for modern cloud-native applicationsXP Days 2019: First secret delivery for modern cloud-native applications
XP Days 2019: First secret delivery for modern cloud-native applications
Vlad Fedosov
 
LvivCSS: Web Components as a foundation for Design System
LvivCSS: Web Components as a foundation for Design SystemLvivCSS: Web Components as a foundation for Design System
LvivCSS: Web Components as a foundation for Design System
Vlad Fedosov
 
KharkivJS: Flaws of the Web Components in 2019 and how to address them
KharkivJS: Flaws of the Web Components in 2019 and how to address themKharkivJS: Flaws of the Web Components in 2019 and how to address them
KharkivJS: Flaws of the Web Components in 2019 and how to address them
Vlad Fedosov
 
OdessaJs 2020 - How to build your first micro frontend in a matter of minutes
OdessaJs 2020 - How to build your first micro frontend in a matter of minutesOdessaJs 2020 - How to build your first micro frontend in a matter of minutes
OdessaJs 2020 - How to build your first micro frontend in a matter of minutes
Vlad Fedosov
 
DevOps Fest 2020. immutable infrastructure as code. True story.
DevOps Fest 2020. immutable infrastructure as code. True story.DevOps Fest 2020. immutable infrastructure as code. True story.
DevOps Fest 2020. immutable infrastructure as code. True story.
Vlad Fedosov
 
Maximizing your professional value, from junior to leader
Maximizing your professional value, from junior to leaderMaximizing your professional value, from junior to leader
Maximizing your professional value, from junior to leader
Vlad Fedosov
 
XP Days 2019: First secret delivery for modern cloud-native applications
XP Days 2019: First secret delivery for modern cloud-native applicationsXP Days 2019: First secret delivery for modern cloud-native applications
XP Days 2019: First secret delivery for modern cloud-native applications
Vlad Fedosov
 
LvivCSS: Web Components as a foundation for Design System
LvivCSS: Web Components as a foundation for Design SystemLvivCSS: Web Components as a foundation for Design System
LvivCSS: Web Components as a foundation for Design System
Vlad Fedosov
 
KharkivJS: Flaws of the Web Components in 2019 and how to address them
KharkivJS: Flaws of the Web Components in 2019 and how to address themKharkivJS: Flaws of the Web Components in 2019 and how to address them
KharkivJS: Flaws of the Web Components in 2019 and how to address them
Vlad Fedosov
 
Ad

Recently uploaded (20)

Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 

JSFest 2019: Technology agnostic microservices at SPA frontend

  • 1. Technology agnostic microservices at SPA frontend Vladlen Fedosov, Director of R&D @Namecheap, Inc
  • 2. Mmm... Listen talk or check Instagram? 🤔 ● What are microservices at Frontend and why you need to be aware? ● Possible approaches overview. Pros/Cons ● Working solution overview ● Extra tips & tricks from our experience
  • 3. Vlad Fedosov Director of R&D @Namecheap TL;DR: ● 10 years in the industry ● Went path from Junior to Architect ● Use JS since Mootools era ● Amateur DevOps evangelist ● AWS ninja ● Believe in self-organized, cross-functional teams
  • 4. “Opening the door for everyone to a free and open Internet”
  • 5. Do we have an issue here? Problem statement...
  • 6. What are Microservices? Microservices - also known as the microservice architecture - is an architectural style that structures an application as a collection of services that are ● Highly maintainable and testable ● Loosely coupled ● Independently deployable ● Organized around business capabilities ● Owned by a small team
  • 8. Ok, got it! But what about frontend?
  • 10. Meet “Micro Frontends” In short: they are Microservices architecture that was adopted for UI needs To be more specific: Think about web app as a composition of features which are owned by independent teams. Each team has a distinct area of business or mission it cares about and specialises in. A team is cross functional and develops its features end-to-end, from database to user interface.
  • 12. What are Micro Frontends?
  • 13. Do I need Micro Fragments in my project? No, unless: ● You have several cross-functional teams working on the same frontend app. And they want: ○ Independent development lifecycle ○ Independent releases ○ Calm sleep at night w/o a chance of their functionality being broken by other team’s release ● You’re working on a huge enterprise app and want to get out of the golden cage of your outdated framework. ● Bring your own case 🙋‍♂
  • 16. What is page composition? Fragment 1 Fragment 2 Fragment 3 Layout
  • 17. What is page composition? Fragment 1 Fragment 2 Fragment 3 First request, composition may happen at client/server side
  • 18. What is page re-composition? Different app was loaded State change 2nd request, re-composition at client/server side
  • 19. What are the options we have?
  • 20. Available approaches 1. Support 1 framework, break code onto NPM modules (static/lazy loading) 2. Support multiple frameworks and a. compose page at server side b. compose page at client side c. compose page at server & client side
  • 22. Available approaches Approach / Criteria Technology agnostic Code isolation SEO/SM-bots compatible (SSR) UX Level 1 Framework, NPM modules ❌ Limited ✅ ✅ X Frameworks, client side composition ✅ ✅ ❌ Limited (longer initial load) X Frameworks, server side composition ✅ ✅ ✅ Limited (need to reload page for re-composition) X Frameworks, isomorphic composition ✅ ✅ ✅ ✅
  • 23. Let’s see what we have in production nowadays
  • 24. Our next-gen solution overview: “Isomorphic Layout Composer”
  • 28. single-spa - JS framework for Micro Frontends
  • 29. We need to go deeper...
  • 30. Challenges we faced with ● Page composition & re-composition ● Routing & page transition ● Micro Frontends registry ● Dynamic code loading & updating ● SSR support ● Error reporting ● Cross-fragment communication ● Code isolation ● Guardrails
  • 31. Overall architecture - System (high level) Registry Client Server Router Layout composer (Tailor) MS 1 MS 2 MS X UI composition layer (single-spa) Template engine
  • 32. Overall architecture - Micro Frontend App Shared Code client.js mount() unmount() server.js config ← Business logic Client side bundle Server bundle Assets Server runner Server API CDN
  • 33. Challenges - Code Isolation Simple rules for micro-frontend developers: ● No “window” modification, no global variables ● No DOM modifications outside assigned container ● No shared CSS, apps use Scoped CSS only ● No shared state, apps can communicate only via events Real experience: we banned Angular as it was patching “window” & had issues if you’re running 2+ Angular apps on the same page
  • 34. Challenges - Page composition <html> <head> ... </head> <body> <slot name="navbar"></slot> <slot name="body"></slot> <slot name="footer"></slot> </body> </html>
  • 35. Challenges - Registry Holds info about: ● Apps ● Routes ● Templates apps: { "@portal/news": { spaBundle: "http://127.0.0.1:3000/dist/single_spa.js", cssBundle: "http://127.0.0.1:3000/dist/21f11a2afc03af3d62f8.css", ssr: { // Optional. If omitted - no rendering will be done at the server side src: "http://localhost:3000/news/?fragment=1", }, }, }, templates: { master: "master.template.html" }, routes: [ // Express like routes, matched in order of appearance { route: "/news/*", template: "master", slots: { navbar: { appName: "@portal/navbar" }, body: { appName: "@portal/news" }, } } ]
  • 36. Challenges - Routing & page transition /news/latest Global Router: /news/* App Router: /latest /latest Rule: MF App is aware about it’s own routes only. Implementation: 2-tiered router
  • 37. Challenges - Routing & page transition But how app A can perform transition to the view within app B? It’s simple - use built in capabilities of your framework. Nothing changes. 1. User clicks link 2. App A framework invokes history.pushState() 3. ILC listens for 'hashchange', 'popstate' & “<a>” click events 4. ILC checks if any changes to the set of the apps visible on a page needed 5. ILC performs unmounting of the old apps & mounts new ones
  • 38. Challenges - Dynamic code loading Solution of choice: SystemJS , every App should be built as AMD/SystemJS bundle & registered in the registry. It will be loaded as soon as it will be requested by the Global Router or as explicit dependency in code: ● Webpack “externals” ● System.import('react') <script type="systemjs-importmap"> { "imports": { "@portal/news":"http://127.0.0.1:3000/index.js", "react": "https://cdnjs.cloudflare.com/.../index.js" } } </script>
  • 39. Few more advanced things...
  • 40. Deploy/Rollback We have two challenges here: ● Notify ILC about new versions of our fragments ● Synchronize versions of the code at server (SSR) & client (Browser) But how can we solve them?
  • 41. Deploy/Rollback - Notification ● Make API call to the Registry after deployment to CDN but before server update ● Use version discovery mechanism. Example: ○ Keep metadata file at CDN with disabled HTTP cache & update it after deploy. { "spaBundle": "https://my-cdn.com/app-name/main.c02de4198cc732e5797a.js", "cssBundle": "https://my-cdn.com/app-name/main.c02de4198cc732e5797a.css", "dependencies": { "react": "https://my-cdn.com/app-name/react.v16.0.1.js" } }
  • 42. Deploy/Rollback - Synchronize versions Registry App 1: v2 ILC App 1: v2 ILC App 1: v1 App server v1 App server v2 Not all ILC instances are in sync with Registry App deployment in progress... Special response header: x-bundle-overrides
  • 43. Error reporting 1. Use framework built-in capabilities, ILC listens at framework error handlers 2. Be prepared for the worst case scenario: window.addEventListener('error', function(event) { const moduleInfo = SystemJS.getModuleInfo(event.filename); // <--- if (moduleInfo === null) { return; } event.preventDefault(); console.error( … ); newrelic.noticeError( … ); // Track errors centrally });
  • 44. Cross-fragment communication There are 3 main options: ● Browser events. ● Shared services. ● Shared state. This solution doesn’t impose or restrict shared state between Micro-Frontends. Bring your own if you need it.
  • 45. Further improvements ● Integration of the Tailor & single-spa under single tool with unified client/server API ● Template transition handling ● LDE improvements for our engineers ● Automated tests ● Documentation, documentation, documentation... ● Built-in monitoring ● Fragment inside fragment (parcels)
  • 46. Vlad Fedosov Director of R&D @Namecheap, Inc [email protected] Slides: Or just scan it: bit.ly/2BRrn8V Source code: github.com/StyleT/icl