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

Architectures for huge Enterprise Applications ...

Architectures for huge Enterprise Applications with Angular -- Slides from We Are Developers in Vienna, May 2018

# Library DEMO - npm package with CLI 6
https://github.com/manfredsteyer/cli6-based-lib-demo

# Monorepo DEMO with Nx
https://github.com/manfredsteyer/monorepo-demo

# Micro Apps with Angular Elements DEMO
https://github.com/manfredsteyer/angular-microapp
Have a look at the README.md

# Blog Post about Micro Apps with Angular Elements
http://www.softwarearchitekt.at/post/2018/05/04/microservice-clients-with-web-components-using-angular-elements-dreams-of-the-near-future.aspx

# More Information & Workshops
http://www.softwarearchitekt.at/

Manfred Steyer

May 17, 2018
Tweet

More Decks by Manfred Steyer

Other Decks in Programming

Transcript

  1. @BASTAcon & @ManfredSteyer About me… • Manfred Steyer • SOFTWAREarchitekt.at

    • Angular Trainings and Consultancy • Google Developer Expert (GDE) Page ▪ 4 Manfred Steyer Vienna: June 2018 In-House: Every time
  2. @ManfredSteyer Typical Module Structure Page ▪ 5 AppModule … …

    … SharedModule Root Module Feature Modules Shared Module
  3. @ManfredSteyer Create Library with CLI >= 6 npm install -g

    @angular/cli ng new lib-project cd lib-project ng generate library logger-lib ng generate application playground-app ng serve --project playground-app ng build --project logger-lib
  4. @ManfredSteyer Publishing to npm Registry • Increment version in package.json

    • npm version [patch | minor | major | version] • ng build --project logger-lib • npm publish --registry http://localhost:4873 • npm install --registry http://localhost:4873
  5. @ManfredSteyer Alternatives for setting the Registry • Global: npm set

    registry http://localhost:4873 • Default: registry.npmjs.org • npm get registry • Project: .npmrc in project root
  6. @ManfredSteyer Disadvantages Distribution • Annoying within project • Prevents gritting

    further libs Versioning • Old versions • Conflicts • How to force devs to use latest version? Decoupling • What if lib authors == app authors?
  7. @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, …
  8. @ManfredSteyer Two Flavors • Like Workspaces/Solutions in different IDEs Project

    Monorepo • E. g. used at Google or Facebook Company-wide Monorepo
  9. @ManfredSteyer Further Features of Nx • Just recompile changed apps

    • Format Code/ check format • Restrict which apps/libs can access which other libs • Visualize module structure and dependencies • Scaffold Boilerplate
  10. @ManfredSteyer Advantages Sub Project Sub Project Sub Project Sub Project

    Sub Project Sub Project Sub Project Sub Project
  11. @ManfredSteyer Disadvantages Sub Project Sub Project Sub Project Sub Project

    Sub Project Sub Project Sub Project Sub Project Team A Team B Contract
  12. @ManfredSteyer Disadvantages More Coordination Blocking Tasks Complex Overall System One

    Architecture One Technology Stack Hard to change One size fits all?
  13. @ManfredSteyer Some Options for Shell iframes • Strong Isolation •

    Straight forward • Overlapping Elements? • Lots of page requests? • SEO? Web Components • Standard • Custom Elements • <app-a></app-a> • <app-b></app-b> • Shadow DOM: CSS Isolation • Nesting • Framework Support? Bootstrapping different SPAs • Similar to Web Components • No Standard • Nesting isn’t possible
  14. @ManfredSteyer MicroApp with Angular Elements @NgModule({ imports: [BrowserModule], declarations: [MicroAppComponent],

    bootstrap: [], entryComponents: [MicroAppComponent] }) export class AppModule { }
  15. @ManfredSteyer MicroApp with Angular Elements @NgModule({ imports: [BrowserModule], declarations: [MicroAppComponent],

    bootstrap: [], entryComponents: [MicroAppComponent] }) export class AppModule { }
  16. @ManfredSteyer MicroApp with Angular Elements @NgModule({ imports: [BrowserModule], declarations: [MicroAppComponent],

    bootstrap: [], entryComponents: [MicroAppComponent] }) export class AppModule { constructor(private injector: Injector) { } ngDoBootstrap() { } }
  17. @ManfredSteyer MicroApp with Angular Elements @NgModule({ imports: [BrowserModule], declarations: [MicroAppComponent],

    bootstrap: [], entryComponents: [MicroAppComponent] }) export class AppModule { constructor(private injector: Injector) { } ngDoBootstrap() { const MicroAppElement = createNgElementConstructor( MicroAppComponent, { injector: this.injector }); customElements.define('micro-app', MicroAppElement); } }
  18. @ManfredSteyer Some General Advice for Macro-Architecture Shared state, communication/ navigation

    b/w apps Hyperlinks Legacy Apps or *very very* strong isolation needed? iframes Need separate Deployment/ mix Technologies Web Components "Majestic Monolith" w/ Libs and Monorepo little much yes no yes no Not a good fit for customer facing Fallback: Bootstrap several frameworks/ Spa Micro-Architecture: • Libs/ npm packages • Monorepo • Web Components • …
  19. @ManfredSteyer Blog • 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 • Microservice Clients With Web Components Using Angular Elements: Dreams Of The (Near) Future?