@angular-architects/ddd

中文文档
22.0.0发布于 2026/06/08MITTypeScriptCommonJS近 30 天下载 1.2万

Nx plugin for structuring a monorepo with domain driven design

原始使用文档
文档目录13 节
  1. Versions
  2. About
  3. Features
  4. Features Overview Video
  5. Usage
  6. Standalone Components
  7. Generated Structure
  8. Generated Structure for Domain Library
  9. Consider Automatically Checking Access Restrictions
  10. Demo Application
  11. Resources
  12. More Architecture
  13. Get in touch with authors

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.7.
  • for Nx >= v21.2 and NG v20 use v20.0.1.
  • for Nx >= v21.2 (Nx v21-22) and NG v21 use v21.0.0.
  • for Nx >= v21.7 (Nx v21-23) and NG v22 use v22.0.0.

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:

  "@org/booking/domain": ["libs/booking/domain/src/index.ts"],
  "@org/booking/feature-test": ["libs/booking/feature-test/src/index.ts"]

Starting with v18.1.0, the generated includePaths are using dashes instead:

  "@org/booking-domain": ["libs/booking/domain/src/index.ts"],
  "@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](- Blog: All about DDD for Angular & Frontend Architectures):

domains and layers

The generated access restrictions prevent unwanted access between libraries respecting layers and domains:

access restrictions

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

Screenshot of 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

dependency graph

To see that the skeleton works end-to-end, call the generated feature component in your app.component.html:

<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:

Result proving that the generated skeleton works end-to-end

Standalone Components

All generators have a switch --standalone to support Standalone Components:

nx g @angular-architects/ddd:domain booking --addApp --standalone

nx 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:

Folder per Domain

The domain layer is subdivided into three parts:

Structured Domain Layer

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.

Access restrictions via linting

Demo Application

see https://github.com/angular-architects/ddd-demo

Resources

More Architecture

Get in touch with authors

版本与发布记录

@angular-architects/ddd 共发布 54 个版本,首次发布于 2020/03/08;过去 12 个月发布了 2 个版本。

版本发布日期距今
22.0.0latest2026/06/085 个月前
21.0.02026/03/237 个月前
20.0.12025/07/131.3 年前
20.0.02025/06/301.4 年前
19.0.72025/06/301.4 年前
19.0.62025/01/111.8 年前

其他发布通道:v17-lts → 17.0.5,v18-lts → 18.1.1。

关于 @angular-architects/ddd 的常见问题

@angular-architects/ddd 是什么?

Nx plugin for structuring a monorepo with domain driven design

如何安装 @angular-architects/ddd?

在项目目录运行 npm install @angular-architects/ddd,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@angular/core(^22.0.0)、@nx/angular(>=21.7.0 <24.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@angular-architects/ddd 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@angular-architects/ddd 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@angular-architects/ddd 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.19.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@angular-architects/ddd 可以商用吗?

@angular-architects/ddd 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@angular-architects/ddd 的下载量有多少?

根据 npm 官方下载统计,@angular-architects/ddd 在 2026/10/06 – 2026/11/04 这 30 天内被下载 12,396 次,日均约 413 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@angular-architects/ddd 还在维护吗?

最新版本 22.0.0 发布于 2026/06/08(5 个月前);至今共发布 54 个版本,其中过去 12 个月发布了 2 个;首次发布于 2020/03/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。