How tusgino/llm-code-reviewer works
Main Components
• GitHub Integration: Include a component labeled “GitHub Actions Workflow” that shows the triggering of the review process on pull request events. This represents the .github/workflows and overall action trigger.
• Core Application: A “Main Application” component (from src/main.py) that orchestrates the review process.
• Core Modules:
• “Core Config & Models” (src/core/config.py and src/core/models.py) – Handles configuration settings and data models.
• “Services” – This component further divides into:
• “AI Service” (src/services/ai_service.py): Central logic for handling code review using LLMs.
• “GitHub Service” (src/services/github_service.py): Handles interactions with GitHub (e.g., posting comments back to PRs).
• “LLM Integrations” (src/services/llms/): Contains specific adapters for each LLM provider (openai.py, gemini.py, anthropic.py) with a base class for common interfaces (base.py).
• Libraries & Utilities:
• “Libraries Module” (src/libs) – e.g., Hunk parsing (Hunk.py) for code differences.
• “Utilities” (src/utils) – Include components for parsing diffs (diff_parser.py), analyzing code (code_analyzer.py), and language validation (language_validator.py).
Relationships & Interactions
• Within the “AI Service” component, show that it delegates to specific LLM integrations (OpenAI, Gemini, Anthropic) using the “LLM Integrations” module. This abstraction allows switching between LLMs based on configuration inputs.
• The “Core Config & Models” component should interact with both services, providing configuration details (like model selection and API keys) and handling the abstraction of data used across modules.
• The “Libraries” and “Utilities” components should be linked to the “Main Application” and “AI Service” as they provide necessary support for analyzing code changes (diffs, language info) and preparing inputs for reviews.
Architectural Patterns & Design Principles
• Service Abstraction: Emphasize the modular design of the LLM integrations where a base interface allows multiple model implementations.
• Configuration Driven: Highlight that configurations (API keys, model selections, file exclusion patterns, etc.) are supplied centrally via configuration files (e.g., src/core/config.py) and via the action’s inputs.