SlideShare a Scribd company logo
19.12.2019
Cross-platform
assets-based front-end architecture
React Kyiv
Oleksandr
Tserkovnyi
Front-end Architect in PMLAB
JS Fest Program Committee member
Consultant
Running half marathons
Micro Frontends in short
✤ Solution for decomposition
✤ Build time / Run time
✤ Build time: any, most popular npm libs
✤ Run time: Lazy Load or iFrame
✤ Solve: independent deploy/development, freshness of tech
stack, maintainability, testability, boundaries
✤ Only for web
Independent development
✤ Key winner in industry
✤ Business benefits: speed, delivery, hypothesis option
✤ Any tech stack
✤ Any development process
✤ etc.
Not only web
✤ Usually the same project is used by
✤ Desktop web
✤ Mobile web
✤ Native App iOS
✤ Native App Android
✤ Desktop app
✤ etc.
HTML/CSS/JS support
All of the platforms have a tool to render html/css/js within like – iframe, webview or directly.
Cost of delivery one feature for
many platforms?
Photo print builder
Ordinar eShop
High cost
Why is that so high?
✤ Teams have their own planning and it is almost impossible to fit
their schedule the same time you want to release.
✤ Different teams = different implementations = very error-prone.
✤ So you need to get capacity of all teams in the project, in our case it is
3-4 teams on 6-7 platforms.
✤ Plan testing, might be regression testing.
✤ Plan release of artifacts.
✤ You need to have a plan for the rollback.
✤ What if we can deliver the same codebase for all of the
platforms?
✤ How much will it cost then?
Low cost
Why is it low?
✤ 1 team supports it
✤ 1 time effort
✤ 1 plan for release and rollback
✤ 1 test plan
✤ etc.
Introducing assets-based
architecture
Gives ability to integrate one codebase to all platforms, thus reduce the cost of development
assets-based architecture
✤ Good at:
✤ contracts are known
✤ contracts are changed rarely
✤ save same product look and feel
✤ very dynamic runtime
✤ Bad at:
✤ communication in between services
✤ very fast load (due to roundtrip for assets-manifest)
✤ when you need to fully save native UX
Shutterfly
Main purpose
Additional business value
Embedded lazy loaded service
Connected to the main project
Main project
Some dynamic items affect
Assets based service
✤ User does not need them right now
✤ They create additional business value
✤ Need to support identical look and feel
✤ Must consume directly and dynamically the same data
(token, language, etc.)
Infrastructure level
Infrastructure entities
✤ HOST
Any product implementing its own logic, wants to include a service.
Must contain a proxy server to communicate with Service discovery. Implements it via INTEGRATION_PREFIX
✤ HOST Proxy
Should have an endpoint, which serves as a proxy for all requests to Service discovery. This endpoint + service
name is INTEGRATION_PREFIX
✤ Service discovery (similar to microservices Kubernetes,
Consul, DNS)
✤ Persistent storage
… for Service discovery. Storage for saving information about registered services. Persistent in order to be
available without alive API (object storage).
Infrastructure level loading (easier)
Loading…
get `photos` service
find service registry endpoint
proxy to the endpoint
return static of the service
proxy statics of the service
Infrastructure level API calls (easier)
call for service’s API
find service registry endpoint
proxy to the endpoint proxy
proxy response back
INTEGRATION_PREFIX
✤ location.origin/{SD_PROXY}/service/{SERVICE_NAME}
✤ e.g.: https://www.shutterfly.com/service-discovery/
service/photos
✤ Is needed for service, to be able to reach its own API/
Static/* resolver.
✤ css/js files are replaced before put into the HOST
Service discovery
✤ Store information about services.
✤ Can register and deregister a service.
✤ Proxy requests.
✤ Gives information for HOST of how to use a service.
Service discovery API
Works as reverse proxy
Service discovery API GET /proxy
{
"corefront": {
"mobile_web": {
"in": {
"en": "http://corefront-mobile"
},
"com": {
"ru": "http://corefront-mobile",
"en": "http://corefront-mobile"
}
}
},
// …
// …
"photos": {
"mobile_web": {
"com": {
"en": "http://photos-fe.domain",
"ru": "http://photos-fe.domain"
}
},
"mobile_native_android": {
"com": {
"en": "http://photos-fe.domain"
}
},
"mobile_native_ios": {
"com": {
"en": "http://photos-fe.domain"
}
}
}

}
O(1)
✤ Proxy EVERY request
✤ Easy trick:
save roundtrip by update
proxy memory variable ONLY
on CRUD of /service
POST/PUT/DELETE
so then, any other NON
/service request will work O(1)
at this point
Infrastructure flow
Register in service discovery
When service is ready
POST /service
{
"serviceName": "corefront",
"proxyPass": “http://corefront-mobile”
}
GET /service/{NAME}
/service/corefront
HOST asks for service in SD
PROXY PASS to `service.proxyPass`
http://corefront-mobile
HOST proxied by SD
SERVICE returns
{
"corefront_file1.mobile.js": "/path/mobile/com/en/1.file.mobile.js",
"corefront_file2.mobile.js": "/path/mobile/com/en/2.file.mobile.js",
"corefront_file1.mobile.css": "/path/mobile/com/en/1.mobile.css"
}
assets-manifest.json
✤ Never caches + ?date=${+(new Date())}
✤ Served on root call
✤ Preserves /platform/brand/language structure
assets-manifest.json
FROM assets-manifest.json
<script src=“/service-discovery/service/corefront/path/mobile/com/en/
1.file.mobile.js”></script>
<script src=“/service-discovery/service/corefront/path/mobile/com/en/
2.file.mobile.js”></script>
<link href="/service-discovery/service/corefront/path/mobile/com/en/
1.mobile.css" rel=“stylesheet” />
later on … HOST’s LOADER
requests files
Run time
Run time entities (already common)
✤ LOADER – Loads service and its dependencies.
✤ REGISTER – Register services.
✤ STATE – Internal state for all architecture purposes.
✤ SHELL – Main entry-point and orchestrator.
✤ ADAPTER
Bridge between implementations in order to provide proper communication.
For instance ADAPTER must be used when web service wants to communicate with Native APP.
Loading…
service library load a service
Run time (easier)
load a service
register a service
loading state
service loaded
Run time (easier)
start
fire CustomEvent
service:registered
with observable ref
notify ref
register the service
service is loaded
store loaded state
service is registered
Communication level
✤ CustomEvent vs Event vs Global namespace
✤ .observable(publish: Function)
✤ observable for listening
✤ publish for triggering (HOST provides to integrate its own
state management)
✤ .notify()
✤ ADAPTER, adapts calls for different platforms
Contracts are known and strict
✤ Architecture contracts
✤ Business contracts
Architecture contracts
✤ Handshake contracts
service:loaded
service:registered
✤ Dependency contracts (request:data)
user-token
language
base-url
render-container
proxy-prefix
Business contracts
✤ Anything specific, which you may require from the HOST.
✤ Examples:
✤ Page UI change from page to page
✤ Platform where we run the app
✤ Brand
✤ URLs/URL templates for other services to route to
request:modal
✤ Business only
modal:login
modal:deposit
confirm:delete-some-stuff
notification:you-have-limits-don't-you?
event
✤ Architecture events
service:initialize
service:render
service:destroy
✤ Business events
change:* (change:language) – here is just example
user:login
user:logout
modal:login:open
modal:login:close
notification:my-custom-action:show
notification:my-custom-action:hide
notification:my-custom-action:accept
confirm:my-custom-action:accept
confirm:my-custom-action:decline
change:* (change:user-data, change:user-balance, change:page:exact-event-id) – here is just example
CustomEvent example
const serviceLoadedEvent = new CustomEvent("service:loaded", {
detail: {
name: "corefront"
}
});
globalThis.dispatchEvent(serviceLoadedEvent)
request:data example
const languageData_REQUEST: DataRequest = {
type: "request:data",
scope: "photos",
id: "language"
};
observable.publish(languageData_REQUEST)
request:modal example
const modalRequest: ModalRequest = {
type: "request:modal",
scope: "photos",
id: "modal:login"
};
observable.publish(modalRequest)
event example
const changeLanguageEv_SUCCESS = {
type: "event",
scope: "photos",
id: "change:language",
payload: {
data: "LANG"
}
};
observable.notify(changeLanguageEv_SUCCESS)
callNative(service: string, msg: { [key: string]: any }) {
if (globalThis.eventScope.webkit !== undefined) {
if (globalThis.eventScope.webkit.messageHandlers[service] !== undefined) {
globalThis.eventScope.webkit
.messageHandlers[service].postMessage(msg);
}
} else {
globalThis.eventScope[service] && globalThis.eventScope[service]
.postMessage(JSON.stringify(msg));
}
}
ADAPTER. Hot to call native?
callNative(service: string, msg: { [key: string]: any }) {
if (globalThis.eventScope.webkit !== undefined) {
if (globalThis.eventScope.webkit.messageHandlers[service] !== undefined) {
globalThis.eventScope.webkit
.messageHandlers[service].postMessage(msg);
}
} else {
globalThis.eventScope[service] && globalThis.eventScope[service]
.postMessage(JSON.stringify(msg));
}
}
ADAPTER (easier)
PMLAB state
✤ Released for Mobile Web platform
✤ In progress of release for Mobile Web 2/Desktop Web 2
✤ In progress of release for Android
✤ In development for iOS
Next steps
✤ Debug tool
✤ Contracts validation
✤ Integration tests
Thanks!

More Related Content

Similar to cross-platform-assets-based-front-end-architecture

The future of web development write once, run everywhere with angular js an...
The future of web development   write once, run everywhere with angular js an...The future of web development   write once, run everywhere with angular js an...
The future of web development write once, run everywhere with angular js an...
Mark Leusink
 
Windows Azure & How to Deploy Wordress
Windows Azure & How to Deploy WordressWindows Azure & How to Deploy Wordress
Windows Azure & How to Deploy Wordress
George Kanellopoulos
 
Cloud APIs Overview Tucker
Cloud APIs Overview   TuckerCloud APIs Overview   Tucker
Cloud APIs Overview Tucker
Infrastructure 2.0
 
Increase automation to rest
Increase automation to restIncrease automation to rest
Increase automation to rest
Shivaling Sannalli
 
#JaxLondon keynote: Developing applications with a microservice architecture
#JaxLondon keynote: Developing applications with a microservice architecture#JaxLondon keynote: Developing applications with a microservice architecture
#JaxLondon keynote: Developing applications with a microservice architecture
Chris Richardson
 
Developing Applications with a Micro Service Architecture - Chris Richardson
Developing Applications with a Micro Service Architecture - Chris RichardsonDeveloping Applications with a Micro Service Architecture - Chris Richardson
Developing Applications with a Micro Service Architecture - Chris Richardson
JAXLondon2014
 
Building SPA’s (Single Page App) with Backbone.js
Building SPA’s (Single Page App) with Backbone.jsBuilding SPA’s (Single Page App) with Backbone.js
Building SPA’s (Single Page App) with Backbone.js
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
 
Running your Spring Apps in the Cloud Javaone 2014
Running your Spring Apps in the Cloud Javaone 2014Running your Spring Apps in the Cloud Javaone 2014
Running your Spring Apps in the Cloud Javaone 2014
cornelia davis
 
TRWResume-10-2016
TRWResume-10-2016TRWResume-10-2016
TRWResume-10-2016
Tommy Williams
 
EVOLVE'14 | Enhance | Anshul Chhabra & Akhil Aggrawal | Cisco - AEM High Avai...
EVOLVE'14 | Enhance | Anshul Chhabra & Akhil Aggrawal | Cisco - AEM High Avai...EVOLVE'14 | Enhance | Anshul Chhabra & Akhil Aggrawal | Cisco - AEM High Avai...
EVOLVE'14 | Enhance | Anshul Chhabra & Akhil Aggrawal | Cisco - AEM High Avai...
Evolve The Adobe Digital Marketing Community
 
Real World SharePoint Framework and Azure Services
Real World SharePoint Framework and Azure ServicesReal World SharePoint Framework and Azure Services
Real World SharePoint Framework and Azure Services
Brian Culver
 
Going FaaSter, Functions as a Service at Netflix
Going FaaSter, Functions as a Service at NetflixGoing FaaSter, Functions as a Service at Netflix
Going FaaSter, Functions as a Service at Netflix
Yunong Xiao
 
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Emerson Eduardo Rodrigues Von Staffen
 
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
Amazon Web Services
 
Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework Basic
Mario Romano
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Amazon Web Services
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Amazon Web Services
 
Convert your Full Trust Solutions to the SharePoint Framework (SPFx) in 1 hour
Convert your Full Trust Solutions to the SharePoint Framework (SPFx) in 1 hourConvert your Full Trust Solutions to the SharePoint Framework (SPFx) in 1 hour
Convert your Full Trust Solutions to the SharePoint Framework (SPFx) in 1 hour
Brian Culver
 
Progressive Web Apps - deep dive
Progressive Web Apps - deep diveProgressive Web Apps - deep dive
Progressive Web Apps - deep dive
Kenneth Rohde Christiansen
 
T2 Web Framework
T2 Web FrameworkT2 Web Framework
T2 Web Framework
Shinpei Ohtani
 

Similar to cross-platform-assets-based-front-end-architecture (20)

The future of web development write once, run everywhere with angular js an...
The future of web development   write once, run everywhere with angular js an...The future of web development   write once, run everywhere with angular js an...
The future of web development write once, run everywhere with angular js an...
 
Windows Azure & How to Deploy Wordress
Windows Azure & How to Deploy WordressWindows Azure & How to Deploy Wordress
Windows Azure & How to Deploy Wordress
 
Cloud APIs Overview Tucker
Cloud APIs Overview   TuckerCloud APIs Overview   Tucker
Cloud APIs Overview Tucker
 
Increase automation to rest
Increase automation to restIncrease automation to rest
Increase automation to rest
 
#JaxLondon keynote: Developing applications with a microservice architecture
#JaxLondon keynote: Developing applications with a microservice architecture#JaxLondon keynote: Developing applications with a microservice architecture
#JaxLondon keynote: Developing applications with a microservice architecture
 
Developing Applications with a Micro Service Architecture - Chris Richardson
Developing Applications with a Micro Service Architecture - Chris RichardsonDeveloping Applications with a Micro Service Architecture - Chris Richardson
Developing Applications with a Micro Service Architecture - Chris Richardson
 
Building SPA’s (Single Page App) with Backbone.js
Building SPA’s (Single Page App) with Backbone.jsBuilding SPA’s (Single Page App) with Backbone.js
Building SPA’s (Single Page App) with Backbone.js
 
Running your Spring Apps in the Cloud Javaone 2014
Running your Spring Apps in the Cloud Javaone 2014Running your Spring Apps in the Cloud Javaone 2014
Running your Spring Apps in the Cloud Javaone 2014
 
TRWResume-10-2016
TRWResume-10-2016TRWResume-10-2016
TRWResume-10-2016
 
EVOLVE'14 | Enhance | Anshul Chhabra & Akhil Aggrawal | Cisco - AEM High Avai...
EVOLVE'14 | Enhance | Anshul Chhabra & Akhil Aggrawal | Cisco - AEM High Avai...EVOLVE'14 | Enhance | Anshul Chhabra & Akhil Aggrawal | Cisco - AEM High Avai...
EVOLVE'14 | Enhance | Anshul Chhabra & Akhil Aggrawal | Cisco - AEM High Avai...
 
Real World SharePoint Framework and Azure Services
Real World SharePoint Framework and Azure ServicesReal World SharePoint Framework and Azure Services
Real World SharePoint Framework and Azure Services
 
Going FaaSter, Functions as a Service at Netflix
Going FaaSter, Functions as a Service at NetflixGoing FaaSter, Functions as a Service at Netflix
Going FaaSter, Functions as a Service at Netflix
 
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
 
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
 
Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework Basic
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
 
Convert your Full Trust Solutions to the SharePoint Framework (SPFx) in 1 hour
Convert your Full Trust Solutions to the SharePoint Framework (SPFx) in 1 hourConvert your Full Trust Solutions to the SharePoint Framework (SPFx) in 1 hour
Convert your Full Trust Solutions to the SharePoint Framework (SPFx) in 1 hour
 
Progressive Web Apps - deep dive
Progressive Web Apps - deep diveProgressive Web Apps - deep dive
Progressive Web Apps - deep dive
 
T2 Web Framework
T2 Web FrameworkT2 Web Framework
T2 Web Framework
 

Recently uploaded

Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
Pravash Chandra Das
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
Finale of the Year: Apply for Next One!
Finale of the Year: Apply for Next One!Finale of the Year: Apply for Next One!
Finale of the Year: Apply for Next One!
GDSC PJATK
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
Shinana2
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
alexjohnson7307
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 

Recently uploaded (20)

Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
Finale of the Year: Apply for Next One!
Finale of the Year: Apply for Next One!Finale of the Year: Apply for Next One!
Finale of the Year: Apply for Next One!
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 

cross-platform-assets-based-front-end-architecture

  • 2. Oleksandr Tserkovnyi Front-end Architect in PMLAB JS Fest Program Committee member Consultant Running half marathons
  • 3. Micro Frontends in short ✤ Solution for decomposition ✤ Build time / Run time ✤ Build time: any, most popular npm libs ✤ Run time: Lazy Load or iFrame ✤ Solve: independent deploy/development, freshness of tech stack, maintainability, testability, boundaries ✤ Only for web
  • 4. Independent development ✤ Key winner in industry ✤ Business benefits: speed, delivery, hypothesis option ✤ Any tech stack ✤ Any development process ✤ etc.
  • 5. Not only web ✤ Usually the same project is used by ✤ Desktop web ✤ Mobile web ✤ Native App iOS ✤ Native App Android ✤ Desktop app ✤ etc.
  • 6. HTML/CSS/JS support All of the platforms have a tool to render html/css/js within like – iframe, webview or directly.
  • 7. Cost of delivery one feature for many platforms?
  • 10. Why is that so high? ✤ Teams have their own planning and it is almost impossible to fit their schedule the same time you want to release. ✤ Different teams = different implementations = very error-prone. ✤ So you need to get capacity of all teams in the project, in our case it is 3-4 teams on 6-7 platforms. ✤ Plan testing, might be regression testing. ✤ Plan release of artifacts. ✤ You need to have a plan for the rollback.
  • 11. ✤ What if we can deliver the same codebase for all of the platforms? ✤ How much will it cost then?
  • 13. Why is it low? ✤ 1 team supports it ✤ 1 time effort ✤ 1 plan for release and rollback ✤ 1 test plan ✤ etc.
  • 14. Introducing assets-based architecture Gives ability to integrate one codebase to all platforms, thus reduce the cost of development
  • 15. assets-based architecture ✤ Good at: ✤ contracts are known ✤ contracts are changed rarely ✤ save same product look and feel ✤ very dynamic runtime ✤ Bad at: ✤ communication in between services ✤ very fast load (due to roundtrip for assets-manifest) ✤ when you need to fully save native UX
  • 18. Embedded lazy loaded service Connected to the main project Main project
  • 20. Assets based service ✤ User does not need them right now ✤ They create additional business value ✤ Need to support identical look and feel ✤ Must consume directly and dynamically the same data (token, language, etc.)
  • 22. Infrastructure entities ✤ HOST Any product implementing its own logic, wants to include a service. Must contain a proxy server to communicate with Service discovery. Implements it via INTEGRATION_PREFIX ✤ HOST Proxy Should have an endpoint, which serves as a proxy for all requests to Service discovery. This endpoint + service name is INTEGRATION_PREFIX ✤ Service discovery (similar to microservices Kubernetes, Consul, DNS) ✤ Persistent storage … for Service discovery. Storage for saving information about registered services. Persistent in order to be available without alive API (object storage).
  • 23. Infrastructure level loading (easier) Loading… get `photos` service find service registry endpoint proxy to the endpoint return static of the service proxy statics of the service
  • 24. Infrastructure level API calls (easier) call for service’s API find service registry endpoint proxy to the endpoint proxy proxy response back
  • 25. INTEGRATION_PREFIX ✤ location.origin/{SD_PROXY}/service/{SERVICE_NAME} ✤ e.g.: https://www.shutterfly.com/service-discovery/ service/photos ✤ Is needed for service, to be able to reach its own API/ Static/* resolver. ✤ css/js files are replaced before put into the HOST
  • 26. Service discovery ✤ Store information about services. ✤ Can register and deregister a service. ✤ Proxy requests. ✤ Gives information for HOST of how to use a service.
  • 27. Service discovery API Works as reverse proxy
  • 28. Service discovery API GET /proxy { "corefront": { "mobile_web": { "in": { "en": "http://corefront-mobile" }, "com": { "ru": "http://corefront-mobile", "en": "http://corefront-mobile" } } }, // … // … "photos": { "mobile_web": { "com": { "en": "http://photos-fe.domain", "ru": "http://photos-fe.domain" } }, "mobile_native_android": { "com": { "en": "http://photos-fe.domain" } }, "mobile_native_ios": { "com": { "en": "http://photos-fe.domain" } } }
 }
  • 29. O(1) ✤ Proxy EVERY request ✤ Easy trick: save roundtrip by update proxy memory variable ONLY on CRUD of /service POST/PUT/DELETE so then, any other NON /service request will work O(1) at this point
  • 31. Register in service discovery When service is ready POST /service { "serviceName": "corefront", "proxyPass": “http://corefront-mobile” }
  • 33. PROXY PASS to `service.proxyPass` http://corefront-mobile HOST proxied by SD
  • 34. SERVICE returns { "corefront_file1.mobile.js": "/path/mobile/com/en/1.file.mobile.js", "corefront_file2.mobile.js": "/path/mobile/com/en/2.file.mobile.js", "corefront_file1.mobile.css": "/path/mobile/com/en/1.mobile.css" } assets-manifest.json
  • 35. ✤ Never caches + ?date=${+(new Date())} ✤ Served on root call ✤ Preserves /platform/brand/language structure assets-manifest.json
  • 36. FROM assets-manifest.json <script src=“/service-discovery/service/corefront/path/mobile/com/en/ 1.file.mobile.js”></script> <script src=“/service-discovery/service/corefront/path/mobile/com/en/ 2.file.mobile.js”></script> <link href="/service-discovery/service/corefront/path/mobile/com/en/ 1.mobile.css" rel=“stylesheet” /> later on … HOST’s LOADER requests files
  • 38. Run time entities (already common) ✤ LOADER – Loads service and its dependencies. ✤ REGISTER – Register services. ✤ STATE – Internal state for all architecture purposes. ✤ SHELL – Main entry-point and orchestrator. ✤ ADAPTER Bridge between implementations in order to provide proper communication. For instance ADAPTER must be used when web service wants to communicate with Native APP.
  • 39. Loading… service library load a service Run time (easier) load a service register a service loading state service loaded
  • 40. Run time (easier) start fire CustomEvent service:registered with observable ref notify ref register the service service is loaded store loaded state service is registered
  • 41. Communication level ✤ CustomEvent vs Event vs Global namespace ✤ .observable(publish: Function) ✤ observable for listening ✤ publish for triggering (HOST provides to integrate its own state management) ✤ .notify() ✤ ADAPTER, adapts calls for different platforms
  • 42. Contracts are known and strict ✤ Architecture contracts ✤ Business contracts
  • 43. Architecture contracts ✤ Handshake contracts service:loaded service:registered ✤ Dependency contracts (request:data) user-token language base-url render-container proxy-prefix
  • 44. Business contracts ✤ Anything specific, which you may require from the HOST. ✤ Examples: ✤ Page UI change from page to page ✤ Platform where we run the app ✤ Brand ✤ URLs/URL templates for other services to route to
  • 46. event ✤ Architecture events service:initialize service:render service:destroy ✤ Business events change:* (change:language) – here is just example user:login user:logout modal:login:open modal:login:close notification:my-custom-action:show notification:my-custom-action:hide notification:my-custom-action:accept confirm:my-custom-action:accept confirm:my-custom-action:decline change:* (change:user-data, change:user-balance, change:page:exact-event-id) – here is just example
  • 47. CustomEvent example const serviceLoadedEvent = new CustomEvent("service:loaded", { detail: { name: "corefront" } }); globalThis.dispatchEvent(serviceLoadedEvent)
  • 48. request:data example const languageData_REQUEST: DataRequest = { type: "request:data", scope: "photos", id: "language" }; observable.publish(languageData_REQUEST)
  • 49. request:modal example const modalRequest: ModalRequest = { type: "request:modal", scope: "photos", id: "modal:login" }; observable.publish(modalRequest)
  • 50. event example const changeLanguageEv_SUCCESS = { type: "event", scope: "photos", id: "change:language", payload: { data: "LANG" } }; observable.notify(changeLanguageEv_SUCCESS)
  • 51. callNative(service: string, msg: { [key: string]: any }) { if (globalThis.eventScope.webkit !== undefined) { if (globalThis.eventScope.webkit.messageHandlers[service] !== undefined) { globalThis.eventScope.webkit .messageHandlers[service].postMessage(msg); } } else { globalThis.eventScope[service] && globalThis.eventScope[service] .postMessage(JSON.stringify(msg)); } } ADAPTER. Hot to call native?
  • 52. callNative(service: string, msg: { [key: string]: any }) { if (globalThis.eventScope.webkit !== undefined) { if (globalThis.eventScope.webkit.messageHandlers[service] !== undefined) { globalThis.eventScope.webkit .messageHandlers[service].postMessage(msg); } } else { globalThis.eventScope[service] && globalThis.eventScope[service] .postMessage(JSON.stringify(msg)); } } ADAPTER (easier)
  • 53. PMLAB state ✤ Released for Mobile Web platform ✤ In progress of release for Mobile Web 2/Desktop Web 2 ✤ In progress of release for Android ✤ In development for iOS
  • 54. Next steps ✤ Debug tool ✤ Contracts validation ✤ Integration tests