Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Angular Architecture: Monorepos and Micro Front...
Search
Manfred Steyer
PRO
October 17, 2023
Programming
1
440
Angular Architecture: Monorepos and Micro Frontends
Manfred Steyer
PRO
October 17, 2023
Tweet
Share
More Decks by Manfred Steyer
See All by Manfred Steyer
Modern Angular: Renovation for Your Applications
manfredsteyer
PRO
0
210
Vertical Architectures for Scalable Angular Applications
manfredsteyer
PRO
0
320
Modern Angular with Lightweight Stores: New Rules and Options
manfredsteyer
PRO
0
260
Successful with Signals: 3 Rules for Your Architecture
manfredsteyer
PRO
0
160
Successful with Signals: 3 Rules for Your Architecture @.NET UserGroup Bern
manfredsteyer
PRO
0
47
Improving Your Architecture with Forensic Analysis
manfredsteyer
PRO
0
110
Micro Frontends Unmasked: Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
330
Modern Angular with the NGRX Signal Store New Rules for Your Architecture @BASTA 2024 in Mainz
manfredsteyer
PRO
0
31
Modern Angular with the NGRX Signal Store New Rules for Your Architecture @BASTA! 2024 in Mainz
manfredsteyer
PRO
0
400
Other Decks in Programming
See All in Programming
カラム追加で増えるActiveRecordのメモリサイズ イメージできますか?
asayamakk
4
1.5k
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
830
Importmapを使ったJavaScriptの 読み込みとブラウザアドオンの影響
swamp09
4
1.2k
CPython 인터프리터 구조 파헤치기 - PyCon Korea 24
kennethanceyer
0
240
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
210
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
3
400
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
110
Vue.js学習の振り返り
hiro_xre
2
130
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
550
リリース8年目のサービスの1800個のERBファイルをViewComponentに移行した方法とその結果
katty0324
5
3.6k
Dev ContainersとGitHub Codespacesの素敵な関係
ymd65536
1
130
Universal Linksの実装方法と陥りがちな罠
kaitokudou
1
220
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
66
9.9k
It's Worth the Effort
3n
183
27k
Why Our Code Smells
bkeepers
PRO
334
57k
Code Reviewing Like a Champion
maltzj
519
39k
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
Rails Girls Zürich Keynote
gr2m
93
13k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
27
1.9k
Teambox: Starting and Learning
jrom
132
8.7k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
KATA
mclloyd
29
13k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Transcript
@BASTAcon & @ManfredSteyer
@ManfredSteyer Typical Module Structure Page ▪ 3 AppModule … …
… SharedModule Root Module Feature Modules Shared Modules SharedModule
@ManfredSteyer Contents • Monorepos • Strategic Design and DDD •
Nx & Incremental Compilation • Microfrontends
@ManfredSteyer Manfred Steyer
@ManfredSteyer Monorepos
@ManfredSteyer Monorepo Structure
@ManfredSteyer Advantages Everyone uses the latest versions No version conflicts
No burden with distributing libs
@ManfredSteyer Two Flavors • Like Workspaces/Solutions in different IDEs Project
Monorepo • E. g. used at Google or Facebook Company-wide Monorepo
@ManfredSteyer Moving back and forth Npm Registry
@ManfredSteyer Tooling & Generator https://nrwl.io/nx
@ManfredSteyer Visualize Module Structure
@ManfredSteyer Further Selected Features of Nx • Restricting access b/w
apps and libs • Just recompile changed apps • Parallel compilation in the cloud • Integration of tooling: Cypress, Playwright, Storybook, …
@ManfredSteyer Creating a Workspace npm install -g @angular/cli ng new
workspace cd workspace ng generate app my-app ng generate lib my-lib ng serve --project my-app ng build --project my-app
@ManfredSteyer Creating a Workspace npm install -g @angular/cli npm init
nx-workspace workspace cd workspace ng generate app my-app ng generate lib my-lib ng serve --project my-app ng build --project my-app
@ManfredSteyer DEMO
@ManfredSteyer DDD in a nutshell
@ManfredSteyer Methodology for bridging the gap b/w requirements and architecture/
design
@ManfredSteyer
@ManfredSteyer Domain Driven Design Strategic Design Tactical Design Decomposing a
System Design Patterns & Practices
@ManfredSteyer Domain Driven Design Strategic Design Tactical Design Decomposing a
System Design Patterns & Practices
@ManfredSteyer
@ManfredSteyer Example Flight System
@ManfredSteyer Booking Check-in Boarding Luggage Example Sub-Domains
@ManfredSteyer Finding Sub-Domains Book Flight Check-in Passenger Check-in Luggage Board
Plane Pickup Luggage Passenger Travel Agency Check-in Agent Boarding Agent
@ManfredSteyer Booking Boarding Bounded Context Ubiquitous Language Flight Price Seats
Passenger Tickets Flight Ticket
@ManfredSteyer Booking Luggage Boarding Check-in Context Map
@ManfredSteyer Booking Boarding Shared Feature Feature Feature Feature Feature UI
UI UI UI UI UI UI UI UI Domain Domain Domain Domain Domain Domain Util Util Util Util Util Util Enterprise Monorepo Patterns, Nrwl 2018: https://tinyurl.com/y2jjxld7 @ManfredSteyer Shared Kernel (if really needed) & other libs Smart Comp. Dumb Comp.
@ManfredSteyer DEMO
@ManfredSteyer
@ManfredSteyer Finegrained Libraries • Units for dep graph • Unit
of recompilation* • Unit of retesting • Access restrictions • Information Hiding • Easy: Just ng g lib …
@ManfredSteyer Restricting Access on a folder basis Rainer Hahnekamp, AngularArchitects
@softarc/eslint-plugin-sheriff
@ManfredSteyer Micro Frontends? Short outlook
@ManfredSteyer Booking App Check-in App Boarding App Luggage App Microfrontends
@ManfredSteyer Shopping Card App Payment App Recommender App Shipping App
Microfrontends
@ManfredSteyer
@ManfredSteyer Booking Boarding Shared Feature Feature Feature Feature Feature …
… … … … … … … … @ManfredSteyer Flight App Deployment Monolith
@ManfredSteyer Booking Boarding Shared Feature Feature Feature Feature Feature …
… … … … … … … … Booking App Boarding App Microfrontends
@ManfredSteyer Booking Boarding Shared Feature Feature Feature Feature Feature …
… … … … … … … … Booking App Boarding App Option 1: One App per Domain Monorepo
@ManfredSteyer Booking Boarding Shared Feature Feature Feature Feature Feature …
… … … … … … … … Booking App Boarding App Option 2: One Monorepo per Domain Publish shared libs seperately via npm Repository n Repository 2 Repository 1
@ManfredSteyer Benefits Autonomous Teams Separate Development Separate Deployment Own architecture
decisions Own technology descisions
@ManfredSteyer Integration via Hyperlinks
@ManfredSteyer UI Composition w/ Hyperlinks µApp SPA µApp SPA µApp
SPA
@ManfredSteyer
@ManfredSteyer
@ManfredSteyer
@ManfredSteyer ✓ Simple Loosing State Load a new
Application
@ManfredSteyer
@ManfredSteyer Web Components for Shared Widgets?
@ManfredSteyer Integration via Shell
@ManfredSteyer µService Providing a (SPA based) Shell µApp µApp µApp
Shell
@ManfredSteyer
@ManfredSteyer Idea const Component = import('other-app/xyz') Does not work with
webpack/ Angular CLI Even lazy parts must be known at compile time!
@ManfredSteyer Webpack 5 Module Federation Shell (Host) Microfrontend (Remote) //
Maps Urls in // webpack config remotes: { mfe1: "http://..." } // Expose files in // webpack config exposes: { Cmp: './my.cmp.ts' } import('mfe1/Cmp')
@ManfredSteyer Dynamic Module Federation Shell (Host) Microfrontend (Remote) remotes: {
} exposes: { Cmp: './my.cmp.ts' } loadRemoteModule({ type: 'module', remoteEntry: 'http://…', exposedModule: './Cmp' })
@ManfredSteyer How to Get the Microfrontend's URL? Shell (Host) Microfrontend
(Remote) RemoteEntrypoint.js <script src="…"></script>
@ManfredSteyer How to Share Libs? Shell (Host) Microfrontend (Remote) shared:
[ "@angular/core", "…" ] shared: [ "@angular/core", "…" ]
@ManfredSteyer
@ManfredSteyer Default Behavior Selecting the highest compatible version ^10.0 ^10.1
@ManfredSteyer Default Behavior Conflict: No highest compatible version ^11.0 ^10.1
@ManfredSteyer Configuring Singletons shared: { "my-lib": { singleton: true }
} 11.0 10.1
@ManfredSteyer Configuring Singletons shared: { "my-lib": { singleton: true, strictVersion:
true // Error instead of warning! } } 11.0 10.1
@ManfredSteyer Relaxing Version Requirements shared: { "my-lib": { requiredVersion: ">=1.0.1
<11.1.1" } }
@ManfredSteyer
@ManfredSteyer ?
@ManfredSteyer Custom Builder
@ManfredSteyer
@ManfredSteyer 1) ng add @angular-architects/module-federation 2) Adjust generated configuration 3)
ng serve
@ManfredSteyer 1) npm i @angular-architects/module-federation -D 2) ng g @angular-architects/module-federation:init
3) Adjust generated configuration 4) ng serve
@ManfredSteyer
@ManfredSteyer
@ManfredSteyer Wrap them into Web Components Angular App (MFE) React
App (MFE)
@ManfredSteyer
@ManfredSteyer await import('other-app/web-cmp');
@ManfredSteyer await import('other-app/web-cmp'); const rootElm = document.createElement('web-cmp') document.body.appendChild(rootElm);
@ManfredSteyer await import('other-app/web-cmp'); const rootElm = document.createElement('web-cmp') document.body.appendChild(rootElm); WrapperComponent
@ManfredSteyer
@ManfredSteyer https://red-ocean-0fe4c4610.azurestaticapps.net
@ManfredSteyer Free eBook (5th Edition) ANGULARarchitects.io/book Module Federation & Nx
@ManfredSteyer Choosing a Solution
@ManfredSteyer Some General Advice Shared state, navigation b/w apps Hyperlinks
Legacy Apps or *very very* strong isolation? iframes Separate Deployment/ mix Technologies? Load Bundles on Demand Monolith little much yes no yes no Module Federation
@ManfredSteyer d Slides & Examples Remote Company Workshops and Consulting
http://angulararchitects.io