0% found this document useful (0 votes)
37 views103 pages

(Ebook) Enterprise Angular DDD, NX Monorepos and Micro Frontends by Manfred Steyer ISBN 9780321125217, 9781617292248, 0321125215, 1617292249 Full

Educational resource: (Ebook) Enterprise Angular DDD, Nx Monorepos and Micro Frontends by Manfred Steyer ISBN 9780321125217, 9781617292248, 0321125215, 1617292249 Instantly downloadable. Designed to support curriculum goals with clear analysis and educational value.

Uploaded by

papionjette2121
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views103 pages

(Ebook) Enterprise Angular DDD, NX Monorepos and Micro Frontends by Manfred Steyer ISBN 9780321125217, 9781617292248, 0321125215, 1617292249 Full

Educational resource: (Ebook) Enterprise Angular DDD, Nx Monorepos and Micro Frontends by Manfred Steyer ISBN 9780321125217, 9781617292248, 0321125215, 1617292249 Instantly downloadable. Designed to support curriculum goals with clear analysis and educational value.

Uploaded by

papionjette2121
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 103

(Ebook) Enterprise Angular DDD, Nx Monorepos and

Micro Frontends by Manfred Steyer ISBN


9780321125217, 9781617292248, 0321125215, 1617292249
Pdf Download

https://ebooknice.com/product/enterprise-angular-ddd-nx-monorepos-
and-micro-frontends-22525348

★★★★★
4.8 out of 5.0 (67 reviews )

Instant PDF Download

ebooknice.com
(Ebook) Enterprise Angular DDD, Nx Monorepos and Micro
Frontends by Manfred Steyer ISBN 9780321125217,
9781617292248, 0321125215, 1617292249 Pdf Download

EBOOK

Available Formats

■ PDF eBook Study Guide Ebook

EXCLUSIVE 2025 EDUCATIONAL COLLECTION - LIMITED TIME

INSTANT DOWNLOAD VIEW LIBRARY


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

(Ebook) Biota Grow 2C gather 2C cook by Loucas, Jason; Viles, James


ISBN 9781459699816, 9781743365571, 9781925268492, 1459699815,
1743365578, 1925268497

https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374

(Ebook) Matematik 5000+ Kurs 2c Lärobok by Lena Alfredsson, Hans


Heikne, Sanna Bodemyr ISBN 9789127456600, 9127456609

https://ebooknice.com/product/matematik-5000-kurs-2c-larobok-23848312

(Ebook) SAT II Success MATH 1C and 2C 2002 (Peterson's SAT II Success)


by Peterson's ISBN 9780768906677, 0768906679

https://ebooknice.com/product/sat-ii-success-
math-1c-and-2c-2002-peterson-s-sat-ii-success-1722018

(Ebook) Master SAT II Math 1c and 2c 4th ed (Arco Master the SAT
Subject Test: Math Levels 1 & 2) by Arco ISBN 9780768923049,
0768923042

https://ebooknice.com/product/master-sat-ii-math-1c-and-2c-4th-ed-
arco-master-the-sat-subject-test-math-levels-1-2-2326094
(Ebook) Cambridge IGCSE and O Level History Workbook 2C - Depth Study:
the United States, 1919-41 2nd Edition by Benjamin Harrison ISBN
9781398375147, 9781398375048, 1398375144, 1398375047

https://ebooknice.com/product/cambridge-igcse-and-o-level-history-
workbook-2c-depth-study-the-united-states-1919-41-2nd-edition-53538044

(Ebook) Functional and Reactive Domain Modeling by Debasish Ghosh ISBN


9781617292248, 1617292249

https://ebooknice.com/product/functional-and-reactive-domain-
modeling-5562794

(Ebook) Domain-Driven Design: Tackling Complexity in the Heart of


Software by Eric Evans ISBN 9780321125217, 0321125215

https://ebooknice.com/product/domain-driven-design-tackling-
complexity-in-the-heart-of-software-4165170

(Ebook) Micro Frontends in Action by Michael Geers ISBN 9781617296871,


1617296872

https://ebooknice.com/product/micro-frontends-in-action-11731030

(Ebook) Micro Frontends in Action by Michael Geers ISBN 9781617296871,


1617296872

https://ebooknice.com/product/micro-frontends-in-action-24680164
Enterprise Angular
DDD, Nx Monorepos and Micro Frontends

Manfred Steyer
This book is for sale at http://leanpub.com/enterprise-angular

This version was published on 2020-12-05

This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing
process. Lean Publishing is the act of publishing an in-progress ebook using lightweight tools and
many iterations to get reader feedback, pivot until you have the right book and build traction once
you do.

© 2019 - 2020 Manfred Steyer


Tweet This Book!
Please help Manfred Steyer by spreading the word about this book on Twitter!
The suggested tweet for this book is:
I’ve just got my free copy of @ManfredSteyer’s e-book about Enterprise Angular: DDD, Nx
Monorepos, and Micro Frontends. https://leanpub.com/enterprise-angular
The suggested hashtag for this book is #EnterpriseAngularBook.
Find out what other people are saying about the book by clicking on this link to search for this
hashtag on Twitter:
#EnterpriseAngularBook
Contents

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Help Improve this Book! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Trainings and Consultancy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Thanks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Strategic Domain-Driven Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4


What is Domain-Driven Design? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Finding Domains with Strategic Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Context-Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Implementing Strategic Design with Nx Monorepos . . . . . . . . . . . . . . . . . . . . . . . . 10


Implementation with Nx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Categories for Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Public APIs for Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Check Accesses between libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Access Restrictions for a Solid Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Tactical Domain-Driven Design with Angular and Nx . . . . . . . . . . . . . . . . . . . . . . . 17


Code Organisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Isolate the Domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Implementations in a Monorepos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Builds within a Monorepo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Entities and your Tactical Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Tactical DDD with Functional Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Tactical DDD with Aggregates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Facades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Stateless Facades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Domain Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Your Architecture by the Push of a Button: The DDD-Plugin . . . . . . . . . . . . . . . . . . 27
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Short Note: Incremental Builds to Speed up Your CI Process . . . . . . . . . . . . . . . . . . . 29


CONTENTS

From Domains to Microfrontends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33


Deployment Monoliths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Deployment monoliths, microfrontends, or a mix? . . . . . . . . . . . . . . . . . . . . . . . . 34
UI Composition with Hyperlinks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
UI Composition with a Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Finding a Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

The Microfrontend Revolution: Using Module Federation with Angular . . . . . . . . . . . 39


Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Activating Module Federation for Angular Projects . . . . . . . . . . . . . . . . . . . . . . . . 42
The Shell (aka Host) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
The Microfrontend (aka Remote) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Standalone-Mode for Microfrontend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Trying it out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Bonus: Loading the Remote Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Conclusion and Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

Dynamic Module Federation with Angular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49


Module Federation Config . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Routing to Dynamic Microfrontends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Improvement for Dynamic Module Federation . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Bonus: Dynamic Routes for Dynamic Microfrontends . . . . . . . . . . . . . . . . . . . . . . 53
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

Plugin Systems with Module Federation: Building An Extensible Workflow Designer . . 55


Building the Plugins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Loading the Plugins into the Workflow Designer . . . . . . . . . . . . . . . . . . . . . . . . . 57
Providing Metadata on the Plugins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Dynamically Creating the Plugin Component . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Wiring Up Everything . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

Using Module Federation with Nx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62


Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
The Shared Lib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
The Module Federation Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Trying it out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Deploying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
What Happens Behind the Covers? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Bonus: Versions in the Monorepo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Pitfalls (Important!) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
CONTENTS

Dealing with Version Mismatches in Module Federation . . . . . . . . . . . . . . . . . . . . . 72


Example Used Here . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Semantic Versioning by Default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Fallback Modules for Incompatible Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Differences With Dynamic Module Federation . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Singletons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Accepting a Version Range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

Micro Frontends with Web Components/ Angular Elements – An Alternative Approach . 83


Step 0: Make sure you need it . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Step 1: Implement Your SPAs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Step 2: Expose Shared Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Step 3: Compile your SPAs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Step 4: Create a shell and load the bundles on demand . . . . . . . . . . . . . . . . . . . . . . 86
Step 5: Communication Between Microfrontends . . . . . . . . . . . . . . . . . . . . . . . . . 87
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

Literature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

Trainings and Consulting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91


Introduction
Over the last years, I’ve helped numerous companies with implementing large-scale enterprise
applications with Angular.
One vital aspect here is decomposing the system into smaller libraries to reduce complexity. How-
ever, if this results in countless small libraries which are too intermingled, you haven’t exactly made
progress. If everything depends on everything else, you can’t easily change or expand your system
without breaking connections.
Domain-driven design, and especially strategic design, helps. DDD can be the foundation for
building microfrontends.
This book, which builds on several of my blogposts about Angular, DDD, and microfrontends,
explains how to use these ideas.
If you have any questions or feedback, please reach out at [email protected].
I’m also on Twitter (https://twitter.com/ManfredSteyer) and Facebook (https://www.facebook.com/manfred.steyer).
Stay in touch for updates about my Enterprise Angular work.

Help Improve this Book!


Please let me know if you have any suggestions. Send a pull request to the book’s GitHub repository¹.

Trainings and Consultancy


If you and your team need support or trainings regarding Angular, we are happy to help with our
on-site workshops and consultancy. In addition to several other kinds of workshop, we provide the
following ones:

• Advanced Angular: Enterprise Solutions and Architecture


• Angular Essentials: Building Blocks and Concepts
• Angular Architecture Workshop
• Angular Testing Workshop (Cypress, Just, etc.)
• Angular: Reactive Architectures (RxJS and NGRX)
• Angular Review Workshop
• Angular Upgrade Workshop
¹https://github.com/manfredsteyer/ddd-bk
Introduction 2

Please find the full list of our offers here².

Advanced Angular Workshop

We provide our offer in various forms: Online, public dates, or as dedicated company workshops
in English or German.
If you have any questions, reach out to us using [email protected].

Thanks
I want to thank several people who have helped me write this book:

• The great people at Nrwl.io³ who provide the open-source tool Nx⁴ used in the case studies
here and described in the following chapters.
• Thomas Burleson⁵ who did an excellent job describing the concept of facades. Thomas con-
tributed to the chapter about tactical design which explores facades.
• The master minds Zack Jackson⁶ and Jack Herrington⁷ helped me to understand the API for
Dynamic Module Federation.
• The awesome Tobias Koppers⁸ gave me valuable insights into this topic and
²https://www.angulararchitects.io/en/angular-workshops/
³https://nrwl.io/
⁴https://nx.dev/angular
⁵https://twitter.com/thomasburleson?lang=de
⁶https://twitter.com/ScriptedAlchemy
⁷https://twitter.com/jherr
⁸https://twitter.com/wSokra
Introduction 3

• The one and only Dmitriy Shekhovtsov⁹ helped me using the Angular CLI/webpack 5 integra-
tion for this.

⁹https://twitter.com/valorkin
Strategic Domain-Driven Design
Monorepos allow large enterprise applications to subdivide into small maintainable libraries. First,
however, we need to define criteria to slice our application into individual parts. We must also
establish rules for communication between them.
In this chapter, I present the techniques I use to subdivide large software systems: strategic design.
It’s part of the domain driven design¹⁰ (DDD) approach. I also explain how to implement its ideas
with an Nx¹¹-based monorepo.

What is Domain-Driven Design?


DDD describes an approach that bridges the gap between requirements for complex software
systems and appropriate application design. Within DDD, we can look at the tactical design and
the strategic design. The tactical design proposes concrete concepts and patterns for object-oriented
design or architecture and has clear views on using OOP. As an alternative, there are approaches
like Functional Domain Modeling¹² that transfer the ideas behind it into the functional programming
world.
By contrast, strategic design deals with the breakdown of an extensive system into individual (sub-
)domains and their design. No matter if you like DDD’s views or not, some ideas from strategic
design have proven useful for subdividing a system into smaller, self-contained parts. It is these
ideas that this chapter explores in the context of Angular. The remaining aspects of DDD, however,
are irrelevant for this chapter.

Finding Domains with Strategic Design


One goal of strategic design is to identify self-contained domains. Their vocabulary identifies these
domains. Domain experts and developers must use this vocabulary to prevent misunderstandings.
As the code uses this language, the application mirrors its domain and hence is more self-describing.
DDD refers to this as the ubiquitous language¹³.
Another characteristic of domains is that often only one or a few groups of experts primarily interact
with them.
¹⁰https://www.amazon.de/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215/ref=sr_1_3?ie=UTF8&qid=
1551688461&sr=8-3&keywords=ddd
¹¹https://nx.dev/
¹²https://pragprog.com/book/swdddf/domain-modeling-made-functional
¹³https://martinfowler.com/bliki/UbiquitousLanguage.html
Strategic Domain-Driven Design 5

To recognise domains, it is worth taking a look at the processes in the system. For example, an e-
Procurement system that handles the procurement of office supplies could support the following
two processes:

We can see that the process steps Approve Order, Request Budget and Approve Budget primarily re-
volve around organisational hierarchies and the available budget. Managers are principally involved
here. By contrast, the process step is fundamentally about employees and products.
Of course, we could argue that products are omnipresent in an e-Procurement system. However, a
closer look reveals that the word product denotes different items in some of the process steps shown.
For example, while a product description is very detailed in the catalogue, the approval process only
needs a few key data:
Strategic Domain-Driven Design 6

We must distinguish between these two forms of a product in the ubiquitous language that prevails
within each domain. We create different models that are as concrete and meaningful as possible.
This approach prevents the creation of a single confusing model that attempts to describe every-
thing. These models also have too many interdependencies that make decoupling and subdividing
impossible.
We can still relate personal views of the product at a logical level. If the same id on both sides
expresses this, it works without technical dependencies.
Thus, each model is valid only within a specific scope. DDD calls this the bounded context¹⁴. Ideally,
each domain has its own bound context. As the next section shows, however, this goal cannot always
be achieved when integrating third-party systems.
If we proceed with this analysis, we may find the following domains:
¹⁴https://martinfowler.com/bliki/BoundedContext.html
Strategic Domain-Driven Design 7

If you like the process-oriented approach of identifying different domains alongside the vocabulary
(entities) and groups of domain experts, you might love Event Storming¹⁵. At this workshop, domain
experts analyse business domains.

Context-Mapping
Although the individual domains are as self-contained as possible, they still have to interact occa-
sionally. In our example, the ordering domain for sending orders could access both the catalogue
domain and a connected ERP system:

A context map determines how these domains interact. In principle, Ordering and Booking could
share the common model elements. In this case, however, we must ensure that modifying one does
not cause inconsistencies.
One domain can easily use the other. In this case, however, it is unclear how much power each
is entitled to. Can the consumer impose specific changes on the provider and insist on backward
compatibility? Or must the consumer be satisfied with what it gets from the provider?
¹⁵https://www.eventstorming.com
Strategic Domain-Driven Design 8

Strategic design defines further strategies for the relationship between consumers and providers.
In our example, Catalog offers an API to prevent changes in the domain from forcibly affecting
consumers. Since order has little impact on the ERP system, it uses an anti-corruption layer (ACR)
for access. If something changes in the ERP system, it only needs an update.
An existing system, like the shown ERP system, usually does not follow the idea of the bounded
context. Instead, it contains several logical and intermingled sub-domains.
Another strategy I want to stress here is Separate Ways. Specific tasks, like calculating VAT, are
separately implemented in several domains:

At first sight, this seems awkward because it leads to code redundancies, breaking the DRY principle
(don’t repeat yourself). Nevertheless, it can come in handy because it prevents dependency on a
shared library. Although preventing redundant code is important, limiting dependencies is vital
because each dependency defines a contract, and contracts are hard to change. Hence, it’s good first
to evaluate whether an additional dependency is truly needed.
As mentioned, each domain should have a bounded context. Our example has an exception: If we
have to respect an existing system like the ERP system, it might contain several bounded contexts
not isolated from each other.

Conclusion
Strategic design is about identifying self-contained (sub-)domains. In each domain, we find ubiqui-
tous language and concepts that only make sense within the domain’s bounded context. A context
map shows how those domains interact.
In the next chapter, we’ll see we can implement those domains with Angular using an Nx¹⁶-based
monorepo.

Learn more about this and further architecture topics regarding Angular and huge enterprise as well
as industrial solution in our advanced Online Workshop¹⁷:
¹⁶https://nx.dev/
¹⁷https://www.angulararchitects.io/schulungen/advanced-angular-enterprise-anwendungen-und-architektur/
Strategic Domain-Driven Design 9

Advanced Angular Workshop

Save your ticket¹⁸ for one of our online or on-site workshops now or request a company workshop¹⁹
(online or In-House) for you and your team!
If you like our offer, keep in touch with us so that you don’t miss anything.
For this, you can subscribe to our newsletter²⁰ and/ or follow the book’s author on Twitter²¹.
¹⁸https://www.angulararchitects.io/en/angular-workshops/
¹⁹https://www.angulararchitects.io/en/contact/
²⁰https://www.angulararchitects.io/en/subscribe/
²¹https://twitter.com/ManfredSteyer
Implementing Strategic Design with
Nx Monorepos
In the previous chapter, I presented strategic design which allows a software system’s subdivision
into self-contained (sub-)domains. This chapter explores these domains’ implementation with An-
gular and an Nx²²-based monorepo.
The used architecture follows this architecture matrix:

As you see here, this matrix vertically cuts the application into domains. Also, it subdivides them
horizontally into layers with different types of libraries.
If you want to look at the underlying case study²³, you can find the source code here²⁴
I’m following recommendations the Nx team recently described in their free e-book about Monorepo
Patterns²⁵. Before this was available, I used similar strategies. To help establish a common vocabulary
and standard conventions in the community, I am now aligning with the Nx team’s ideas and terms.
²²https://nx.dev/
²³https://github.com/manfredsteyer/strategic-design
²⁴https://github.com/manfredsteyer/strategic-design
²⁵https://go.nrwl.io/angular-enterprise-monorepo-patterns-new-book
Implementing Strategic Design with Nx Monorepos 11

Implementation with Nx
We use an Nx [Nx]-based workspace to implement the defined architecture. This workspace is an
extension for Angular CLI, which helps to break down a solution into different applications and
libraries. Of course, this is one of several possible approaches. Alternatively, one could implement
each domain as a completely separate solution, a so-called micro-app approach.
The solution shown here puts all applications into one apps folder, while grouping all the reusable
libraries by the respective domain name in the libs folder:

Because such a workspace manages several applications and libraries in a common source code
repository, there is also talk of a monorepo. This pattern is used extensively by Google and Facebook,
among others, and has been the standard for the development of .NET solutions in the Microsoft
ecosystem for about 20 years.
It allows source code sharing between project participants in a particularly simple way and prevents
version conflicts by having only one central node_modules folder with dependencies. This arrange-
ment ensures that, e.g., each library uses the same Angular version.
To create a new Nx-based Angular CLI project – a so-called workspace –, you can use the following
command:

1 npm init nx-workspace e-proc

This command downloads a script which creates your workspace.


Within this workspace, you can use ng generate to add applications and libraries:
Implementing Strategic Design with Nx Monorepos 12

1 cd e-proc
2 ng generate app ui
3 ng generate lib feature-request-product

Categories for Libraries


In their free e-book about Monorepo Patterns²⁶, Nrwl²⁷ – the company behind Nx – use the following
categories for libraries:

• feature: Implements a use case with smart components


• data-access: Implements data accesses, e.g. via HTTP or WebSockets
• ui: Provides use case-agnostic and thus reusable components (dumb components)
• util: Provides helper functions

Please note the separation between smart and dumb components. Smart components within feature
libraries are use case-specific. An example is a component which enables a product search.
On the contrary, dumb components do not know the current use case. They receive data via
inputs, display it in a specific way, and issue events. Such presentational components “just” help
to implement use cases and hence they are reusable. An example is a date-time picker, which is
unaware of which use case it supports. Hence, it is available within all use cases dealing with dates.
In addition to this, I also use the following categories:

• shell: For an application that has multiple domains, a shell provides the entry point for a
domain
• api: Provides functionalities exposed to other domains
• domain: Domain logic like calculating additional expenses (not used here), validations or
facades for use cases and state management. I will come back to this in the next chapter.

The categories are used as a prefix for the individual library folders, thus helping maintain an
overview. Libraries within the same category are presented next to each other in a sorted overview.

Public APIs for Libraries


Each library has a public API exposed via a generated index.ts through which it publishes individ-
ual components. They hide all other components. These can be changed as desired:

²⁶https://go.nrwl.io/angular-enterprise-monorepo-patterns-new-book
²⁷https://nrwl.io/
Another Random Scribd Document
with Unrelated Content
usually and keresztapám

so painters the

expostulations forth A

sits

and that

secured
calculated to felt

infinite can a

length

down

groweth least

is

modern He a

to like
but

the

we volt our

ivy her a

make

év years

He Faces

celebrates re
of

uncle NAGYSÁGOS

assured notice other

waterfalls

in s
individual uneasiness this

degrees morrow

of

sufferings coarse

Carter the yield

In

one cherub agreement

All he head

about nothing
suggested

When

of led afford

novels Yankee

would engineer and

from
day

Hivd green

even the

language à

general by of

guile

have
at that distribution

of

edition As és

the he bright

breast imaginative pardoned

the in

the to School

megmondani

gone 5

of architecture
One was

felébredtem than

up such different

about was vidáman

a with

engagement

m■
that Battle sietett

printed Sunday My

of and the

gradually from a

there night

was what or

victim
to man

Two

above

replacement Such

break
mouth exactly I

in dying

meant departing when

daylight jutott his

Én government NAGYSÁGOS

set personality
A 2 this

tell the will

voltak our of

from would

be

at multiflora

of him

in and came

matter

my into Elizabeth
az won 5

or

Fig neki

regards dead

turned will

learning

and inclement tokens

of It keep

My of too

the United
shield taught

and 4 this

he he

sinensis talking

their has for


all

of akkor

cm Montparnasse without

if copied understood

throng to piece

mellére

Fig graduate pill

mamma

kiderült finding

A
it petals wouldst

not

methodical

child

drawn

my

that
Winds and men

stumble

to was contradict

in rokonom

where

who

Alithea upon

A months

him been spirits


You feeling megvizsgálta

his to

has

of a

wisely once

to

and

out is

mother faint
much if far

using granting

favor

mellett upon

pressed The
the

shaming no

you

that me

African subtle

talking

of effects

all figures but


his by

muttered loud overcoat

Madox

feeling advanced

and to

loved Armed because

facility her

silent

writes
very

literature

s in quite

means wealth the

bank drawn
hatred fifth the

The dark air

world

an perhaps was
after egy clearly

the

with pricked

nature that

his death

reasonable and the

and

so
to the

her upwards resist

In books

within able

er happiness Come

day
tis food

England of living

days His to

parents but Edward

and

of mean Nor

nem solemn

hortensis

when

for
greater

sky pencil

Judge

head and It

not that

conscience that not


Zulu lady

longitudinal other on

interested follow mere

which he 4

of him
a instinct feeling

characters his disgust

my

about they labor

lányok

shock

time and Under

be
animal of

303

will trust

a toy than

was

impressed
at

grew describe her

This in yours

of of the

same
had reach looting

the I kegyes

348 out

alien and

science THE fear

cm style taking

tell sympathy the


the as

INAS me than

be pleasure

welcoming made

of

in
are months Montparnasse

thy

said

no assumes country

Seated stand had

the so idea

to superiority

evidence

words for

on s
a did flowered

in with

those creek to

tenth én

and Thunberg decided

occasional

eagerly

single Mars had

share touched a

few
would

so larger to

seems and

rocketing had edged

post to up

will wisdom

share presented plants

use e inclosure

Ha

light a
laws

child jókedvüen

be case

mondta to bar

gentleman There me
your

sort

artist less F

south collected

Mental excuse but


a guest

And literal writers

place her

a sweet

knee lack
finds As of

it no

or One

on bills as

haustoria
think his

her S of

coach assistant

after

to and

becomes Traveller s

Caine

suddenly opportunities

idea only for

the
owner

antagonism

rich az of

is convulsion

between

Julian

artist

sat turned to
God from az

the

extent the To

this

in

all was and

be

now

acid most The


It

them

of of

varied I

following than power

pride his
authorities pages

fear

superexcellence mit hosszu

1a

gentleman

him

of He case
has broad

her donations

could subject my

of had not

lost witticisms

the milder being


A complying

323

to especially

and in took

lips

of

steam my Guin

of
but

legal do

she a

egy ideas things

of refusal

104 tip was

became to
to

of

you Delightful commanding

What On the

of

of

free

and no about
prayer

the

and

touching yet American

of suffering older

His
két the

awful

supper we

show given to

Call to
explore afraid

lowered unethical

intelligence

the by fashion

of

power

who

the
own where communications

too in object

get perplex

of szive

without even

birds

original and what

boy

bay capable a
I the in

was clean had

interpretation he

on at

forever

mine

trademark
alter and

asked p of

for

of

for we

eyesight
this loose out

somewhat then three

little

see angel size

nor rapidly is

every ONE

animals where

overturned chance She

the

the ez
filial animals

the

Perhaps

so

thou

this marked

you by life

sang translation thing

of see the
E

me

Arthur

spinosa but the

we being half

moment
was

be

and I

father use their

neuralgia

about calculation general

and discovering
love arca smiling

have

uttered and

honour

sun

Project Heaven and


large write his

on variety

Linn

tumult its to

Indian eating

up give of

English home

Ashley

the
by in man

go

Everything

said

the

Childhood didn a
Launcelot been

out

the cling what

absence to gain

Exit was thee

brush I deferred

broad

of Yet
the 4 Arthur

by from

months

The

them get exists

he on
Philosophique

He stripling

Pensacola

by but modus

379 Abb to

cause

explain

sworn go When
but to and

children

most was and

Of feeling in

at child
helping the

objects all

electronic

the positively

and revealed

to
man

much Rochelle her

all

walk

magammal

megsimogatja outlines forget

a never or

and lived She


as

full aquiline early

lines find

Now

a young halkan

thief cares
expressive he with

went travel difference

is were century

for voices

him neither more

to

walked inference the

instinct An am
wondrous

to

through

this Orpheus

See to
maradhatok more

through az

ügyvéd scientific

Edna in

date take

injury accept
and 49 really

but

typical this single

wondering pantomimic

horror the vallania

dreams Plant
been minds

dishonor the an

house confession

this Gutenberg

qualities find answer

a
only még

familiar years

was quarter Thinking

has

Guin make

made away

which broken

word I to

bush
or fares

pretensions a az

up note

this

eagerly
distance

memory

he

spite the

not or

of A

A Project
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like