Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Micro Frontends in the Wild

Micro Frontends in the Wild

NDC London

SQUER Solutions

January 23, 2020
Tweet

More Decks by SQUER Solutions

Other Decks in Technology

Transcript

  1. @duffleit
    Micro
    Frontends
    in the Wild
    .
    NDC London 2020
    David Leitner - @duffleit

    View full-size slide

  2. @duffleit
    @duffleit
    @duffleit
    [email protected]
    David Leitner
    Lead Engineer

    View full-size slide

  3. @duffleit
    “microservices are small
    and focused on one thing
    to be autonomous.”

    View full-size slide

  4. @duffleit
    Why autonomous?
    ✔ Independent Deployments
    ✔ Distinct Operations
    ✔ Technology Agnostic
    ✔ Model around Business Domains
    ✔ Small Interface Surface
    ✔ Parallel development

    View full-size slide

  5. @duffleit
    Microservice
    Microservice Microservice
    DB
    DB
    DB
    Microservice
    Microservice Microservice
    DB
    DB
    DB

    View full-size slide

  6. @duffleit
    Disclaimer:
    That's fine in 80 % of
    the cases.
    SPA
    API
    Gateway
    Microservice
    Microservice Microservice
    DB
    DB
    DB

    View full-size slide

  7. @duffleit
    Microservice
    API
    Gateway
    SPA
    Microservice Microservice
    DB
    DB
    DB
    ❌ Independent Deployments
    ❌ Distinct Operations
    ❌ Technology Agnostic
    ❌ Small Interface Surface
    ❌ Parallel development
    Frontend
    Monolith

    View full-size slide

  8. @duffleit
    Microservice
    API
    Gateway
    SPA
    Microservice Microservice
    DB
    DB
    DB
    SPA
    API
    Gateway
    Micro
    Frontends

    View full-size slide

  9. @duffleit
    μService
    Ordering
    μService
    DB
    μService μService
    DB
    DB
    Catalogue Profile
    μService
    DB
    DB
    Hyperlink Hyperlink

    View full-size slide

  10. @duffleit
    ✔ Independent Deployments
    ✔ Distinct Operations
    ✔ Technology Agnostic
    ✔ Small Interface Surface
    ✔ Model around Business Domains
    ✔ Parallel development
    Based on the assumption to have
    fully verticalized systems.
    μService
    Ordering
    μService
    DB
    μService μService
    DB
    DB
    Catalogue Profile
    μService
    DB
    DB
    Hyperlink Hyperlink
    Approach 1:
    Hyperlink Connected Applications

    View full-size slide

  11. @duffleit
    Approach 1:
    Hyperlink Connected Applications
    μService
    Ordering
    μService
    DB
    μService μService
    DB
    DB
    Catalogue Profile
    μService
    DB
    DB
    Hyperlink Hyperlink
    Dashboard
    Hyperlink
    μService
    DB
    ⛔ Overfetching
    ⛔ Overrequesting

    View full-size slide

  12. @duffleit
    Approach 1:
    Hyperlink Connected Applications
    with Backend for Frontends
    μService
    Ordering
    μService
    DB
    μService μService
    DB
    DB
    Catalogue Profile
    μService
    DB
    DB
    Hyperlink Hyperlink
    Dashboard
    Hyperlink
    μService
    DB
    BFF
    Service
    BFF
    Service
    BFF
    Service
    BFF
    Service
    https://samnewman.io/patterns/architectural/bff/
    Presentation
    Process Flow
    Domain Logic
    Data
    Presentation
    Process Flow
    Domain Logic
    Data

    View full-size slide

  13. @duffleit
    Approach 1:
    Hyperlink Connected Applications
    with GraphQL
    μService
    Ordering
    μService
    DB
    μService μService
    DB
    DB
    Catalogue Profile
    μService
    DB
    DB
    Hyperlink Hyperlink
    Dashboard
    Hyperlink
    μService
    DB
    GraphQL
    Presentation
    Process Flow
    Domain Logic
    Data

    View full-size slide

  14. @duffleit
    But,

    View full-size slide

  15. @duffleit
    Hyperlink Integration
    breaks your SPA.

    View full-size slide

  16. @duffleit
    We introduce another
    horizontal layer.

    View full-size slide

  17. @duffleit
    μService
    Ordering
    μService
    DB
    μService μService
    DB
    DB
    Catalogue Profile
    μService
    DB
    DB
    Hyperlink Hyperlink
    Dashboard
    Hyperlink
    μService
    DB
    View Aggregation Layer
    Horizontal Layer
    Ripple Effect

    View full-size slide

  18. @duffleit
    Only works on a very
    coarse grained level.
    Ordering
    Catalogue
    Hyperlink Hyperlink
    Dashboard

    View full-size slide

  19. @duffleit
    Dashboard
    Profile
    Profile
    μService
    DB
    Catalogue
    μService
    DB
    Catalogue
    Ordering
    Ordering
    μService
    DB
    Dashboard
    μService
    DB

    View full-size slide

  20. @duffleit
    Dashboard
    Profile
    Catalogue
    Ordering
    Ordering
    Catalogue
    Hyperlink Hyperlink
    Dashboard
    Two Definitions of Micro Frontends
    One “Micro Frontend” per page. 2...n Micro Frontends per page.

    View full-size slide

  21. @duffleit
    Dashboard
    Profile
    Catalogue
    Ordering
    Ordering
    Catalogue
    Hyperlink Hyperlink
    Dashboard
    Two Definitions of Micro Frontends
    One “Micro Frontend” per page. 2...n Micro Frontends per page.

    View full-size slide

  22. @duffleit
    How to integrate them?
    @duffleit

    View full-size slide

  23. @duffleit
    Repository
    Build & Deploy
    Server
    Browser
    Composed Application Micro Frontend
    Build Time Integration Server Side Integration Runtime Integration

    View full-size slide

  24. @duffleit
    Repository
    Build & Deploy
    Server
    Browser
    Mono Repo
    package.json
    Composed Application Micro Frontend
    Build Time Integration
    MonoRepo
    ✔ Allows extensive code
    sharing and reuse.
    ✔ No Version Conflicts and
    burden with distributing
    libraries
    Angular
    Workspaces

    View full-size slide

  25. @duffleit
    Repository
    Build & Deploy
    Server
    Browser
    Composed Application Micro Frontend
    Build Time Integration
    ❌ Independent Deployments
    ❌ Distinct Operations
    ❌ Technology Agnostic
    ✔ Small Interface Surface
    ✔ Model around Business Domains
    ✔ Parallel development

    View full-size slide

  26. @duffleit
    Build Time Integration allows
    Static Site Generation

    View full-size slide

  27. @duffleit
    Product
    Product
    Product
    new
    Product
    Product
    Page
    Product
    Page
    Product
    Page
    Product
    Page
    Static Files
    Scully
    Rebuild

    View full-size slide

  28. @duffleit
    Repository
    Build & Deploy
    Server
    Browser
    Composed Application Micro Frontend
    Build Time Integration
    ❌ Independent Deployments
    ❌ Distinct Operations
    ❌ Technology Agnostic
    ✔ Small Interface Surface
    ✔ Model around Business Domains
    ✔ Parallel development

    View full-size slide

  29. @duffleit
    Repository
    Build & Deploy
    Server
    Browser
    Composed Application Micro Frontend
    Server Side Integration
    e.g. Project Mosaic

    View full-size slide

  30. @duffleit
    Based on the concept of Server Side Includes
    or Edge Side Includes

    View full-size slide

  31. @duffleit
    Tailor is a Layout Server
    header
    fragment
    μService
    account
    fragment
    μService
    catalogue
    fragment
    μService
    maps your request to
    a template
    checkout-template.html ...
    dashboard.template.html
    profile-template.html

    View full-size slide

  32. @duffleit
    Repository
    Build & Deploy
    Server
    Browser
    Composed Application Micro Frontend
    Server Side Integration
    ✔ Independent Deployments
    ✔ Distinct Operations
    ✔ Technology Agnostic
    ✔ Small Interface Surface
    ✔ Model around Business Domains
    ✔ Parallel development

    View full-size slide

  33. @duffleit
    @duffleit
    Round Trips

    View full-size slide

  34. @duffleit
    Repository
    Build & Deploy
    Server
    Browser
    Composed Application Micro Frontend
    Runtime Integration
    Aggregating UI
    Routing, Templates, Lazy Loading
    Meta-SPA-Router

    View full-size slide

  35. @duffleit
    A Meta
    Framework
    to handle
    Frameworks.

    View full-size slide

  36. @duffleit
    Meta Framework
    Isolation &
    Composition
    Routing
    Messaging &
    Shared State
    Web Platform
    Isolation &
    Composition
    Routing
    Frontend 1 Frontend N
    ... Frontend N
    Frontend 1 ...

    View full-size slide

  37. @duffleit
    @duffleit

    View full-size slide

  38. @duffleit
    @duffleit

    View full-size slide

  39. @duffleit
    index.html
    Meta Framework
    Isolation &
    Composition
    Routing
    Messaging &
    Shared State
    Web Platform
    Isolation &
    Composition
    Routing
    Messaging &
    Shared State
    Frontend N
    Frontend 1 ... Frontend N
    Frontend 1 ...
    Frontend N + 1

    View full-size slide

  40. @duffleit
    our environment is the index.html
    immutablewebapps.org
    index.html
    https://12factor.net/

    View full-size slide

  41. @duffleit
    Repository
    Build & Deploy
    Server
    Browser
    Composed Application Micro Frontend
    ✔ Independent Deployments
    ✔ Distinct Operations
    ✔ Technology Agnostic
    ✔ Small Interface Surface
    ✔ Model around Business Domains
    ✔ Parallel development
    Runtime Integration

    View full-size slide

  42. @duffleit
    Server
    Browser
    Runtime Integration
    Longliving App
    State in the frontend &
    verticals need to interact
    with each other.
    Server Side Integration
    Request Response Model
    Interactions between
    different Verticals are done
    on the Backend.

    View full-size slide

  43. @duffleit
    1 Micro-Frontend per Page
    Hyperlink Integration
    n Micro-Frontends per Page
    Buildtime Integration
    Serverside Integration
    Runtime Integration

    View full-size slide

  44. @duffleit
    Complexities:
    ● UI/UX Consistency
    ● Shared State
    ● Resilience
    ● Tracing/Analytics
    ● Offline-First
    ● ...
    ✔ Independent
    Deployments
    ✔ Distinct
    Operations
    ✔ Technology
    Agnostic
    ✔ Model around
    Business Domains
    ✔ Small Interface
    Surface
    ✔ Parallel
    development

    View full-size slide

  45. @duffleit
    1 Micro-Frontend per Page
    Hyperlink Integration
    n Micro-Frontends per Page
    Buildtime Integration
    Serverside Integration
    Runtime Integration

    View full-size slide

  46. @duffleit
    Mix and Match
    Landing Shop Ordering
    hyperlink hyperlink



    APP SHELL
    Header
    Footer

    View full-size slide

  47. @duffleit
    Micro-Frontends are
    Distributed Systems.
    The Final Secret:

    View full-size slide

  48. @duffleit
    Everything that can
    go wrong will go wrong.
    The Final Secret:
    Murphy’s law

    View full-size slide

  49. @duffleit
    Maybe start with a
    monolithic first approach.

    View full-size slide

  50. @duffleit
    by: twitter.com/swardley

    View full-size slide

  51. @duffleit
    @duffleit
    @duffleit
    squer.at/slides
    David Leitner
    Lead Engineer

    View full-size slide