Overview
This page traces a pull request review from the moment a developer opens a PR on GitHub to when Nectr posts the AI-generated review as a GitHub comment.The entire flow is asynchronous and non-blocking. The webhook returns
HTTP 200 within 1 second, then processes the PR in a background task.PR Review Flow Diagram
Step-by-Step Walkthrough
Step 1: GitHub Webhook Event
Location:app/api/v1/webhooks.py
When a developer opens or updates a PR, GitHub sends a pull_request event to the configured webhook URL:
Why Deduplicate?
Why Deduplicate?
GitHub sometimes sends duplicate webhook events (network retries, misconfigured hooks). Deduplication prevents processing the same PR twice within a 1-hour window.
Step 2: Fetch PR Data from GitHub
Location:app/services/pr_review_service.py:473
GET /repos/{owner}/{repo}/pulls/{pr_number}- PR metadataGET /repos/{owner}/{repo}/pulls/{pr_number}/files- Changed filesGET /repos/{owner}/{repo}/pulls/{pr_number}withAccept: application/vnd.github.v3.diff- Unified diff
Step 3: Pull MCP Context (Optional)
Location:app/services/pr_review_service.py (ReviewToolExecutor)
If MCP integrations are configured, Nectr pulls live context:
If
LINEAR_MCP_URL or SENTRY_MCP_URL are not set, these calls return empty lists gracefully.Step 4: Build Review Context
Location:app/services/context_service.py:58
- Mem0: Project patterns, decisions, rules
- Mem0: Developer-specific patterns, strengths
- Neo4j: File experts (developers who touched these files most)
- Neo4j: Related past PRs (PRs that touched the same files)
Step 5: Agentic AI Analysis
Location:app/services/ai_service.py:536
Nectr supports two review modes:
Standard Mode (Default)
- PR metadata (title, body, author)
- Diff (up to 15,000 chars)
- File list (name, additions, deletions)
- 8 tools to fetch additional context on-demand
- Claude analyzes diff
- Calls
read_file("app/auth/jwt_utils.py")- needs full context - Calls
search_project_memory("JWT token handling")- checks past decisions - Calls
get_file_history(["app/auth/jwt_utils.py"])- finds experts - Returns final review with verdict + inline suggestions
Tool Call Example
Tool Call Example
Parallel Mode (Opt-In)
- Security agent - Injection, auth flaws, secrets
- Performance agent - N+1 queries, memory leaks, O(n²)
- Style agent - Missing tests, unclear names, dead code
Step 6: Post Review to GitHub
Location:app/services/pr_review_service.py:716
POST /repos/{owner}/{repo}/pulls/{pr_number}/reviews
Inline suggestions use GitHub’s suggestion format. Users can click “Commit suggestion” to apply the fix directly.
Step 7: Index PR in Neo4j
Location:app/services/graph_builder.py:197
Step 8: Extract Memories to Mem0
Location:app/services/memory_extractor.py
Claude extracts learnings from the PR review:
repo: Repository full namedeveloper: GitHub username (for developer-specific memories)category: Memory type
Step 9: Update Event Status
Location:app/services/pr_review_service.py:744
Failure Handling
If any step fails (GitHub API error, Claude timeout, Neo4j unreachable), the workflow:- Logs the error with full traceback
- Updates
event.status = "failed" - Stores error message in
workflow.error - Does not retry automatically (prevents duplicate reviews)
Performance Metrics
The webhook returns
HTTP 200 in < 1 second. All processing happens in the background.Next Steps
Service Layer
Deep dive into PR review, AI, and context services
Neo4j Graph
Learn about the knowledge graph schema