Architectural Fitness Analysis for TypeScript

A modern CLI tool and library for analyzing coupling, detecting cycles, and computing architecture fitness metrics like instability, abstractness, and distance from the main sequence.

Quick Installation

Get started with tdepend in seconds

npm install -D tdepend

Powerful Features

Everything you need to maintain healthy architecture

Dependency Analysis

Analyze coupling between modules and components. Understand how your codebase is structured and identify tight coupling that may need refactoring.

Cycle Detection

Detect circular dependencies using Tarjan's strongly connected components algorithm. Find and eliminate problematic cycles in your architecture.

Architectural Metrics

Compute key fitness metrics including Afferent Coupling (Ca), Efferent Coupling (Ce), Instability (I), Abstractness (A), and Distance from the main sequence.

Configurable Fitness Functions

Define custom fitness functions and thresholds to enforce architectural rules. Set up quality gates that align with your team's standards.

Programmatic API

Use tdepend as a library in your Node.js/TypeScript projects. Access the full analysis pipeline, dependency graph, and metrics programmatically for custom integrations.

JSON Export & Serialization

Export complete analysis results to versioned JSON format. Includes serialized dependency graphs, normalized cycles with unique IDs, and full metric data for external tools.

Dual CLI/Library Mode

Works as both a standalone CLI tool and an importable library. Use --export flag for file output or import analyze() for programmatic usage in your scripts and workflows.

Tool Integration

Designed to work alongside ts-arch, dependency-cruiser, and custom dashboards. Export data in formats that other architectural tools can consume for comprehensive analysis.

Use as CLI or Library

Choose the approach that fits your workflow

CLI Usage


# Analyze your project
tdepend analyze

# Export results to JSON
tdepend analyze --export report.json

# CI mode with strict checks
tdepend analyze --ci --failOnCycle
          

Library Usage


import { analyze, exportToFile } from 'tdepend';

const result = await analyze({
  rootDir: 'src',
  failOnCycle: true
});

await exportToFile(result, 'analysis.json');
          

Understanding Core Concepts

Learn about the metrics and algorithms that help you maintain clean architecture and identify technical debt in your TypeScript projects. Explore fitness functions, abstractness, afferent and efferent coupling, distance metrics, and Tarjan's strongly connected components algorithm.

Ready to improve your architecture?

Start analyzing your TypeScript projects today and maintain clean, maintainable code.