System Overview
Nectr is a full-stack AI code review agent built with a modern, event-driven architecture. The system consists of three main layers:- Frontend - Next.js 15 + React 19 web application (Vercel)
- Backend - FastAPI + Uvicorn Python application (Railway)
- Data Layer - PostgreSQL, Neo4j knowledge graph, and Mem0 semantic memory
Nectr uses an agentic review approach where Claude fetches only the context it needs via tools, rather than receiving all context upfront. This keeps reviews focused and reduces noise.
Architecture Diagram
Core Components
PR Review Service
Orchestrates the full PR review workflow from webhook to GitHub comment
AI Service
Manages Claude AI interactions with agentic tool execution
Context Service
Builds review context from Neo4j graph and Mem0 memories
Graph Builder
Builds and queries the Neo4j knowledge graph
Key Design Principles
1. Agentic Architecture
Rather than overwhelming Claude with all available context upfront, Nectr uses tool-based agentic execution. Claude decides what context it needs and fetches it on-demand:read_file- Fetch full source code when diff isn’t enoughsearch_project_memory- Query project patterns and decisionssearch_developer_memory- Look up developer-specific patternsget_file_history- Find file experts and related PRsget_linked_issues- Pull Linear/GitHub issuesget_related_errors- Fetch Sentry production errors
2. Event-Driven Processing
GitHub webhook events trigger background tasks that:- Return
HTTP 200immediately (< 10s timeout) - Process PR review asynchronously in background
- Update database with status and results
- Post review back to GitHub via REST API
3. Multi-Modal Memory
Structural Memory (Neo4j)- File → Developer relationships
- PR → File touch patterns
- Issue → PR closure links
- Project patterns and decisions
- Developer habits and strengths
- Risk modules and recurring issues
4. Bidirectional MCP Integration
Outbound (Nectr as MCP Server)- Exposes PR reviews, verdicts, contributor stats via MCP
- Claude Desktop and other agents can query Nectr’s data
- Pulls Linear issues, Sentry errors, Slack messages
- Enriches PR reviews with live production context
Technology Stack
| Layer | Technology |
|---|---|
| Frontend | Next.js 15, React 19, TypeScript, TailwindCSS 4 |
| Backend | FastAPI, Uvicorn, Python 3.14 |
| Database | PostgreSQL (asyncpg + SQLAlchemy async) |
| Knowledge Graph | Neo4j (async driver) |
| Semantic Memory | Mem0 |
| AI Model | Anthropic Claude Sonnet 4.6 |
| GitHub Integration | GitHub OAuth + REST API + Webhooks |
| MCP | FastMCP (server) + httpx MCP client |
| Frontend Hosting | Vercel |
| Backend Hosting | Railway |
| Auth | GitHub OAuth → JWT (httpOnly, SameSite=None, Secure) |
| Token Encryption | Fernet (AES-128-CBC) |
Performance Characteristics
Review Latency
Review Latency
- Webhook response: < 1 second (returns 200 immediately)
- Background processing: 10-30 seconds (depends on PR size)
- Agentic tool calls: 3-5 rounds average, ~2s per round
- Parallel agent mode: 15-20 seconds (3 agents + synthesis)
Scalability
Scalability
- Concurrent reviews: Handled by FastAPI async workers
- Database: Connection pooling via SQLAlchemy
- Neo4j: Indexed queries, <100ms for file experts
- Rate limits: GitHub API (5000/hour), Anthropic (tier-based)
Data Volume
Data Volume
- PostgreSQL: ~1 KB per event, ~5 KB per workflow run
- Neo4j: ~100-500 nodes per repo, ~1000-5000 edges
- Mem0: ~10-20 memories per PR review
Security & Privacy
- Token Encryption: GitHub access tokens encrypted with Fernet (AES-128-CBC)
- Webhook Verification: HMAC-SHA256 signature validation per-repo
- JWT Auth: httpOnly cookies, SameSite=None, Secure flag
- CORS: Strict origin allowlist for production
- No Data Sharing: All data stays in your infrastructure
Next Steps
Backend Architecture
Dive into FastAPI service layer and API routes
Frontend Architecture
Explore Next.js structure and React components
Data Flow
Follow a PR review from webhook to comment
Neo4j Graph
Learn about the knowledge graph schema