Sustainable SPA-Architectures with Micro Apps (Microfrontends)

Sustainable SPA-Architectures with Micro Apps (Microfrontends)

15934fa2aa7b2ce21f091e9b7cffa856?s=128

Manfred Steyer

June 26, 2019
Tweet

Transcript

  1. @ManfredSteyer Sustainable SPA-Architectures with Micro Apps (Microfrontends) Manfred Steyer SOFTWAREarchitekt.at

    ManfredSteyer
  2. @ManfredSteyer Ever build a software from the scratch? Kick-off After

    some weeks After some years
  3. @ManfredSteyer Idea System

  4. @ManfredSteyer Idea µService µService µService

  5. @ManfredSteyer Idea µService µService µService Single Page Application ??

  6. @ManfredSteyer Contents 1) Deployment Monolith 2) Hyperlinks 3) Shell 4)

    How to choose?
  7. @ManfredSteyer About me… • Manfred Steyer • SOFTWAREarchitekt.at • Angular

    Trainings and Consultancy • Google Developer Expert (GDE) • Trusted Collaborator in the Angular Team Page ▪ 7 Manfred Steyer Public: Selected Cities In-House: everywhere http://softwarearchitekt.at/workshops
  8. @ManfredSteyer 1) Deployment Monolith

  9. @ManfredSteyer Idea µService µService µService Client Fragment Client Fragment Client

    Fragment ✓ Easy (Tooling) ✓ One optimized bundle set ✓ Consistent  No separate deployment  Mixing Technologies: Difficult  Coupling npm Packages ?
  10. @ManfredSteyer Advantages • Distribution • Versioning

  11. @ManfredSteyer Disadvantages • Distribution • Versioning ;-)

  12. @ManfredSteyer Disadvantages Distribution • Annoying within project Versioning • Old

    versions • Conflicts • How to force devs to use latest version?
  13. @ManfredSteyer 2) Monorepo

  14. @ManfredSteyer Workspace

  15. @ManfredSteyer Advantages Everyone uses the latest versions No version conflicts

    No burden with distributing libs Creating new libs: Adding folder Experience: Successfully used at Google, Facebook, …
  16. @ManfredSteyer Moving back and forth Npm Registry

  17. @ManfredSteyer Advantages Sub Project Sub Project Sub Project Sub Project

    Sub Project Sub Project Sub Project Sub Project
  18. @ManfredSteyer Disadvantages Sub Project Sub Project Sub Project Sub Project

    Sub Project Sub Project Sub Project Sub Project
  19. @ManfredSteyer Disadvantages Sub Project Sub Project Sub Project Sub Project

    Sub Project Sub Project Sub Project Sub Project Team A Team B Contract
  20. @ManfredSteyer Disadvantages One Architecture One Technology Stack Hard to change

    No self- contained teams One size fits all?
  21. @ManfredSteyer 3) Hyperlinks

  22. @ManfredSteyer UI Composition w/ Hyperlinks µApp SPA µApp SPA µApp

    SPA <a href="…">…</a> <a href="…">…</a>
  23. @ManfredSteyer

  24. @ManfredSteyer

  25. @ManfredSteyer ✓ Simple  Loosing State  Load a new

    Application
  26. @ManfredSteyer

  27. @ManfredSteyer Web Components for Shared Widgets?

  28. @ManfredSteyer Communication b/w µApps µApp µApp µApp Backend HTTP, Web

    Sockets, SSE, …
  29. @ManfredSteyer Communication b/w µApps µApp µApp /app2/xyz/17?p=42 /app1/abc/42

  30. @ManfredSteyer 3) Shell

  31. @ManfredSteyer µService Providing a (SPA based) Shell µApp µApp µApp

    Shell ▪ iframes ▪ Bootstrapping several SPAs ▪ + Lazy Loading ▪ Meta-Frameworks?
  32. @ManfredSteyer DEMO

  33. @ManfredSteyer µService Communication via Url µApp µApp µApp Shell http://my-url?customerId=7

  34. @ManfredSteyer Communication via Custom Events window.dispatchEvent('customer-selected', …) window.addEventListener('customer-selected', …)

  35. @ManfredSteyer Communication with Web Components <client-a [state]="appState" (message)="handle($event)"></client-a> <client-b [state]="appState"

    (message)="handle($event)"></client-b> JavaScript in Shell
  36. @ManfredSteyer In general: Eventing As little as possible Send out

    information Don't expect an answer 0 to n other micro apps can consume it Don't expect specific notifications Loosely coupling
  37. @ManfredSteyer Routing /client-a/this/that /client-b/this/that /client-c/this/that :

  38. @ManfredSteyer Routing /client-a/this/that /client-b/this/that /client-c/this/that :

  39. @ManfredSteyer Advantage • Several small and decoupled Projects

  40. @ManfredSteyer Disadvantages • Several small and decoupled Projects ;-) •

    More Bundles • Less optimized Bundles/ duplicate Code? • UI Consistency?
  41. @ManfredSteyer 4) Choosing a Solution

  42. @ManfredSteyer Some General Advice Shared state, navigation b/w apps Hyperlinks

    Legacy Apps or *very very* strong isolation? iframes Separate Deployment/ mix Technologies? Bootstrap several SPAs Deployment Monolith little much yes no yes no Not a good fit for public web sites
  43. @ManfredSteyer Architecture within Micro-Apps Packages Web Components Monorepo Inner Sourcing

    Separate Wey …
  44. @ManfredSteyer Blog > SOFTWAREarchitekt.at • A Software Architect's Approach Towards

    Using Angular (And SPAs In General) For Microservices Aka Microfrontends • A Lightweight And Solid Approach Towards Micro Frontends (Micro Service Clients) With Angular And/Or Other Frameworks • Micro Apps With Web Components Using Angular Elements
  45. @ManfredSteyer Conclusion Deployment Monolith Hyper Links Shell You need to

    evaluate!
  46. @ManfredSteyer Beware the Frankenstein- Monster on the client too!

  47. @ManfredSteyer Contact and Downloads [mail] manfred.steyer@SOFTWAREarchitekt.at [web] SOFTWAREarchitekt.at [twitter] ManfredSteyer

    d http://softwarearchitekt.at/workshops Slides & Examples