npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@phoenixaihub/driftmap

v1.0.0

Published

Architectural Drift Detection — track how your codebase's structure changes over time using call graphs, dependency analysis, and Weisfeiler-Leman graph kernels

Downloads

146

Readme

driftmap

Architectural Drift Detection — track how your codebase's structure changes over time.

npm License: MIT

The Problem

Codebases don't rot overnight. Architecture erodes gradually — one shortcut at a time. A module that started clean accumulates dependencies. Boundaries blur. Coupling grows. By the time you notice, it's a rewrite.

driftmap detects this drift early by analyzing your codebase's structure over time, quantifying how coupling, complexity, and module boundaries change.

How It Works

  1. Parse — Tree-sitter ASTs extract call graphs and dependency graphs from JS/TS/Python
  2. Graph — Build structural representations: which functions call which, which modules import which
  3. Compare — Weisfeiler-Leman graph kernel computes structural similarity between snapshots
  4. Measure — Fan-in, fan-out, instability ratios, internal complexity per module
  5. Scorecoupling_delta × complexity_delta × change_frequency = drift_risk

Install

npm install -g @phoenixaihub/driftmap
# or
npx @phoenixaihub/driftmap analyze .

CLI Usage

Analyze current architecture

driftmap analyze ./src
driftmap analyze ./src --output json

Compare two commits

driftmap compare abc123 def456 --dir .

Generate drift report

driftmap report --dir . --since 30d
driftmap report --dir . --since 7d --output json

Programmatic API

import { analyze, compare, report } from '@phoenixaihub/driftmap';

// Current snapshot
const snapshot = analyze('./src');
console.log(snapshot.coupling.modules);

// Compare commits
const diff = await compare('.', 'main~10', 'main');
console.log(diff.drift.filter(d => d.risk === 'critical'));

// Drift report
const r = await report('.', '2026-03-01');
console.log(JSON.stringify(r, null, 2));

Output Format

{
  "period": { "from": "2026-03-01", "to": "2026-04-01" },
  "modulesAnalyzed": 47,
  "driftScore": 34,
  "hotspots": [
    {
      "module": "src/auth/",
      "coupling_before": 3,
      "coupling_after": 47,
      "coupling_increase": "15.7x",
      "complexity_delta": "+340%",
      "risk": "critical",
      "recommendation": "Module is becoming a god object. Consider extracting shared logic."
    }
  ],
  "graphDiff": {
    "nodes_added": 12,
    "nodes_removed": 3,
    "edges_added": 89,
    "edges_removed": 7
  }
}

Core Algorithms

Weisfeiler-Leman Graph Kernel

Hash-based graph isomorphism test. Iteratively refines node labels by incorporating neighbor information, producing histograms that capture structural patterns. Cosine similarity between histograms quantifies how different two graph snapshots are.

Coupling Metrics

  • Fan-in: How many modules depend on X (afferent coupling)
  • Fan-out: How many modules X depends on (efferent coupling)
  • Instability: fan_out / (fan_in + fan_out) — 0 = maximally stable, 1 = maximally unstable

Drift Score

drift = |coupling_delta| × (1 + |complexity_delta|) × change_frequency

Risk levels: critical (>10), high (>5), medium (>2), low (≤2)

Supported Languages

  • JavaScript (.js, .jsx, .mjs, .cjs)
  • TypeScript (.ts, .tsx)
  • Python (.py)

License

MIT