A CLI tool that parses dependency files from real projects, builds directed graphs, detects circular dependencies, and visualizes them as interactive force-directed graphs. Built from scratch with zero graph library dependencies.
- Interactive Web Dashboard — D3.js force-directed graph with drag, zoom, search, and SVG export. Nodes are sized by criticality (PageRank) and can be overlaid with license and vulnerability data
- Multi-format parsing —
requirements.txt,package.json/package-lock.json,go.mod,Cargo.toml,Gemfile,pom.xml, custom YAML, with versions captured where available - Dependency diff — Compare two files, or one file across two git revisions, to see added, removed, and version-bumped packages
- Impact & criticality — Blast-radius analysis (what breaks if a package changes) plus PageRank ranking of the most depended-upon packages
- License overlay — Offline SPDX classification that flags copyleft licenses, read from metadata already on disk
- Security audit — Offline match against a locally-downloaded OSV database export (no live API calls)
- Cycle detection — Iterative DFS with back-edge tracking, handles 10,000+ node graphs
- Strongly connected components — Tarjan's algorithm finds tightly-coupled clusters
- Topological sorting — Kahn's algorithm for build-order resolution
- Multiple export formats — Graphviz DOT, JSON, ASCII tree
- Plugin architecture — Register custom parsers via decorator or function call
git clone https://github.com/atikulmunna/dependency-visualizer.git
cd dependency-visualizer
pip install .This installs dgvis as a global command — no PYTHONPATH setup needed.
Point dgvis at any dependency file from a real project on your machine:
# Node.js project (best results — hundreds of deps)
dgvis web C:\path\to\your-project\package-lock.json
# Python project
dgvis web C:\path\to\your-project\requirements.txt
# Go project
dgvis web C:\path\to\your-project\go.modThis opens an interactive graph dashboard in your browser at http://127.0.0.1:8080.
Dashboard controls:
- Drag any node to rearrange
- Scroll to zoom in/out
- Click a node to highlight its dependency chain and everything that depends on it
- Type in the search box to find specific packages
- Export SVG button to download the graph
- Press Ctrl+C in the terminal to stop the server
Options:
| Flag | Description |
|---|---|
--port 3000 or -p 3000 |
Use a different port |
--no-open |
Don't auto-open the browser |
--watch or -w |
Auto-reload when the file changes |
--licenses |
Overlay license info; copyleft packages get an orange ring |
--audit <osv_dir> |
Overlay vulnerabilities from a local OSV export; hits get a red ring |
dgvis has 11 commands. All work with any supported file format.
python -m dgvis analyze C:\path\to\package.json
# Output:
# ─── Dependency Graph Analysis ───
# Nodes : 11
# Edges : 11
# Cycles : None ✓# ASCII tree (default)
python -m dgvis visualize C:\path\to\requirements.txt
# Graphviz DOT
python -m dgvis visualize deps.yaml -f dot -o graph.dot
# JSON
python -m dgvis visualize deps.yaml -f json -o graph.jsonpython -m dgvis detect-cycles C:\path\to\deps.yaml
# ⚠ Found 1 cycle(s):
# 1. service-a → service-b → service-c → service-apython -m dgvis stats C:\path\to\requirements.txt -v
# Shows topological order, per-node dep counts, etc.python -m dgvis scc C:\path\to\deps.yaml
# ⚠ Found 1 tightly-coupled cluster(s):
# 1. [3 nodes] service-c ↔ service-b ↔ service-apython -m dgvis rank C:\path\to\package-lock.json -n 10
# ─── Most Critical Dependencies (PageRank) ───
# 1. debug 0.1042 █████████████████████
# 2. ms 0.0871 █████████████████Uses PageRank so a package that many others depend on ranks highest. These are the packages most worth keeping healthy.
python -m dgvis impact C:\path\to\deps.yaml crypto
# ─── Impact of crypto ───
# 2 package(s) would be affected if it changed:
# • app
# • authYou can pass a short name (e.g. gin); it resolves to the full node id when unambiguous.
# Two files
python -m dgvis diff old\requirements.txt new\requirements.txt
# One file across two git revisions (local git only, no network)
python -m dgvis diff HEAD~1 HEAD --git requirements.txt
# + rich (added)
# - six (removed)
# ~ flask: 2.0.0 -> 2.3.2 (version bump)python -m dgvis licenses C:\path\to\package-lock.json
# Groups packages into permissive / weak-copyleft / copyleft / unknown
# and flags copyleft licenses for compliance review.License data is read from metadata already on disk (npm lockfile license fields and any node_modules/ tree). No network calls.
python -m dgvis audit C:\path\to\requirements.txt --db C:\path\to\osv-export
# ─── Security Audit ───
# ⚠ 1 vulnerability(ies) across 1 package(s):
# [email protected]
# • OSV-2023-XXXX [severity 7.5]Matches package name and version against a locally-downloaded OSV database export. Download the export once (out of band); auditing itself is fully offline.
dgvis web C:\path\to\package-lock.json
dgvis web C:\path\to\requirements.txt -p 3000 --no-open
dgvis web C:\path\to\Cargo.toml --watch # auto-reload on changes
dgvis web C:\path\to\package-lock.json --licenses # color by license
dgvis web C:\path\to\requirements.txt --audit C:\path\to\osv-export # flag vulnsNodes are sized by PageRank (bigger = more depended on). With --licenses, copyleft packages get an orange ring; with --audit, vulnerable packages get a red ring. Click any node to see its version, license, dependents, and dependencies.
| Ecosystem | File | What it parses |
|---|---|---|
| Node.js | package-lock.json |
Full transitive dependency tree (best results) |
| Node.js | package.json |
Direct deps + devDeps. Auto-uses lock file if present |
| Python | requirements.txt |
Direct dependencies with version specifiers |
| Go | go.mod |
Direct module dependencies |
| Rust | Cargo.toml |
Dependencies, dev-dependencies, build-dependencies |
| Ruby | Gemfile |
All gem declarations including groups |
| Java | pom.xml |
Maven dependency artifacts |
| Custom | *.yaml / *.yml |
Manual dependency graph definition |
project: my-app
dependencies:
app:
- auth
- database
auth:
- crypto
database:
- connection-pool
crypto: []
connection-pool: []dgvis/
├── cli.py → Click CLI with 11 commands
├── parser.py → Format detection + parsers + version capture + plugin registry
├── graph.py → Node/Graph (adjacency list, no external libs) + short_label
├── analyzer.py → DFS, Tarjan's SCC, topo sort, BFS depth, dependents, PageRank
├── differ.py → Dependency diffing (files or git revisions)
├── licenses.py → Offline SPDX license extraction + classification
├── security.py → Offline OSV vulnerability matching
├── exporter.py → DOT, JSON, ASCII tree renderers
├── web/ → D3.js dashboard + HTTP server
└── __main__.py → python -m dgvis entry point
Input File → Parser → {node: [deps]} → Graph → Analyzer / Exporter / Web UI
When you run dgvis web Cargo.toml, the parser first auto-detects the format based on filename and extension. Each parser reads the file and extracts dependencies into a simple dictionary:
# Input: Cargo.toml
# Output:
{"__root__": ["serde", "tokio", "clap"]}
# Input: simple.yaml (with nested deps)
# Output:
{"app": ["auth", "database"], "auth": ["crypto"], "database": ["connection-pool"]}For flat formats (requirements.txt, Cargo.toml, Gemfile, pom.xml), all packages are listed under a synthetic __root__ node. For tree formats (YAML, package-lock.json), the full parent→child relationships are preserved.
Node ids keep the fully-qualified name (for example github.com/gin-gonic/gin or com.google.guava:guava) so packages that share a short name stay distinct. Displays shorten them to the last segment for readability, with the full id available on hover.
The dictionary is converted into a directed graph using a hand-built adjacency list (no NetworkX or igraph):
app → [auth, database]
auth → [crypto]
database → [connection-pool]
crypto → []
connection-pool → []
Each node stores its name and outgoing edges. The graph supports O(1) neighbor lookup and O(V+E) traversals.
Several algorithms run on the graph, all implemented iteratively (no recursion limits):
-
Cycle Detection (DFS): Walks the graph tracking a recursion stack. When a node is visited that's already on the stack, a cycle is found. The path is extracted by backtracking through the stack. Time: O(V+E).
-
Tarjan's SCC: Finds strongly connected components — groups of nodes that all depend on each other (directly or transitively). Uses a single DFS pass with a stack and low-link values. Any SCC with >1 node indicates circular coupling. Time: O(V+E).
-
Topological Sort (Kahn's): Computes a valid build order by repeatedly removing nodes with zero in-degree. If all nodes are processed, the graph is acyclic. Time: O(V+E).
-
Depth Calculation (multi-source BFS): Starting from all root nodes (zero in-degree) at once, BFS assigns each node a depth level. Used by the web UI to color nodes — lighter nodes are closer to a root, darker nodes are deeper leaves.
-
Impact / Blast Radius (reverse-reachability DFS): Walks the reversed graph from a node to find every package that depends on it, directly or transitively. Time: O(V+E).
-
Criticality (PageRank): The iterative power method ranks nodes by how depended-upon they are; a package many others rely on scores highest. Used to size nodes in the dashboard.
The web UI works in three steps:
-
Data injection: The server builds a JSON payload containing nodes, edges, depths, PageRank scores, cycles, SCCs, roots, leaves, and any license or vulnerability annotations. This JSON is injected into the HTML template, replacing the placeholder with real data.
-
Force simulation: D3.js creates a force-directed layout where nodes repel each other and edges act as springs. Nodes are colored on a white-to-gray gradient based on depth and sized by PageRank (bigger = more depended on). SCC nodes get dashed borders; with
--licensescopyleft packages get an orange ring, and with--auditvulnerable packages get a red ring. -
Interactivity: Click a node to highlight its transitive dependency chain plus everything that depends on it, and to see its version, license, and any vulnerabilities. The search box filters nodes in real-time. SVG export captures the current layout.
When --watch is enabled, a background thread polls the file's modification time every second. When a change is detected:
File changed → Re-parse → Rebuild graph → Re-render HTML → Browser auto-reloads
The browser polls a /__hash endpoint every 1.5 seconds. When the hash changes (indicating new data), the page reloads automatically.
| Algorithm | Use | Complexity |
|---|---|---|
| Iterative DFS | Cycle detection | O(V + E) |
| Tarjan's Algorithm | Strongly connected components | O(V + E) |
| Kahn's Algorithm | Topological sort | O(V + E) |
| Multi-source BFS | Depth calculation across all roots | O(V + E) |
| Reverse-reachability DFS | Impact / blast radius | O(V + E) |
| PageRank (power method) | Dependency criticality ranking | O(k(V + E)) |
Register custom parsers for unsupported file formats:
from dgvis.parser import registry
# Decorator form
@registry.register(extensions=[".lock"], filenames=["Pipfile.lock"])
def parse_pipfile_lock(filepath):
# Return {parent: [dep1, dep2], ...}
...
# Imperative form
registry.register_parser(my_parser, extensions=[".toml"])Plugins take priority over built-in parsers. Use registry.clear() to reset.
Add to any repo's .github/workflows/ to check dependencies on every push:
name: Dependency Check
on: [push, pull_request]
jobs:
check-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install click pyyaml
- run: |
git clone --depth 1 https://github.com/atikulmunna/dependency-visualizer.git /tmp/dgvis
PYTHONPATH=/tmp/dgvis python -m dgvis detect-cycles requirements.txtcp scripts/pre-commit-hook.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commitpython -m pytest tests/ -v
# 193 tests across 11 test files (includes 10k+ node stress test)git clone https://github.com/atikulmunna/dependency-visualizer.git
cd dependency-visualizer
pip install click pyyaml pytest
$env:PYTHONPATH="."; python -m pytest tests/ -vMIT
