DependaMan - Python Dependency Analyzer

🔗 View on Codeberg

A command-line tool and Python library that analyzes a project’s internal module structure and produces an interactive HTML graph. It surfaces architectural problems — circular imports, dead code, coupling hotspots — using nothing but the Python standard library.

Why This Project?

As Python projects grow, their import graphs become impossible to reason about mentally. Linters catch syntax errors; type checkers catch type errors — but nothing tells you that your utils.py is imported by 40 modules and changed 200 times in the last year, or that your helpers.py is completelly filled with functions that nobody uses. DependaMan makes all of that visible.

Usage

Installation:

pip install dependaman

CLI:

dependaman                      # analyze the current directory, open the graph
dependaman /path/to/project     # analyze another project
dependaman --format json -o -   # print the analysis as JSON on stdout
dependaman -o graph.html        # choose the output file
dependaman --no-browser         # write the file, do not open a browser
dependaman --help
FlagMeaning
pathproject root (default: current directory)
-f, --format {html,json}output format (default: html)
-o, --output-path PATHdestination file, or - for stdout
--no-browserdo not open the rendered HTML
--versionprint the installed version

Point dependaman at the directory that contains your top-level package, not at the package itself — imports resolve against the package name, so analyzing myproject/myproject/ leaves most modules without edges.

JSON output is the whole analysis, so it pipes:

dependaman --format json -o - | jq '.cycles'

Python API:

from dependaman import dependaman

dependaman()                                 # writes Dependaman.html, opens it
dependaman("/path/to/project", in_memory=True)  # returns the HTML string
dependaman(".", output_format="json", output_path="graph.json")

Every argument after path is keyword-only:

ArgumentDefaultMeaning
path"."project root to analyze
output_format"html""html" or "json"
in_memoryFalsereturn the rendered text, write nothing
output_pathNonedestination; derived from the format
open_browserTrueopen the written file

With in_memory=True nothing is written and output_path / open_browser are ignored — useful for serving the graph from a web handler.

The analysis is also available on its own, as a dictionary, without rendering or writing anything:

from dependaman.core import analyze

data = analyze(".")     # {"cycles", "callable_cycles", "packages"}

Live Demo

Click nodes to inspect module details — functions, classes, dead callables, fan-in/out. Search by module or function name (/). Drag to reposition. Scroll to zoom. Desktop only — the graph requires a mouse to navigate.