How coderabbitai/ai-pr-reviewer works
Main System Components
a) GitHub Integration Layer
• This as a top-level component that handles GitHub events
• Webhook receivers for PR events and comment events
• Integration with GitHub API (via Octokit)
b) Core Processing Layer
• Central controller component (main.ts)
• Review processor
• Comment processor
• Token management system
c) OpenAI Integration Layer
• API client interface
• Model selector (GPT-3.5-Turbo vs GPT-4)
• Token counting and management
Component Relationships
a) Primary Flow:
GitHub Events → GitHub Integration → Core Processing → OpenAI Integration → GitHub Response
b) Secondary Flows:
• Comment handling flow
• Token management flow
• Review skip logic flow
Specific Components
• Bot Controller (bot.ts)
• Comment Manager (commenter.ts)
• Input Handler (inputs.ts)
• Review Manager (review.ts)
• Tokenizer (tokenizer.ts)
• Prompt Manager (prompts.ts)
Key Interactions to Highlight
Crucial interactions:
• PR event triggering review process
• Comment event triggering conversation
• Token limit checks
• Model selection logic
• Review skip conditions
Technical Details
Annotations for:
• Used models (gpt-3.5-turbo, gpt-4)
• API endpoints
• Configuration options
• Concurrency handling
Specific Implementation Notes
Create sections showing:
• Environment variable handling
• Permission requirements
• Webhook event processing
• Error handling paths
┌─ GitHub Layer ─────────────────────┐
• PR Events │
• Comment Events │
• GitHub API Integration │
• Core Processing Layer ────────────┤
• Review Logic │
• Comment Processing │
• Token Management │
• AI Integration Layer ─────────────┤
• OpenAI API Client │
• Model Selection │
• Response Processing │
• ┘