Overview
Nectr uses Neo4j as a knowledge graph to track structural relationships between repositories, files, developers, pull requests, and issues.Neo4j is optional. If not configured, Nectr degrades gracefully (file experts and related PRs won’t be available, but reviews still work).
Graph Schema
Node Types
Repository
Created: When a repo is connected via/api/v1/repos/{owner}/{repo}/install
Cypher: Create Repository
Cypher: Create Repository
File
Created: When a repo is scanned (build_repo_graph)
Cypher: Create File
Cypher: Create File
Composite key:
(repo, path) uniquely identifies a file. This allows multiple repos to have files with the same path.PullRequest
Created: When a PR review is completed (index_pr)
Cypher: Create PullRequest
Cypher: Create PullRequest
Developer
Created: When a PR is indexed (index_pr)
Cypher: Create Developer
Cypher: Create Developer
Issue
Created: When a PR closes an issue (index_pr)
Cypher: Create Issue
Cypher: Create Issue
Relationship Types
[:CONTAINS]
Direction:Repository → FileCardinality: 1:N (one repo contains many files)
Example Query
Example Query
[:TOUCHES]
Direction:PullRequest → FileCardinality: N:M (a PR touches many files, a file is touched by many PRs)
Example Query
Example Query
[:AUTHORED_BY]
Direction:PullRequest → DeveloperCardinality: N:1 (many PRs by one developer)
Example Query
Example Query
[:CONTRIBUTED_TO]
Direction:Developer → RepositoryCardinality: N:M (a developer contributes to many repos)
Example Query
Example Query
[:CLOSES]
Direction:PullRequest → IssueCardinality: N:M (a PR can close multiple issues, an issue can be closed by multiple PRs)
Example Query
Example Query
Constraints & Indexes
File:app/core/neo4j_schema.py
Constraints
Constraints
Indexes
Indexes
Common Queries
File Experts
Find developers who most frequently touched given files.Example (Python)
Example (Python)
Related Past PRs
Find past PRs that touched the same files (structural similarity).Example (Python)
Example (Python)
File Hotspots
Find files touched by the most PRs (high churn → high importance or fragility).Example (Python)
Example (Python)
High-Risk Files
Find files repeatedly flagged in PRs withREQUEST_CHANGES verdict.
Example (Python)
Example (Python)
Code Ownership
For each heavily-touched file, who is the dominant contributor?Example (Python)
Example (Python)
Performance Characteristics
Neo4j Aura Free Tier is sufficient for repos with < 10,000 files and < 1,000 PRs. Larger repos should use a paid tier or self-hosted instance.
Data Volume Estimates
Next Steps
Service Layer
Learn how graph_builder service uses Neo4j
MCP Client
Explore MCP integrations (Linear, Sentry, Slack)