Skip to main content

N3MO: The Impact Tracker

Project description

๐Ÿ” N3MO

N3MO Banner PyPI version License: AGPL v3.0 Python Docker Status

A code intelligence engine that transforms repositories into queryable knowledge graphs

Parse once. Query forever. Know exactly what breaks before it does.

๐Ÿ“œ Licensed under AGPL-3.0 โ€” Free for personal/internal use โ€ข Contact for commercial licensing

What is N3MO โ€ข Architecture โ€ข Installation โ€ข Usage โ€ข Benchmarks โ€ข Roadmap


๐ŸŽฏ What is N3MO?

N3MO is a symbol-centric code intelligence engine. Instead of scanning raw text, it parses your source code ASTs, maps call graphs, and models dependencies in a queryable relational database.

For engineering leaders and teams, N3MO acts as a structural insurance policy for your codebases.

๐Ÿ’ก Why N3MO?

  • ๐Ÿ›ก๏ธ Eliminate Regression Risks: Utility functions are rarely refactored because developers fear unknown side effects. N3MO maps the transitive blast radius of any symbol to arbitrary depth, showing you exactly what will break before you make the edit.
  • ๐ŸŽ๏ธ Rapid Developer Onboarding: Instead of senior engineers spending hours explaining codebase flow to new hires, developers can run one command to visualize complex call chains and parent-child dependencies interactively.
  • ๐Ÿค– AI-Agent Ready Infrastructure: Modern LLM agents (Cursor, Claude Desktop) are limited by context windows and text search. N3MO's native MCP server lets AI agents query the actual code graph, enabling fast, hallucination-free refactoring.

๐Ÿ“Š How N3MO Compares

Capability Grep / Text Search IDE "Find References" N3MO Code Graph
Analysis Basis Substring Matching AST-based Direct matching Relational Knowledge Graph
Transitive Traversal โŒ None โŒ Manual (one level at a time) โšก Instant (to arbitrary depth)
Blast Radius Mapping โŒ None โŒ Text-based search list ๐ŸŽจ Interactive visual orbit map
CI/CD Integration โŒ None โŒ Bound to IDE runtime โš™๏ธ Dockerized CLI & DB CTE queries
AI Agent Integration โŒ Injected file chunks โš ๏ธ Manual context copy ๐Ÿค– Native MCP Server (Claude/Cursor)

๐Ÿ› ๏ธ The Core Problem N3MO Solves

โŒ Traditional grep/search:  "Where does 'login' appear?"
โœ… N3MO:                     "What will break if I change the login function?"

Critical questions N3MO answers instantly:

  • ๐Ÿ”Ž What functions and classes exist in this repository?
  • ๐ŸŽฏ Where is this symbol being used โ€” directly and transitively?
  • ๐Ÿ’ฅ What is the blast radius of changing this function?
  • ๐Ÿ•ธ๏ธ How do these components actually connect?

๐Ÿ—๏ธ Architecture

Knowledge graph model

N3MO builds a symbol-centric knowledge graph stored in PostgreSQL:

graph TB
    subgraph repo["Repository Analysis"]
        A["๐Ÿ“„ Source Code"] -->|Tree-sitter| B["๐ŸŒณ AST Parser"]
        B --> C["๐Ÿ” Symbol Extractor"]
    end

    subgraph kg["Knowledge Graph"]
        D[("๐Ÿ—„๏ธ PostgreSQL")]
        E["๐Ÿ“ฆ Projects"]
        F["๐Ÿ”ค Symbols"]
        G["๐Ÿ”— Relationships"]
        D --- E
        D --- F
        D --- G
    end

    subgraph query["Query Engine"]
        H["๐Ÿ“Š Dependency Graph"]
        I["๐Ÿ“ž Call Graph"]
        J["๐Ÿ’ฅ Impact Analysis"]
    end

    C --> D
    D --> H
    D --> I
    D --> J
    H --> K["๐ŸŽจ Visualization"]
    I --> K
    J --> K

    style repo fill:#2d3748,stroke:#4a5568,stroke-width:2px,color:#fff
    style kg fill:#2d3748,stroke:#4a5568,stroke-width:2px,color:#fff
    style query fill:#2d3748,stroke:#4a5568,stroke-width:2px,color:#fff
    style A fill:#e2e8f0,stroke:#4a5568,color:#1a202c
    style B fill:#cbd5e0,stroke:#4a5568,color:#1a202c
    style C fill:#cbd5e0,stroke:#4a5568,color:#1a202c
    style D fill:#fc8181,stroke:#c53030,color:#1a202c,stroke-width:3px
    style E fill:#a0aec0,stroke:#4a5568,color:#1a202c
    style F fill:#a0aec0,stroke:#4a5568,color:#1a202c
    style G fill:#a0aec0,stroke:#4a5568,color:#1a202c
    style H fill:#90cdf4,stroke:#2c5282,color:#1a202c
    style I fill:#90cdf4,stroke:#2c5282,color:#1a202c
    style J fill:#90cdf4,stroke:#2c5282,color:#1a202c
    style K fill:#9ae6b4,stroke:#2f855a,color:#1a202c

System flow

sequenceDiagram
    participant User
    participant CLI
    participant Docker
    participant Parser
    participant DB as PostgreSQL
    participant Viz as Visualizer

    User->>CLI: n3mo index
    CLI->>Docker: Start containers
    Docker->>Parser: Mount repository
    Parser->>Parser: Walk file tree
    Parser->>Parser: Parse AST (Tree-sitter)
    Parser->>DB: Store symbols & relations
    DB-->>Parser: Confirm storage

    User->>CLI: n3mo impact "function_name"
    CLI->>DB: Query call graph
    DB->>DB: Recursive CTE traversal
    DB-->>Viz: Return dependency tree
    Viz-->>User: Display graph (HTML/JS)

Data model

erDiagram
    PROJECT ||--o{ SYMBOL : contains
    SYMBOL ||--o{ SYMBOL : "calls/inherits"
    SYMBOL {
        uuid id PK
        string kind "function|class|variable"
        string name
        string file_path
        int line_number
        uuid parent_id FK
        uuid project_id FK
    }
    PROJECT {
        uuid id PK
        string name
        string root_path
        timestamp indexed_at
    }

โœจ Core Capabilities

  • โœ… Multi-Language Ingestion โ€” dynamic Tree-sitter loading with support for all 27 requested languages (including Python, JS, TS, Go, Rust, Java, C/C++, C#, Haskell, Perl, Ruby, PHP, Powershell, Groovy, Matlab, Delphi, Kotlin, Swift, Scala, etc.)
  • โœ… Parallel AST Ingestion โ€” multiprocessing scaling utilizing ProcessPoolExecutor to distribute CPU-bound parsing across cores
  • โœ… Strict & Flawless Exclusions โ€” case-insensitive directory filters (tests, mocks, specs, fixtures, temp) and camelCase-aware prefix/suffix filename checks to avoid false positives (e.g. allows contest.py)
  • โœ… No-Impact Skips & Pruning โ€” skips files with 0 symbols, imports, and calls to prevent db bloat and deletes database residues upon updates
  • โœ… Premium Theme & Visual Styling โ€” warm beige editorial layout inspired by modern minimalist web design with elegant typography (Lora serif and Inter sans-serif)
  • โœ… Dynamic Canvas Dark Mode โ€” toggleable dark mode that dynamically updates Vis.js canvas nodes, edges, labels, and orbit lines in real-time, persisting preference in localStorage
  • โœ… AST-based parsing โ€” Tree-sitter integration for error-tolerant source analysis
  • โœ… Symbol extraction โ€” functions, classes, methods with full file + line context
  • โœ… Hierarchical modeling โ€” parent-child relationships (Module โ†’ Class โ†’ Method)
  • โœ… Call graph construction โ€” who calls whom, captured at ingestion time
  • โœ… Blast radius analysis โ€” recursive CTE traversal to arbitrary depth
  • โœ… Idempotent ingestion โ€” re-indexing updates existing data without duplication
  • โœ… Interactive visualizer โ€” vis.js graph with click-to-inspect nodes, sidebar, and depth slider
  • โœ… Docker-first โ€” single-command infrastructure setup
  • โœ… Connection pooling โ€” eliminated per-symbol DB round trips
  • โœ… Batch inserts โ€” symbols, imports, and calls batched per file
  • โœ… SPLIT_PART query fix โ€” major call-resolution speedup
  • โœ… CLI flags โ€” --file and --depth for targeted impact analysis
  • โœ… Incremental re-index โ€” SHA-256 file hashing, skip unchanged files
  • โœ… Test suite โ€” pytest with database integration testing
  • โœ… GitHub Actions CI โ€” lint and test pipeline on every PR

๐Ÿš€ Installation

Prerequisites

Docker Python Git

Quick start

Install N3MO directly from PyPI:

# Install the package
pip install n3mo

# Start Docker containers & run the database and background engines setup
n3mo setup

Alternatively, for developers running in editable mode:

git clone https://github.com/RajX-dev/N3MO.git
cd N3MO
pip install -e .
n3mo setup

๐Ÿค– Model Context Protocol (MCP)

N3MO includes a Model Context Protocol (MCP) server that exposes N3MO's repository analysis and graph traversal tools to LLM agents (like Claude or Cursor).

Automatic Claude Desktop Setup

To automatically configure N3MO in your local Claude Desktop:

# Navigate to the workspace you want Claude to analyze, then run:
n3mo mcp install

This registers N3MO and sets up the paths automatically. Restart Claude Desktop and you're ready!

Cursor Setup

To use N3MO in Cursor:

  1. Go to Settings -> Models -> MCP.
  2. Click + Add New MCP Server.
  3. Set the configuration details:
    • Name: n3mo
    • Type: command
    • Command: n3mo mcp start (or uvx n3mo mcp start to run directly)
    • Environment Variables: TARGET_CODE_DIR=/absolute/path/to/your/active/workspace
  4. Click Save, and Cursor will instantly be able to index and query your workspace blast radius.

๐Ÿ’ป Usage

Index a repository

# Navigate to any Python repository
cd /path/to/your/project

# Run the indexer
n3mo index

What gets indexed:

  • โœ… Python files (.py)
  • โŒ Virtual environments (venv/, .venv/)
  • โŒ Dependencies (node_modules/, site-packages/)
  • โŒ Build artifacts (.git/, __pycache__/, dist/)

Blast radius analysis

# Find everything affected by changing a function
n3mo impact "authenticate_user"

# Limit to a specific file or traversal depth
n3mo impact "authenticate_user" --file api/auth.py --depth 2

# Open an interactive visual graph in your browser (with depth slider)
n3mo impact "authenticate_user" --graph

Visualizer Screenshots

Solar Orbit View

Solar Orbit View

Horizontal Tree View

Horizontal Tree View

Example terminal output:

  โ—ˆ IMPACT ANALYSIS
  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  Target:  authenticate_user
  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

  โ—‰ Direct Callers  (3 symbols)

  โ–ธ login_endpoint             api/auth.py:12
  โ–ธ refresh_token              api/token.py:23
  โ–ธ validate_session           middleware/auth.py:89

  โ—Ž Ripple Effects  (5 symbols)

    โ•ฐโ”€โ–ธ POST /login              routes.py:67
    โ•ฐโ”€โ–ธ admin_login              admin/views.py:34
    โ•ฐโ”€โ–ธ require_auth             decorators.py:12
    โ•ฐโ”€โ–ธ dashboard_view           views/dashboard.py:8
    โ•ฐโ”€โ–ธ settings_view            views/settings.py:22

  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  Total impacted: 8 references  โ”‚  depth โ‰ค 3

Dependency graph visualization

graph LR
    A[main.py] --> B[auth.py::login]
    A --> C[db.py::connect]
    B --> D[utils.py::hash_password]
    B --> E[models.py::User]
    C --> F[config.py::DB_URI]

    style A fill:#ff6b6b,stroke:#c92a2a,stroke-width:2px,color:#fff
    style B fill:#4ecdc4,stroke:#0ca89e,stroke-width:2px,color:#000
    style C fill:#45b7d1,stroke:#1098ad,stroke-width:2px,color:#000
    style D fill:#96ceb4,stroke:#63b598,stroke-width:2px,color:#000
    style E fill:#ffd93d,stroke:#f5c200,stroke-width:2px,color:#000
    style F fill:#e0e0e0,stroke:#a0a0a0,stroke-width:2px,color:#000

๐Ÿ› ๏ธ Technology stack

Component Technology Purpose
Parser Tree-sitter Error-tolerant syntax analysis
Database PostgreSQL Relational graph storage + recursive CTE queries
Runtime Python Core logic
Infrastructure Docker Containerization
Visualization JavaScript Interactive impact graph

๐Ÿ“Š Benchmarks

ScanCode Toolkit (v0.3 baseline)

Tested on ScanCode Toolkit โ€” a real-world open source Python project with ~600k lines of code.

Metric v0.3 (baseline)
Repository nexB/scancode-toolkit
Lines of code ~600,000
Index time ~3 minutes
Processing mode Single-threaded
Hardware Intel i5-13450HX, 24GB RAM, NVMe SSD

Django โ€” full optimization history (v0.3 โ†’ v0.4)

Version Index time Speedup
v0.3 baseline 23 minutes 1x
After SPLIT_PART fix 11 minutes 2x
After batch inserts (symbols/imports/calls) 5 minutes 4.6x
Files:    3,021
Symbols:  ~43,000
Calls:    ~181,000

โœ… Real measured results on Django, single-threaded, same hardware as above.

Total improvement: 4.6x faster than v0.3. Multiprocessing (v0.5) will produce a further before/after comparison once implemented. No projections until the code exists.

Running the Indexing Performance Benchmark

N3MO includes an automated performance benchmarking script to evaluate index timing improvements (comparing full indexing times against incremental re-indexing times):

python benchmarks/benchmark_indexing.py

๐Ÿ—บ๏ธ Roadmap

Development timeline

Phase Component Status
Phase 1 โ€” Foundations
Docker setup โœ… Complete
Database schema โœ… Complete
Tree-sitter integration โœ… Complete
Symbol + call extraction โœ… Complete
Blast radius (recursive CTE) โœ… Complete
Interactive visualizer โœ… Complete
Phase 2 โ€” Performance
Connection pooling โœ… Complete
Batch DB operations (symbols/imports/calls) โœ… Complete
SPLIT_PART query fix โœ… Complete
--file / --depth CLI flags โœ… Complete
Interactive depth slider โœ… Complete
Phase 3 โ€” Correctness & Scaling
Incremental re-index (file hashing) โœ… Complete
Multiprocessing (AST parsing) โœ… Complete
Scope-aware call resolution โณ Planned
CTE cycle guard โณ Planned
Full type annotations + mypy โณ Planned
pytest suite + CI โœ… Complete
Multi-language support โœ… Complete
Phase 4 โ€” Distribution
MCP server (Cursor / Claude Code) โœ… Complete
FastAPI REST layer โณ Planned
Real-time git-hook indexing โณ Planned
pgvector semantic search โณ Planned

Legend: โœ… Complete ย |ย  ๐Ÿ”ต In Progress ย |ย  โณ Planned

Phase 1: Foundations โœ… Complete
  • Docker environment (PostgreSQL)
  • Database schema โ€” Projects, Symbols, Calls, Imports tables
  • Tree-sitter parser integration
  • Symbol extractor with full AST traversal
  • Idempotent upsert logic
  • Blast radius via recursive CTE
  • Interactive vis.js visualizer
Phase 2: Performance โœ… Complete
  • psycopg2.pool.ThreadedConnectionPool โ€” replace per-call connections
  • execute_values() batch inserts for symbols, imports, and calls โ€” 1 transaction per file
  • SPLIT_PART query optimization for call resolution
  • --file and --depth CLI flags for targeted impact analysis
  • Interactive depth slider in visualizer

Results: Django (3,021 files, ~43k symbols, ~181k calls) โ€” 23min โ†’ 5min (4.6x faster)

Phase 3: Correctness + Scaling ๐Ÿ”ต In Progress
  • SHA-256 file hashing for incremental re-index
  • ProcessPoolExecutor for parallel AST parsing
  • Scope-aware call resolution using imports table
  • CTE cycle guard (visited node tracking)
  • Full type annotations, mypy --strict clean
  • pytest unit + integration test suite
  • GitHub Actions CI pipeline
  • Multi-language support
Phase 4: Distribution ๐Ÿ”ต In Progress
  • MCP server โ€” N3MO as a tool for Cursor, Claude Code, Windsurf
  • FastAPI REST layer โ€” GET /impact/{symbol}, POST /index
  • Real-time incremental indexing via git hooks
  • pgvector semantic search โ€” "find functions that do X"

๐Ÿ“ Design principles

1. Structure before semantics Map the code skeleton (AST) before adding AI analysis. A correct graph is worth more than a smart but wrong one.

2. Database as source of truth All state lives in PostgreSQL, eliminating in-memory complexity and enabling graph queries that application-level traversal cannot match.

3. Correctness over speed The parser must handle syntax errors gracefully without corrupting the graph. A fast indexer that silently drops symbols is worse than a slow one that gets everything right.

4. Idempotent operations Re-running ingestion produces identical results, enabling safe incremental updates and CI/CD integration.


๐Ÿค Contributing

Contributions are welcome. Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development setup

# Install with dev dependencies
pip install -e ".[dev]"

# Lint
ruff check n3mo/

# Type check
mypy n3mo/

# Tests
pytest tests/

๐Ÿ“œ License

Licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).

  • โœ… Free for personal projects and internal tools
  • โœ… Open source โ€” view, modify, and distribute freely
  • โš ๏ธ Copyleft โ€” derivative works must also be AGPL-3.0
  • โš ๏ธ Network use โ€” modified versions run as a web service must share changes

For commercial deployments or proprietary modifications, contact for licensing options.

See LICENSE for full legal details.


๐Ÿ‘จโ€๐Ÿ’ป Author

Raj Shekhar โ€” Delhi Technological University

GitHub LinkedIn


๐Ÿ™ Acknowledgments

  • Tree-sitter โ€” for robust, incremental, error-tolerant parsing
  • PostgreSQL โ€” for making recursive graph queries possible without a graph database
  • Docker โ€” for reproducible, single-command environments
  • vis.js โ€” for the interactive graph visualization

โญ Star this repo if you find it useful!

Building tools for understanding code at scale.

Visitors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

n3mo-1.0.4.tar.gz (73.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

n3mo-1.0.4-py3-none-any.whl (64.3 kB view details)

Uploaded Python 3

File details

Details for the file n3mo-1.0.4.tar.gz.

File metadata

  • Download URL: n3mo-1.0.4.tar.gz
  • Upload date:
  • Size: 73.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for n3mo-1.0.4.tar.gz
Algorithm Hash digest
SHA256 6fe2c044a844f8413a32404d8c661e026d5840a3570193656ce2034714dee158
MD5 763a857ad0b00d04b762e396447b0555
BLAKE2b-256 c0f6b3a8d072d235e76bca3ad6e1b684fb5d3d681c40bb582f850951bc5d05d7

See more details on using hashes here.

File details

Details for the file n3mo-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: n3mo-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 64.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for n3mo-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6ed833a4ec2e448564cde9251dab294eaea2f22ad4aa59a637a002b61328f4c0
MD5 0a77204aa8ab9e6a88b9d4e05c87934b
BLAKE2b-256 692bd3e646e9627d6a61e1da4a5e1b7fa250ec4f410d7f1a040578d15ecfd0ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page