MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB...

64
I DON’T UNDERSTAND MICRO-FRONTENDS @lucamezzalira

Transcript of MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB...

Page 1: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

I DON’T UNDERSTANDMICRO-FRONTENDS@lucamezzalira

Page 2: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

🧐

Page 3: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application
Page 4: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Luca MezzaliraVP of Architecture at DAZN

Google Developer Expert

London JavaScript Community Manager

Page 5: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Architecture evolution

Application Server

Single-Page Application

DB

Page 6: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Architecture evolution

API Gateway

Single-Page Application

DB

Microservice

DB

Microservice

DB

Microservice

Page 7: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Architecture evolution

API Gateway

Single-Page Application

DB

Microservice

DB

Microservice

DB

Microservice

MFE MFE MFE MFE

Page 8: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Who is using micro-frontends

Page 9: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

MICRO-FRONTENDS DEFINITION

Page 10: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

“ Micro-frontends are the technicalrepresentation of a business subdomain,they allow independent implementationswith the same or different technology choices.Finally they should avoid sharing logic with other subdomains and they are own by a single team ”

Page 11: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

What is a micro-frontend?

Landing pageSign inSing upCatalog

Help

Landing page

Sign in

Sign up

Catalog

Help

Page 12: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

MICRO-FRONTENDS PRINCIPLES

Page 13: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Model around business domain

Culture of automation

Hide implementation details

Decentralisation

Deploy independently

Isolate failure

Page 14: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Model around business domain

Core Subdomain Supporting Subdomain Generic Subdomain

Page 15: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Model around business domainLanding page

Sign in

Sign up

Catalog

Schedule

Search

Generic

Generic

Core

Page 16: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Model around business domainLanding page

Sign in

Sign up

Catalog

Schedule

Search

Landing page MFE

Auth MFE

Discovery MFE

Page 17: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Model around business domain

AmsterdamGeneric Subdomain

LondonCore Subdomain

LeedsSupporting Subdomain

KatowiceSupporting Subdomain

Page 18: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Decentralisation

Tech LeadsArchitecture

Team Mars

Team Venus

Team Moon

Page 19: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Decentralisation

1. Autonomous teams

2. Using the right tool for the right job

3. Components library

4. Standardization where needed

5. Code duplication vs shared code

Page 20: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Culture of automation

1 1 1 1 1 1

1

1

1

Page 21: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Independent deployment

Catalog 2.0.0

Landing Page 1.1.0

My Account 2.4.1

Catalog 1.9.2

Page 22: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Hide implementation details

SubscriptionMicro-Frontend

PayPal Component

CONTRACT

Page 23: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

MICRO-FRONTENDSDECISIONS FRAMEWORK

Page 24: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

1. Define

2. Compose

3. Route

4. Communicate

Key micro-frontends decisions

Page 25: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Define a micro-frontends

header

footer

image

relatedarticlesarticle

description

landingpage

sign insign up

catalog

Page 26: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

1. Up front investment

2. Teams structure

3. Great for SEO

4. Testing challenges

5. Scalability challenges

6. Dependency management

Horizontal VS Vertical split

1. Traditional development

2. Embracing JavaScript

ecosystem

3. Dynamic Rendering for

SEO

Page 27: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Compose micro-frontends

ORIGIN

CDN

CLIENT

Page 28: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Route micro-frontends

ORIGIN

CDN

CLIENT

RR

R

R

Page 29: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Micro-frontends communication

header

footer

image

relatedarticlesarticle

description

header

footer

image

relatedarticlesarticle

description

mysite.com/section?id=123

Page 30: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Isolate failure

header

footer

image

relatedarticles

article description

CatalogError

Page 31: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

THERE IS NORIGHT OR WRONGBUT ONLYTHE RIGHT APPROACHBASED ON THE CONTEXT

Page 32: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

MICRO-FRONTENDS @DAZN

Page 33: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application
Page 34: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Micro-Frontend @ DAZN

CSS

HTML App.js

Vendor.js

Page 35: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

DAZN implementation

BOOTSTRAP

1. Application startup

2. I/O operations

3. Micro-Frontends lifecycle

4. Communication between

Micro-Frontends

Page 36: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

DAZN implementation

1. A Micro-Frontend represents a business domain

2. A Micro-Frontend is autonomous

3. One Micro-Frontend loaded per time

4. No sharing between micro-frontends (*)

5. Technology agnostic

(*) with some exceptions

Page 37: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

How bootstrap works

CSS

HTML

App.js

Vendor.js

1. Call Startup service

2. Understand user status

3. Load and Mount a

Micro-Frontend

Page 39: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

DAZN routing

Cloudfront Lambda@Edge Bootstrap Micro-Frontend

Page 40: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Components

1. Development time

integration

2. APIs first

3. Own by a single team

Page 41: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

MICRO-FRONTENDSBEST PRACTICES

Page 42: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

APIs first design principles

1. APIs are the first user interface of your application

2. APIs come first, then the implementation

3. APIs are self-descriptive

Page 43: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Design System and Governance

Button

List

Accordion

Checkbox

Fonts

Colors

Icons

Contract Testing

Visual Regression

Performance Budget

NPM Private Registry

DESIGN TOKENS COMPONENTS LIBRARY AUTOMATION

Page 44: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Duplication over abstraction

Page 45: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Duplication over abstraction

Core Library

Lib A

Lib B

Lib C

Project Moon

Project Saturn

Page 46: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

WRONG ABSTRACTION IS MORE EXPENSIVE THAN CODE DUPLICATION

Page 47: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Dependencies Management

header

footer

image

relatedarticlesarticle

descriptionAngular 9

React 16.1

React 15.1

Page 48: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Performance

1. What is true for SPA is also true for Micro-Frontends

2. Pick the right approach to fulfill your needs

3. A user may download less code than a SPA

Page 49: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Business Evolution

Auth MFE

Sign in MFE Subscribe MFE

Page 50: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

SEO

Server Side Rendering Dynamic Rendering

Page 51: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

MICRO-FRONTENDSAUTOMATION

Page 52: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Version of Control

Monorepo Polyrepo

● Improve code quality● Always working with the

latest libraries versions● Continuous scaling

investment● Faster onboarding● Trunk based development

● Embrace conventional development methods

● Focus on part of the code● Multiple branching

strategies available● Freedom to define CI/CD

Page 53: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Continuous Integration

1. Investment upfront

2. Fast feedback

3. Parallel and Sequential tasks execution

4. Fitness functions for testing architectural concerns

Page 54: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Building Evolutionary Architectures - O’Reilly

Fitness Function is a function that provides an objective integrity assessment of some architectural characteristics

Page 55: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Continuous Integration

Static AnalysisRun tests

Analyse Permutations

Build and Optimize

Artifacts saved

Clone Git repo

Module swapping

Bundlesize check

Page 56: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Micro-Frontends Deployment

Catalog

Sign In

Help

Page 57: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Components Deployment

header

footer

image

relatedarticlesarticle

description

Button

List

Accordion

Checkbox

Page 58: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Strangler Patternand Canary Releases

Cloudfront Lambda@edge

Single Page App

Catalog MFE

Auth MFE

Help MFE

Lambda@Edge in DAZN: bit.ly/2SZ0Y24

Page 59: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

LET’SWRAP UP

Page 60: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Micro-frontends summary

Orchestrate

Compose

Communicate

Observability

Teams impact

AutomationDesign System

DependenciesManagement

PerformanceDuplication over Abstraction

Page 61: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application
Page 62: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

Useful links

bit.ly/386DNbx

Resources

bit.ly/2v79e70

Webinar

Page 63: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

30 daysFREE ACCESS

bit.ly/32glJJF

buildingmicrofrontends.com

Page 64: MICRO-FRONTENDS I DON’T UNDERSTAND · 2020. 7. 13. · Single-Page Application DB Microservice DB Microservice DB Microservice. Architecture evolution API Gateway Single-Page Application

THANK YOU

t: @lucamezzaliraw: lucamezzalira.come: [email protected]🤣🤣

🤣