Installations
npm install @angular-architects/ddd
Developer Guide
Typescript
Yes
Module System
CommonJS
Min. Node Version
>=18
Node Version
20.18.1
NPM Version
10.8.2
Releases
Contributors
Languages
TypeScript (94.9%)
JavaScript (2.93%)
HTML (1.79%)
SCSS (0.3%)
CSS (0.07%)
Developer
angular-architects
Download Statistics
Total Downloads
690,669
Last Day
149
Last Week
4,119
Last Month
16,948
Last Year
221,769
GitHub Statistics
323 Stars
40 Commits
56 Forks
7 Watching
12 Branches
4 Contributors
Package Meta Information
Latest Version
19.0.5
Package Id
@angular-architects/ddd@19.0.5
Unpacked Size
118.16 kB
Size
24.86 kB
File Count
138
NPM Version
10.8.2
Node Version
20.18.1
Publised On
03 Dec 2024
Total Downloads
Cumulative downloads
Total Downloads
690,669
Last day
-8.6%
149
Compared to previous day
Last week
4%
4,119
Compared to previous week
Last month
0.2%
16,948
Compared to previous month
Last year
2.6%
221,769
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
DDD Plugin for Angular Nx Monorepos
Versions
The package versions are aligned with the Angular version.
- for Nx < v19 and NG v17 use v17.0.5.
- for Nx < v20 and NG v18 use v18.0.1.
- for Nx >= v20 and NG v18 use v18.1.1.
- for Nx >= v20 and NG v19 use v19.0.5.
Breaking change in v18.1.0:
The naming of the Nx includePaths
has changed to only use one "/".
Until v18.0.1, the generated includePaths
were like this, which is illegal in npm:
1 "@org/booking/domain": ["libs/booking/domain/src/index.ts"], 2 "@org/booking/feature-test": ["libs/booking/feature-test/src/index.ts"]
Starting with v18.1.0, the generated includePaths
are using dashes instead:
1 "@org/booking-domain": ["libs/booking/domain/src/index.ts"], 2 "@org/booking-feature-test": ["libs/booking/feature-test/src/index.ts"]
About
This plugin installs some schematics which automate slicing your Nx workspace into domains and layers according to Nrwl's best practices and our ideas about client-side DDD with Angular:
The generated access restrictions prevent unwanted access between libraries respecting layers and domains:
Features
- 🗺️ Generating domains with domain libraries including a facades, models, and data services
- ⚙️ Generating feature libraries including a feature components using the facades
- 🙅♂️ Adding linting rules for access restrictions between domains as proposed by Nrwl
- 🙅♀️ Adding linting rules for access restrictions between layers as proposed by Nrwl (supports tslint and eslint)
- 🔥 Optionally generates skeleton for NGRX and integrates it into the DDD design (
--ngrx
switch, needs @ngrx/schematics) - 💥 Supports Standalone Components
Features Overview Video
Usage
Add this plugin to a Nx workspace:
npm i @angular-architects/ddd
nx g @angular-architects/ddd:init
Instead, you can also use ng add, however, Nx currently emits a warning when using ng add:
nx add @angular-architects/ddd
Add domains and features manually:
nx g @angular-architects/ddd:domain booking --addApp
nx g @angular-architects/ddd:domain boarding --addApp
nx g @angular-architects/ddd:feature search --domain booking --entity flight
nx g @angular-architects/ddd:feature cancel --domain booking
nx g @angular-architects/ddd:feature manage --domain boarding
For NGRX support, just add the --ngrx
switch:
nx g @angular-architects/ddd:domain luggage --addApp --ngrx
nx g @angular-architects/ddd:feature checkin --domain luggage --entity luggage-list --ngrx
[...]
This example assumes that you have an app flight-app
in place.
These schematics also wire up the individual libs. To see the result, create a dependency graph:
npm run dep-graph
To see that the skeleton works end-to-end, call the generated feature component in your app.component.html
:
1<booking-search></booking-search>
You don't need any TypeScript or Angular imports. The plugin already took care about that. After running the example, you should see something like this:
Standalone Components
All generators have a switch --standalone
to support Standalone Components:
ng g @angular-architects/ddd:domain booking --addApp --standalone
ng g @angular-architects/ddd:feature search --domain booking --entity flight --standalone
Don't mix Standalone Components and traditional ones within the same domain.
Since version 19, standalone defaults to true.
Generated Structure
The included schematics generate a folder for each domain. This folder contains feature libs as well as a library with the domain logic:
The domain layer is subdivided into three parts:
Generated Structure for Domain Library
- application: Contains application services. This is a DDD term for what we call facades in Angular nowadays. They orchestrate everything for a use case given so that a feature component only needs to communicate with one such facade. Also, it hides details for state management. While the generates facades just use a
BehaviorSubject
, feel free to add a library like NGRX underneath. As such a modifications changes nothing from the component's perspective, you can use facades to introduce NGRX later on demand. - entities: Client-side data model including logic operating on it (like validations).
- infrastructure: Services for communicating with the backend.
Consider Automatically Checking Access Restrictions
As the access restrictions defined with Nx use linting, you can check against them at the command line too. Hence, you might consider including this into your automated build process.
Demo Application
see https://github.com/angular-architects/ddd-demo
Resources
- Nx
- Nrwl's eBook about monorepos and best practices
- Recording of session about this architecture
- Article series about DDD with Angular
- Our eBook on Enterprise Angular
More Architecture
Get in touch with authors
No vulnerabilities found.
Reason
19 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
Found 1/24 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 7 are checked with a SAST tool
Reason
11 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-92r3-m2mg-pj97
- Warn: Project is vulnerable to: GHSA-c24v-8rfc-w8vw
- Warn: Project is vulnerable to: GHSA-8jhw-289h-jh2g
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986 / GHSA-64vr-g452-qvp3
- Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
Score
2.6
/10
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More