Skip to main content

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

File

Created: When a repo is scanned (build_repo_graph)
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)

Developer

Created: When a PR is indexed (index_pr)

Issue

Created: When a PR closes an issue (index_pr)

Relationship Types

[:CONTAINS]

Direction: Repository → File
Cardinality: 1:N (one repo contains many files)
Use case: Find the largest Python files in a repo.

[:TOUCHES]

Direction: PullRequest → File
Cardinality: N:M (a PR touches many files, a file is touched by many PRs)
Use case: List all files changed in PR #42.

[:AUTHORED_BY]

Direction: PullRequest → Developer
Cardinality: N:1 (many PRs by one developer)
Use case: Find top contributors by PR count.

[:CONTRIBUTED_TO]

Direction: Developer → Repository
Cardinality: N:M (a developer contributes to many repos)
Use case: List all repos a developer has contributed to.

[:CLOSES]

Direction: PullRequest → Issue
Cardinality: N:M (a PR can close multiple issues, an issue can be closed by multiple PRs)
Use case: List recent PRs and the issues they closed.

Constraints & Indexes

File: app/core/neo4j_schema.py

Common Queries

File Experts

Find developers who most frequently touched given files.
Find past PRs that touched the same files (structural similarity).

File Hotspots

Find files touched by the most PRs (high churn → high importance or fragility).

High-Risk Files

Find files repeatedly flagged in PRs with REQUEST_CHANGES verdict.

Code Ownership

For each heavily-touched file, who is the dominant contributor?

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)