Modular monolith and monorepo
One app and one deploy, split into team-owned modules. Boundary rules checked in CI keep teams out of each other's code, with most of the ownership benefits and little of the runtime cost.
How it works
- Modules per team. Each team owns a module or package in one repository, tagged with its scope.
- Rules on imports. Lint or workspace checks allow only the dependencies the rules permit, for example a team module may use shared libraries but not another team's internals.
- One build. The app builds as one unit, so shared code is bundled once.
- One deploy. Everything ships together; a boundary violation fails CI before it merges.
Pros
- One app and one deploy, with no runtime composition to run.
- Ownership is clear and checked automatically.
- Refactoring across modules stays a normal code change.
Cons
- Teams still share one release.
- One slow build or test suite can slow every team.
- Boundaries erode if the rules are not enforced in CI.
Best when
- One to three teams.
- Teams that need clear ownership but not independent deploys.
- Any team considering micro frontends, as the baseline to compare against.
Avoid when
- Teams are regularly blocked by a shared release.
- Parts of the product must run different frameworks.
- Separate organizations own separate parts.
In code
import nx from "@nx/eslint-plugin";
export default [
...nx.configs["flat/base"],
{
files: ["**/*.ts", "**/*.tsx"],
rules: {
"@nx/enforce-module-boundaries": ["error", {
depConstraints: [
{ sourceTag: "scope:checkout", onlyDependOnLibsWithTags: ["scope:checkout", "scope:shared"] },
{ sourceTag: "scope:search", onlyDependOnLibsWithTags: ["scope:search", "scope:shared"] },
{ sourceTag: "scope:shared", onlyDependOnLibsWithTags: ["scope:shared"] },
],
}],
},
},
];import nx from "@nx/eslint-plugin";
export default [
...nx.configs["flat/base"],
{
files: ["**/*.ts", "**/*.tsx"],
rules: {
"@nx/enforce-module-boundaries": ["error", {
depConstraints: [
{ sourceTag: "scope:checkout", onlyDependOnLibsWithTags: ["scope:checkout", "scope:shared"] },
{ sourceTag: "scope:search", onlyDependOnLibsWithTags: ["scope:search", "scope:shared"] },
{ sourceTag: "scope:shared", onlyDependOnLibsWithTags: ["scope:shared"] },
],
}],
},
},
];Tooling and ecosystem
This is not a lesser option. Natalia Venditto calls modularization a valid and efficient way to decouple a monolith, and more often than not the most suitable one. What sets it apart from micro frontends is that the modules are still deployed together.
In Nx, the @nx/enforce-module-boundaries lint rule checks imports and package.json dependencies against tags you give each project, and fails linting when a project depends on one its tags don’t allow. Untagged projects can’t depend on anything unless a rule allows *, and neither can a project whose tags match no rule, so every tag you use needs one. Turborepo’s turbo boundaries command checks for imports outside a package’s directory and for dependencies missing from its package.json, and supports tag-based rules; it is marked experimental.