Architecture validation as an integral part of the software development process

Need for modularization

Common errors in implementation

  • Breaking the principles of hermetization and encapsulation (referring to the internal part of the module directly, omitting the defined abstraction),
  • Circular dependency — cyclical dependency of modules,
  • Reference to a component that is not part of our domain module (e.g. crossing the boundaries between two bounded contexts in Domain-Driven Design),

Modularization in Node.js

Dependency cruiser

npm install --save-dev dependency-cruiser
depcruise --init
"depcruise:check": "npx dependency-cruiser src --config .dependency-cruiser.js",
name: 'not-from-application-to-domain-layer',
severity: 'error',
comment: 'Domain should not depend on application layer',
to: {
path: '^src/application',
from: {
path: '^src/domain',
> npx dependency-cruiser src --config .dependency-cruiser.jserror not-from-application-to-domain-layer: 
→ src/application/application.module.ts
✖ 1 dependency violations (1 errors, 0 warnings).
2 modules, 20 dependencies cruised.
  • Referencing dev-dependencies or dependencies not defined in package.json.
  • Dependence of Source Code on Tests.

Or maybe unit tests?

describe("Architecture dependency unit test", ()=> {
it("domain layer should not depend
on application layer",
async ()=> {
const rule = filesOfProject()
await expect(rule).toPassAsync()




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


iteo is an international technology consultancy & software engineering company, founded in Poland. Visit us on