architecture-analyzer
v0.3.1
Published
Framework-agnostic architecture analyzer
Maintainers
Readme
Architecture Analyzer
Framework-agnostic tool for architectural governance and metric analysis.
Input
Analyzes a dependency graph (graph.json). Does not analyze source code directly (except for optional Knip integration).
Example graph.json
{
"entrypoints": ["src/cli.ts"],
"nodes": [
{
"id": "src/cli.ts",
"metadata": { "layer": "UI", "type": "module" }
},
{
"id": "lib/core.ts",
"metadata": { "layer": "Core", "type": "module" }
}
],
"edges": [
{ "from": "src/cli.ts", "to": "lib/core.ts", "type": "import" }
]
}Key Features
- Knip Integration: High-confidence detection of unused modules and exports via
npx knip. - Agnostic Entrypoints: Explicit (
entrypointsarray) or graph-driven (Fan-in 0) entrypoint filtering. - Architectural Drift: Prevent degradation in CI/CD by comparing snapshots.
- Precision Metrics: Filters
type-onlydependencies and calculates Instability ($I$), Abstractness ($A$), and Distance ($D$). - Hotspot Detection: Identifies complex modules and prohibited inheritance (e.g., Domain extending Infrastructure).
- AI-Ready: Generates optimized prompts for LLM refactoring plans.
Usage
# Basic Analysis (Knip runs automatically if available)
npx architecture-analyzer analyze graph.json
# CI/CD Drift Detection
npx architecture-analyzer analyze graph.json --baseline baseline.json
# Generate AI Refactoring Prompt
npx architecture-analyzer analyze graph.json --ai-promptTL;DR
- Generate graph:
npx architecture-diagram-generator - Analyze:
npx architecture-analyzer architecture.json --baseline last-stable.json
