Engineering
cargo-coupling avatar

cargo-coupling

Rust-based architecture analysis tool for measuring code coupling, identifying refactoring hotspots, and visualizing dependency graphs using the Vlad Khononov framework.

Introduction

cargo-coupling is an architectural analysis tool for Rust projects that evaluates code quality by measuring the 'right distance' between modules. Built on the principles of Vlad Khononov's 'Balancing Coupling in Software Design' framework, it calculates a multi-dimensional Balance Score based on integration strength, physical distance, and volatility. Designed for software engineers, architects, and technical leads, the tool helps maintain healthy codebases by identifying architectural risks like global complexity, circular dependencies, and cascading change hazards.

  • Multi-dimensional metrics: Calculates Balance Score using the formula (STRENGTH XOR DISTANCE) OR NOT VOLATILITY to distinguish between healthy cohesion and problematic coupling.

  • Interactive Web UI: Provides a browser-based visualization via Cytoscape.js, allowing users to explore dependency graphs, filter by strength or volatility, and inspect blast radii for specific modules.

  • Hotspot Identification: Automatically ranks refactoring targets based on severity, helping teams prioritize technical debt reduction.

  • Job-Focused CLI: Offers specialized commands for CI/CD gates (quality checks), dependency tracing, impact analysis, and machine-readable JSON output for automated pipelines.

  • AI-Ready Integration: Generates structured output designed for AI coding assistants, providing actionable refactoring suggestions like interface extraction and module decoupling.

  • Language support: Includes Japanese output options for summaries and design decision matrices, making it accessible to global development teams.

  • The tool requires a Rust environment and functions as a cargo subcommand. It analyzes source code structure, module imports, and crate metadata.

  • To begin, run cargo coupling ./src to perform a baseline analysis. For visual exploration, use cargo coupling --web ./src.

  • Configuration is supported through a .coupling.toml file, enabling users to customize threshold settings, exclude specific test paths, or manually define module volatility (high vs. low).

  • Performance: Leverages parallel processing via rayon to handle large workspaces efficiently; it can be integrated into CI/CD pipelines to enforce modularity grades.

  • Limitations: The tool is currently experimental. While it provides deep architectural insight, users should validate findings against manual review as thresholds and heuristics evolve.

Repository Stats

Stars
73
Forks
2
Open Issues
1
Language
Rust
Default Branch
main
Sync Status
Idle
Last Synced
May 4, 2026, 01:06 AM
View on GitHub