SlideShare a Scribd company logo
1 of 27
Download to read offline
From monolith SPA to micro-frontends
How we extended microservices architecture to frontend
Rustam Aliyev @rstml
Ivan Martynov @j_martyn
07/07/2018 OneDome
What is ”microservice”?
• Architectural pattern
• Collection of loosely coupled services
Application
(PHP, Ruby, etc.)
Database
Frontend (SPA)
API
Backend
Database
XHR
Conway’s Law
Produced system design copies
organisational structure
M. Conway, 1967
Frontend (SPA)
API Gateway (REST, GraphQL)
Backend
Database
Microservice A
Team A
Backend
Database
Microservice B
Team B
Backend
Database
Microservice N
Team N
…
Problems of monolith SPA
• Ownership !
• Dependency management "
• Shared components #
• Deployment and releases $
• A/B testing %
…
Backend
Database
Microservice A
Team A
Frontend
Backend
Database
Microservice B
Team B
Frontend
Backend
Database
Microservice N
Team N
Frontend…
API Gateway (REST, GraphQL)
Decoupling Monolith
Typical SPA Anatomy
• One entry point (index.js)
• SPA framework
• All components in one bundle
...
<script src="https://unpkg.com/react/dist/react.js"></script>
<script src="/index.js"></script>
...
Complex monolith SPA
• All-in-one SPA bundle
• Package per product with custom routings
• Shared components in separate packages
index.js
…App A
Package
App B
Package
App N
Package
Shared
Components
Package(s)
Ways to decompose monolith frontend
1. Strong isolation
Web Components / IFrame
Multiple SPAs / frameworks
Communication channels
2. Weak isolation
Dependency Injection
Single SPA / framework
Shared state store
…
App A
Package
Team A
App B
Package
Team B
App N
Package
Team N
Browser
Runtime
Dependency
Injection
Shared
Components
Package ver.A
Shared
Components
Package ver.B
Shared
Components
Package ver.N
Thin SPA (injector)
Shared Store (Redux, MobX)
/* app/package.json */
{
"dependencies" : {
"dependency" : "1.0.0"
}
}
/* app.js */
import dependency from 'dependency';
...
dependency.use();
/* index.html */
<script src="/dependency.v1.0.0.js"></script>
<script src="/app.v2.0.0.js"></script>
<script src="/thin-spa.js"></script>
/* app.js */
export default (dependency) => {
dependency.use();
}
/* thin-spa.js (injector) */
import app from 'app';
import dependency from 'dependency';
...
app(dependency); // wiring
Importing vs Dependency Injection
Organising projects
Before: project structure
Package
Thin SPA
Package
App A
Package
App B
Package
Shared
Component
… Package
App N
Before: Local development workflow
1. Manual symlink or npm link to test
2. Publish components to NPM
3. Deploy whole app
cd ~/components
npm link
cd ~/application
npm link components
Monorepo
• A single repository holding the code of many packages
• Monorepo ≠ monolith
Thin
SPA
Package
App A
Package
App B
Package
Shared
Components
Package
…
App N
Package
Monorepo
Shared
Components
Package
Lerna
• Tool for managing monorepo
• Inter-dependency management
• Publishing
• Testing
• CLI: bootstrap, publish, etc.
• yarn optimised
lerna-repo
├─ package.json
├─ lerna.json
└─ packages
├─ main-spa
│ └─ package.json
├─ design-lib
│ └─ package.json
├─ app-a
│ └─ package.json
└─ app-b
├─ package.json
└─ node_modules
├─ design-lib -> ../../design-lib
├─ ...
Lerna
• Tool for managing monorepo
• Inter-dependency management
• Publishing
• Testing
• CLI: bootstrap, publish, etc.
• yarn optimised
/* lerna.json */
{
"lerna": "2.5.1",
"npmClient": "yarn",
"useWorkspaces": true, // yarn workspaces
"version": "independent"
}
/* package.json */
{
// yarn workspaces configuration
"workspaces": [
"packages/*"
],
"private": true
}
Lerna: Local development workflow
• Automatically interlinking
• Inter-dependencies and downstream versions
• Automated testing
lerna bootstrap
# All packages are symlinked now
git commit -a -m "Many changes"
lerna publish
# Changes:
# - app-A: 1.0.1 => 1.0.2
# - app-B: 1.2.1 => 1.3.0
# - utils: 1.5.4 => 1.5.5
# - components: 3.0.4 => 3.0.5
Deployment
A
…
B
N
…
A
…
B1
N
B2
Monorepo (e.g. Git) Web Server
Build, test, deployApplications
Shared
components
Micro-frontends
Thin SPA
Results
Same
bundle size
Migrated gradually
in background
~1 month
Summary
Before After
Ownership ! "
Dependency management # $
Shared components % &
Deployment and releases ' (
A/B testing ) *
Future work
• Applying Web Components
• Communication between modules via event bus
• Bolt as an alternative to Lerna
• Hierarchical dependency injection
Questions?

More Related Content

What's hot

Rails in the bowels
Rails in the bowelsRails in the bowels
Rails in the bowelsCreditas
 
4. introduction to Asp.Net MVC - Part II
4. introduction to Asp.Net MVC - Part II4. introduction to Asp.Net MVC - Part II
4. introduction to Asp.Net MVC - Part IIRohit Rao
 
Migrating from monolithic rails
Migrating from monolithic railsMigrating from monolithic rails
Migrating from monolithic railsDanielius Visockas
 
The next step from Microsoft - Vnext (Srdjan Poznic)
The next step from Microsoft - Vnext (Srdjan Poznic)The next step from Microsoft - Vnext (Srdjan Poznic)
The next step from Microsoft - Vnext (Srdjan Poznic)Geekstone
 
.NET Standard - Introduction
.NET Standard - Introduction.NET Standard - Introduction
.NET Standard - IntroductionImmo Landwerth
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on RailsEleni Huebsch
 
Алексей Злобин «Scala in Goozy»
Алексей Злобин «Scala in Goozy»Алексей Злобин «Scala in Goozy»
Алексей Злобин «Scala in Goozy»e-Legion
 
Intoduction to React
Intoduction to ReactIntoduction to React
Intoduction to ReactRubizza
 
ATLRUG Giveback Announcements - Oct. 2014
ATLRUG Giveback Announcements - Oct. 2014ATLRUG Giveback Announcements - Oct. 2014
ATLRUG Giveback Announcements - Oct. 2014jasnow
 
PHP is the King, nodejs is the Prince and Lua is the fool
PHP is the King, nodejs is the Prince and Lua is the foolPHP is the King, nodejs is the Prince and Lua is the fool
PHP is the King, nodejs is the Prince and Lua is the foolAlessandro Cinelli (cirpo)
 
How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?Hiroshi SHIBATA
 
AtlasCamp 2010: Macro Migration Guide for Confluence 4.0 - Ryan Thomas
AtlasCamp 2010: Macro Migration Guide for Confluence 4.0 - Ryan ThomasAtlasCamp 2010: Macro Migration Guide for Confluence 4.0 - Ryan Thomas
AtlasCamp 2010: Macro Migration Guide for Confluence 4.0 - Ryan ThomasAtlassian
 
Introduction to Monix Coeval
Introduction to Monix CoevalIntroduction to Monix Coeval
Introduction to Monix CoevalKnoldus Inc.
 
Patterns in a Containerized World (Matthias Luebken Technology Stream)
Patterns in a Containerized World (Matthias Luebken Technology Stream)Patterns in a Containerized World (Matthias Luebken Technology Stream)
Patterns in a Containerized World (Matthias Luebken Technology Stream)IT Arena
 
Implementing GraphQL API in Elixir – Victor Deryagin
Implementing GraphQL API in Elixir – Victor DeryaginImplementing GraphQL API in Elixir – Victor Deryagin
Implementing GraphQL API in Elixir – Victor DeryaginElixir Club
 
Structured web apps
Structured web appsStructured web apps
Structured web appsSheng Tian
 

What's hot (20)

Rails in the bowels
Rails in the bowelsRails in the bowels
Rails in the bowels
 
4. introduction to Asp.Net MVC - Part II
4. introduction to Asp.Net MVC - Part II4. introduction to Asp.Net MVC - Part II
4. introduction to Asp.Net MVC - Part II
 
Upgrading to rails3
Upgrading to rails3Upgrading to rails3
Upgrading to rails3
 
Migrating from monolithic rails
Migrating from monolithic railsMigrating from monolithic rails
Migrating from monolithic rails
 
The next step from Microsoft - Vnext (Srdjan Poznic)
The next step from Microsoft - Vnext (Srdjan Poznic)The next step from Microsoft - Vnext (Srdjan Poznic)
The next step from Microsoft - Vnext (Srdjan Poznic)
 
.NET Standard - Introduction
.NET Standard - Introduction.NET Standard - Introduction
.NET Standard - Introduction
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
 
Алексей Злобин «Scala in Goozy»
Алексей Злобин «Scala in Goozy»Алексей Злобин «Scala in Goozy»
Алексей Злобин «Scala in Goozy»
 
Intoduction to React
Intoduction to ReactIntoduction to React
Intoduction to React
 
ATLRUG Giveback Announcements - Oct. 2014
ATLRUG Giveback Announcements - Oct. 2014ATLRUG Giveback Announcements - Oct. 2014
ATLRUG Giveback Announcements - Oct. 2014
 
PHP is the King, nodejs is the Prince and Lua is the fool
PHP is the King, nodejs is the Prince and Lua is the foolPHP is the King, nodejs is the Prince and Lua is the fool
PHP is the King, nodejs is the Prince and Lua is the fool
 
Vagrant&amp;ansible
Vagrant&amp;ansibleVagrant&amp;ansible
Vagrant&amp;ansible
 
How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?
 
Lua vs python
Lua vs pythonLua vs python
Lua vs python
 
Event Machine
Event MachineEvent Machine
Event Machine
 
AtlasCamp 2010: Macro Migration Guide for Confluence 4.0 - Ryan Thomas
AtlasCamp 2010: Macro Migration Guide for Confluence 4.0 - Ryan ThomasAtlasCamp 2010: Macro Migration Guide for Confluence 4.0 - Ryan Thomas
AtlasCamp 2010: Macro Migration Guide for Confluence 4.0 - Ryan Thomas
 
Introduction to Monix Coeval
Introduction to Monix CoevalIntroduction to Monix Coeval
Introduction to Monix Coeval
 
Patterns in a Containerized World (Matthias Luebken Technology Stream)
Patterns in a Containerized World (Matthias Luebken Technology Stream)Patterns in a Containerized World (Matthias Luebken Technology Stream)
Patterns in a Containerized World (Matthias Luebken Technology Stream)
 
Implementing GraphQL API in Elixir – Victor Deryagin
Implementing GraphQL API in Elixir – Victor DeryaginImplementing GraphQL API in Elixir – Victor Deryagin
Implementing GraphQL API in Elixir – Victor Deryagin
 
Structured web apps
Structured web appsStructured web apps
Structured web apps
 

Similar to From monolith web app to micro-frontends

Manual JavaScript Analysis Is A Bug
Manual JavaScript Analysis Is A BugManual JavaScript Analysis Is A Bug
Manual JavaScript Analysis Is A BugLewis Ardern
 
N api-node summit-2017-final
N api-node summit-2017-finalN api-node summit-2017-final
N api-node summit-2017-finalMichael Dawson
 
Cytoscape: Now and Future
Cytoscape: Now and FutureCytoscape: Now and Future
Cytoscape: Now and FutureKeiichiro Ono
 
Reaktive Programmierung mit den Reactive Extensions (Rx)
Reaktive Programmierung mit den Reactive Extensions (Rx)Reaktive Programmierung mit den Reactive Extensions (Rx)
Reaktive Programmierung mit den Reactive Extensions (Rx)NETUserGroupBern
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowKaxil Naik
 
Quick look in Reactive Extensions
Quick look in Reactive ExtensionsQuick look in Reactive Extensions
Quick look in Reactive Extensionsjohnlvidal
 
Introduction to React native
Introduction to React nativeIntroduction to React native
Introduction to React nativeDhaval Barot
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC frameworkMohit Gupta
 
From CoreOS to Kubernetes and Concourse CI
From CoreOS to Kubernetes and Concourse CIFrom CoreOS to Kubernetes and Concourse CI
From CoreOS to Kubernetes and Concourse CIDenis Izmaylov
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureColin Mackay
 
Magento 2 Workflows
Magento 2 WorkflowsMagento 2 Workflows
Magento 2 WorkflowsRyan Street
 
Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18Pierre Joye
 
PHP - Programming language war, does it matter
PHP - Programming language war, does it matterPHP - Programming language war, does it matter
PHP - Programming language war, does it matterMizno Kruge
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)Chris Cowan
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-upTroy Miles
 

Similar to From monolith web app to micro-frontends (20)

Manual JavaScript Analysis Is A Bug
Manual JavaScript Analysis Is A BugManual JavaScript Analysis Is A Bug
Manual JavaScript Analysis Is A Bug
 
Node.js an Exectutive View
Node.js an Exectutive ViewNode.js an Exectutive View
Node.js an Exectutive View
 
N api-node summit-2017-final
N api-node summit-2017-finalN api-node summit-2017-final
N api-node summit-2017-final
 
N-API NodeSummit-2017
N-API NodeSummit-2017N-API NodeSummit-2017
N-API NodeSummit-2017
 
Cytoscape: Now and Future
Cytoscape: Now and FutureCytoscape: Now and Future
Cytoscape: Now and Future
 
Intro to CakePHP
Intro to CakePHPIntro to CakePHP
Intro to CakePHP
 
Reaktive Programmierung mit den Reactive Extensions (Rx)
Reaktive Programmierung mit den Reactive Extensions (Rx)Reaktive Programmierung mit den Reactive Extensions (Rx)
Reaktive Programmierung mit den Reactive Extensions (Rx)
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache Airflow
 
Quick look in Reactive Extensions
Quick look in Reactive ExtensionsQuick look in Reactive Extensions
Quick look in Reactive Extensions
 
Introduction to React native
Introduction to React nativeIntroduction to React native
Introduction to React native
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC framework
 
Micro frontend
Micro frontendMicro frontend
Micro frontend
 
From CoreOS to Kubernetes and Concourse CI
From CoreOS to Kubernetes and Concourse CIFrom CoreOS to Kubernetes and Concourse CI
From CoreOS to Kubernetes and Concourse CI
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azure
 
Magento 2 Workflows
Magento 2 WorkflowsMagento 2 Workflows
Magento 2 Workflows
 
Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18
 
Node.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniquesNode.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniques
 
PHP - Programming language war, does it matter
PHP - Programming language war, does it matterPHP - Programming language war, does it matter
PHP - Programming language war, does it matter
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-up
 

Recently uploaded

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 

Recently uploaded (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 

From monolith web app to micro-frontends

  • 1. From monolith SPA to micro-frontends How we extended microservices architecture to frontend Rustam Aliyev @rstml Ivan Martynov @j_martyn 07/07/2018 OneDome
  • 2. What is ”microservice”? • Architectural pattern • Collection of loosely coupled services
  • 5. Conway’s Law Produced system design copies organisational structure M. Conway, 1967
  • 6. Frontend (SPA) API Gateway (REST, GraphQL) Backend Database Microservice A Team A Backend Database Microservice B Team B Backend Database Microservice N Team N …
  • 7. Problems of monolith SPA • Ownership ! • Dependency management " • Shared components # • Deployment and releases $ • A/B testing %
  • 8. … Backend Database Microservice A Team A Frontend Backend Database Microservice B Team B Frontend Backend Database Microservice N Team N Frontend… API Gateway (REST, GraphQL)
  • 10. Typical SPA Anatomy • One entry point (index.js) • SPA framework • All components in one bundle ... <script src="https://unpkg.com/react/dist/react.js"></script> <script src="/index.js"></script> ...
  • 11. Complex monolith SPA • All-in-one SPA bundle • Package per product with custom routings • Shared components in separate packages index.js …App A Package App B Package App N Package Shared Components Package(s)
  • 12. Ways to decompose monolith frontend 1. Strong isolation Web Components / IFrame Multiple SPAs / frameworks Communication channels 2. Weak isolation Dependency Injection Single SPA / framework Shared state store
  • 13. … App A Package Team A App B Package Team B App N Package Team N Browser Runtime Dependency Injection Shared Components Package ver.A Shared Components Package ver.B Shared Components Package ver.N Thin SPA (injector) Shared Store (Redux, MobX)
  • 14. /* app/package.json */ { "dependencies" : { "dependency" : "1.0.0" } } /* app.js */ import dependency from 'dependency'; ... dependency.use(); /* index.html */ <script src="/dependency.v1.0.0.js"></script> <script src="/app.v2.0.0.js"></script> <script src="/thin-spa.js"></script> /* app.js */ export default (dependency) => { dependency.use(); } /* thin-spa.js (injector) */ import app from 'app'; import dependency from 'dependency'; ... app(dependency); // wiring Importing vs Dependency Injection
  • 16. Before: project structure Package Thin SPA Package App A Package App B Package Shared Component … Package App N
  • 17. Before: Local development workflow 1. Manual symlink or npm link to test 2. Publish components to NPM 3. Deploy whole app cd ~/components npm link cd ~/application npm link components
  • 18. Monorepo • A single repository holding the code of many packages • Monorepo ≠ monolith Thin SPA Package App A Package App B Package Shared Components Package … App N Package Monorepo Shared Components Package
  • 19. Lerna • Tool for managing monorepo • Inter-dependency management • Publishing • Testing • CLI: bootstrap, publish, etc. • yarn optimised lerna-repo ├─ package.json ├─ lerna.json └─ packages ├─ main-spa │ └─ package.json ├─ design-lib │ └─ package.json ├─ app-a │ └─ package.json └─ app-b ├─ package.json └─ node_modules ├─ design-lib -> ../../design-lib ├─ ...
  • 20. Lerna • Tool for managing monorepo • Inter-dependency management • Publishing • Testing • CLI: bootstrap, publish, etc. • yarn optimised /* lerna.json */ { "lerna": "2.5.1", "npmClient": "yarn", "useWorkspaces": true, // yarn workspaces "version": "independent" } /* package.json */ { // yarn workspaces configuration "workspaces": [ "packages/*" ], "private": true }
  • 21. Lerna: Local development workflow • Automatically interlinking • Inter-dependencies and downstream versions • Automated testing lerna bootstrap # All packages are symlinked now git commit -a -m "Many changes" lerna publish # Changes: # - app-A: 1.0.1 => 1.0.2 # - app-B: 1.2.1 => 1.3.0 # - utils: 1.5.4 => 1.5.5 # - components: 3.0.4 => 3.0.5
  • 23. A … B N … A … B1 N B2 Monorepo (e.g. Git) Web Server Build, test, deployApplications Shared components Micro-frontends Thin SPA
  • 25. Summary Before After Ownership ! " Dependency management # $ Shared components % & Deployment and releases ' ( A/B testing ) *
  • 26. Future work • Applying Web Components • Communication between modules via event bus • Bolt as an alternative to Lerna • Hierarchical dependency injection