A code intelligence engine that transforms repositories into queryable knowledge graphs
Enabling deep code understanding, dependency analysis, and AI-assisted reasoning
๐ Licensed under AGPL-3.0 - Free for personal/internal use โข Contact for commercial licensing
Features โข Architecture โข Installation โข Usage โข Roadmap
N3MO addresses a fundamental challenge in software engineering: understanding large codebases. Unlike simple code search tools that rely on text matching, N3MO models code structure firstโcapturing symbols, their relationships, and their semantics.
โ Traditional grep/search: "Where does 'login' appear?"
โ
N3MO: "What will break if I change the login function?"
Critical Questions N3MO Answers:
- ๐ What functions exist in this repository?
- ๐ฏ Where is this class being used?
- ๐ฅ What will break if I modify this function? (Blast Radius)
- ๐ธ๏ธ How do these components actually connect?
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<br/>Database")]
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
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)
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
}
- โ AST-Based Parsing: Tree-sitter integration for error-tolerant Python analysis
- โ Symbol Extraction: Functions, classes, methods, variables with full context
- โ Hierarchical Modeling: Parent-child relationships (Module โ Class โ Method)
- โ Idempotent Ingestion: Re-indexing updates existing data without duplication
- โ Docker-First: Containerized environment for consistency
- ๐ง Import Resolution: Link
from x import ystatements - ๐ง Call Graph: Map function invocation chains
- ๐ง Blast Radius Analysis: Visualize change impact
- ๐ง CI/CD Integration: Automated quality gates
Note: The
n3mowrapper is currently in development (Phase 1). Commands below reflect the target interface we're building.
# 1. Clone the repository
git clone https://github.com/RajX-dev/N3MO.git
cd N3MO
# 2. Install the wrapper (development mode)
pip install -e .
# 3. Spin up the infrastructure
docker-compose up -d
# 4. Start infrastructure & index (automatic via wrapper)
n3mo index
# 5. Verify installation
n3mo query --stats# Check indexed symbols
n3mo query --list
# View database stats
n3mo query --statsExpected Output:
๐ N3MO Statistics
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Total Symbols: 247
Functions: 156
Classes: 42
Methods: 89
Variables: 23
Recent Symbols:
function parse_ast /src/parser.py:45
class SymbolExtractor /src/extractor.py:12
method extract_symbols /src/extractor.py:34
# Navigate to target repository
cd /path/to/your/project
# Run indexer (scans current directory)
n3mo indexWhat Gets Indexed:
- โ
Python files (
.py) - โ Virtual environments (
venv/,.venv/) - โ Dependencies (
node_modules/,site-packages/) - โ Build artifacts (
.git/,__pycache__/,dist/)
# Find all callers of a function (direct + indirect)
n3mo impact "authenticate_user" --graph
# CI/CD mode (exit code 1 if impact > threshold)
n3mo impact "core_function" --ci --threshold 20# List all functions in a file
n3mo query --file "auth.py" --kind function
# Find class hierarchy
n3mo hierarchy "UserModel"
# Export dependency graph
n3mo export --format dot > deps.dot| Component | Technology | Purpose |
|---|---|---|
| Parser | Error-tolerant syntax analysis | |
| Database | Relational graph storage | |
| Search | Fast symbol lookup | |
| Runtime | Core logic | |
| Infrastructure | Containerization |
| Phase | Component | Status | Timeline |
|---|---|---|---|
| Phase 1: Foundations | |||
| Docker Setup | โ Complete | Day 1-3 | |
| Database Schema | โ Complete | Day 4-5 | |
| Tree-sitter Integration | โ Complete | Day 6-8 | |
| Symbol Extraction | โ Complete | Day 9-10 | |
| Phase 2: Connectivity | |||
| Import Resolution | โ Complete | Day 11-14 | |
| Graph Builder | โ Complete | Day 15-19 | |
| Scope Analysis | โณ Planned | Day 20-22 | |
| Phase 3: Performance | |||
| Smart File Filtering | โ Complete | Day 23 | |
| Parallel Processing | ๐ต Active | Day 24-26 | |
| Batch DB Operations | โณ Planned | Day 27-28 | |
| Phase 4: Interface | |||
| CLI Enhancement | ๐ต Active | Day 29-31 | |
| Web Visualization | ๐ต Active | Day 32-36 | |
| CI/CD Integration | ๐ต Active | Day 37-39 |
Legend: โ Complete | ๐ต In Progress | โณ Planned
Phase 1: Foundations โ Complete
- Docker environment setup (PostgreSQL + Elasticsearch)
- Database schema design (Projects, Symbols tables)
- Tree-sitter parser integration
- Symbol extractor with AST traversal
- Idempotent upsert logic
Phase 2: Connectivity ๐ง In Progress
- Import statement resolution
- Cross-file dependency linking
- Call graph population
- Recursive CTE queries for traversal
Phase 3: Performance Optimization ๐ง In Progress
- Smart directory filtering (skip
venv/,.git/) - Multiprocessing for AST parsing (4-8x speedup) โก Currently tackling
- Batch database inserts (10,000+ โ 5 transactions)
- Progress indicators with
tqdm
Phase 4: Advanced Features ๐ฎ Future
-
pgvectorintegration for semantic search - Fuzzy symbol matching for dynamic imports
- Web-based graph visualization
- GitHub Actions integration
- Multi-language support (JavaScript, TypeScript)
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
$ n3mo impact "authenticate_user"
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
BLAST RADIUS ANALYSIS
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Target Function: authenticate_user
Direct Callers: 3
Indirect Callers: 12
Total Affected Files: 8
IMPACT TREE:
authenticate_user (auth.py:45)
โโโ login_endpoint (api/auth.py:12)
โ โโโ POST /login (routes.py:67)
โ โโโ admin_login (admin/views.py:34)
โโโ refresh_token (api/token.py:23)
โโโ validate_session (middleware/auth.py:89)
โโโ require_auth (decorators.py:12)
โโโ dashboard_view (views/dashboard.py:8)
โโโ profile_view (views/profile.py:15)
โโโ settings_view (views/settings.py:22)
โ ๏ธ WARNING: Modifying this function affects 8 files| Metric | Before Optimization | After Optimization | Improvement |
|---|---|---|---|
| Indexing Time | 12m 34s | 1m 47s | 7x faster |
| CPU Usage | 12.5% (1 core) | 98% (8 cores) | 8x utilization |
| DB Transactions | 45,231 | 6 | 7,500x reduction |
| Memory Peak | 2.1 GB | 890 MB | 2.4x lower |
Tested on: Intel i5-13450HX, 24GB RAM, NVMe SSD
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
pytest tests/
# Check code quality
black src/
flake8 src/
mypy src/-
Structure Before Semantics
Map the code skeleton (AST) before adding AI analysis -
Correctness Over Speed
Parser must handle syntax errors gracefully without corrupting the graph -
Database as Source of Truth
All state lives in PostgreSQL, eliminating in-memory complexity -
Idempotent Operations
Re-running ingestion produces identical results, enabling safe incremental updates
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
- โ Free to use for personal projects and internal tools
- โ Open source - you can view, modify, and distribute the code
โ ๏ธ Copyleft - derivative works must also be AGPL-3.0โ ๏ธ Network use - if you run a modified version as a web service, you must share your changes
For commercial deployments or proprietary modifications, contact for licensing options.
See LICENSE for full legal details.
Raj Shekhar
Delhi Technological University
- Tree-sitter - For robust, incremental parsing
- PostgreSQL - For powerful graph queries with CTEs
- Docker - For reproducible environments