Dependency Graph

Map the import relationships in your codebase and discover which modules carry Lore knowledge.

Overview

Lore parses your source files to build a module-level dependency graph — tracking which files import which. This graph is stored in .lore/graph.json and powers the dependency visualization in the UI dashboard.

Build the Graph

# Build or rebuild the full dependency graph
$ lore graph --build

📖 Building dependency graph...
✓ Graph built: 42 files indexed

View Graph Stats

$ lore graph

📖 Dependency Graph
  Files indexed: 42
  Import edges:  87
  Last updated:  2025-03-05T22:30:00Z

  Run: lore graph   for file details
  Run: lore graph --build     to rebuild from scratch

Inspect a File

Pass a filepath to see what it imports and what imports it, along with how many Lore entries are attached to each dependency:

$ lore graph src/api/auth.js

📖 src/api/auth.js

Imports:
  src/db/users.js        → 2 Lore entries
  src/utils/jwt.js       → 1 Lore entry
  src/middleware/rateLimit.js  → 0 Lore entries

Imported by:
  src/routes/login.js    → 1 Lore entry
  src/routes/signup.js   → 0 Lore entries

How It Works

Lore uses Babel Parser to parse JavaScript/TypeScript source files and extract import and require() statements. The resulting graph tracks two relationships per file:

When viewing a file's graph, Lore also cross-references the index to show how many Lore entries are linked to each dependency. This helps you identify critical dependency chains that may lack documentation.

⚠️ Language Support
The dependency graph parser currently supports JavaScript and TypeScript files (ES modules and CommonJS). Support for other languages may be added in future versions.