PR-AI-Agent is a sophisticated automated code review system that leverages AI to analyze GitHub Pull Requests. Built with a focus on scalability and reliability, it provides detailed insights into code quality, security vulnerabilities, performance implications, and documentation completeness.
- Asynchronous Processing: Handle multiple PR reviews simultaneously
- Scalable Architecture: Each component can be scaled independently
- Real-time Status Updates: Track review progress through API endpoints
- Detailed Analysis: Comprehensive code review covering multiple aspects
- Persistent Storage: Reliable task and result management
- Error Handling: Robust retry mechanisms and error recovery
-
Web Framework: FastAPI
- Async support for high performance
- Built-in OpenAPI documentation
- Type validation with Pydantic
-
Task Queue: Celery
- Distributed task processing
- Automatic retries
- Task monitoring
-
Message Broker & Cache: Redis
- Fast in-memory operations
- Persistent task queue
- Result caching
-
Clone Repository
git clone https://github.com/yourusername/pr-ai-agent.git cd pr-ai-agent
-
Environment Setup
python -m venv .venv source .venv/bin/activate # Unix # or .venv\Scripts\activate # Windows
-
Install Dependencies
pip install -r requirements.txt
-
Configure Environment
cp .env.example .env # Edit .env with your configurations
-
Start Services
# Start Redis redis-server # Start Celery Worker celery -A tasks worker --loglevel=info # Start FastAPI Server uvicorn main:app --reload
curl -X POST "http://localhost:8000/analyze-pr" -H "Content-Type: application/json" -d '{"repo_url": "https://github.com/NixOS/nixpkgs", "pr_number": 350177}'
http://localhost:8000/status/508ae882-027c-4812-a905-020f5b8bf27a
http://localhost:8000/results/508ae882-027c-4812-a905-020f5b8bf27a
Example JSON Response:
{
"task_id": "201c58f9-599b-42ef-a798-52caa0b4d1ea",
"result": {
"files": [{
"name": "merged--generated--merge-conflict",
"issues": [{
"type": "Code Quality",
"line": 0,
"description": "Presence of auto-generated code conflicting with custom code.",
"suggestion": "Review and resolve the merge conflict manually to ensure all necessary functionalities are intact."
}, {
"type": "Documentation Completeness",
"line": 0,
"description": "Lack of inline comments and documentation for complex logic.",
"suggestion": "Include comments explaining the purpose and usage of critical sections of the code."
}]
}],
"summary": {
"total_files": 1,
"total_issues": 2,
"critical_issues": 1
}
},
"error": null
}
-
Enhanced Analysis
- Custom analysis rules
- Language-specific checks
- Team-specific preferences
-
Integration Features
- GitHub webhook support
- CI/CD pipeline integration
- Slack notifications
-
Performance Optimizations
- Response caching
- Task prioritization
- Resource optimization
We welcome contributions! Please see our Contributing Guidelines for details.
This project is licensed under the MIT License - see the LICENSE file for details.
For support, please open an issue in the GitHub repository or contact the maintainers.