Skip to content

Dependency Graph

The dependency graph shows file-level and module-level dependencies in the legacy codebase. This goes deeper than the context map — it shows which files import which, where shared controllers create coupling, and where circular dependencies exist.

The dependency graph renders cross-module relationships from the ERPNext reference dataset:

  • Nodes represent modules or files
  • Edges show import/dependency relationships
  • Edge weight reflects the strength of coupling (number of shared references)
  • Clusters indicate natural bounded context boundaries
  • Red edges highlight circular dependencies that complicate extraction

Legacy systems accumulate implicit dependencies over years. In ERPNext:

  • accounts_controller.py (4,412 lines) is imported by every transaction type
  • The hooks system creates invisible execution paths across modules
  • Regional overrides create country-specific dependency branches

Understanding these dependencies is a prerequisite for safe extraction. The dependency graph makes the invisible visible.

ERPNext’s controller inheritance chain demonstrates deep coupling:

A single method change in AccountsController can affect every transaction type in the system.

The dependency graph helps identify:

PatternMeaningAction
Dense clusterHigh internal cohesion — good bounded contextExtract as a unit
Few cross-cluster edgesLow external couplingClean extraction boundary
Hub nodeMany incoming/outgoing edges — shared controllerDecompose before extraction
Circular dependencyModules depend on each otherBreak cycle with ACL before extraction