Skip to content

Bot-code-2003/Code-Review-Agent

Repository files navigation

🤖 Reactive AI Code Review Assistant

An intelligent code review tool powered by Reactive AI Agents that adapt and specialize based on your code's specific needs. The system automatically analyzes your code and routes it to the most appropriate AI specialists for review and optimization.

🌟 Key Features

🧠 Reactive AI Agent System

  • Adaptive Intelligence: AI agents analyze code complexity and route to specialized reviewers
  • Dynamic Specialization: Automatic selection of security, performance, or architecture specialists
  • Self-Correcting Workflows: Quality assessment with automatic refinement loops
  • Context-Aware Optimization: Optimizers adapt based on review findings and code characteristics

📊 Multi-Input Support

  • 📄 File Upload: Single Python file analysis
  • 📝 Code Paste: Direct code input
  • 📁 Folder Analysis: Batch processing of multiple files
  • 🔗 GitHub Integration: Clone and analyze repositories with PR creation

🚀 Advanced Capabilities

  • Intelligent Routing: AI determines the best review strategy automatically
  • Specialized Agents: Security, performance, architecture, and general code specialists
  • Quality Assurance: Built-in assessment and refinement mechanisms
  • Comprehensive Reports: Detailed analysis with comparison scores and recommendations

🛠️ Setup Instructions

Prerequisites

  • Python 3.8+
  • Azure OpenAI API access
  • GitHub Personal Access Token (optional, for GitHub features)

Installation

  1. Clone and Setup

    git clone <repository-url>
    cd updated_code_review
    python -m venv venv
    venv\Scripts\activate  # Windows
    # source venv/bin/activate  # Linux/Mac
  2. Install Dependencies

    pip install -r requirements.txt

    Or use the automated setup script:

    python setup.py
  3. Configure Environment

    Copy .env.template to .env and configure:

    # Azure OpenAI Configuration
    AZURE_OPENAI_API_KEY=your_api_key
    AZURE_OPENAI_ENDPOINT=your_endpoint
    AZURE_OPENAI_API_VERSION=2024-12-01-preview
    AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o
    AZURE_OPENAI_MODEL_NAME=gpt-4o
    
    # GitHub Configuration (Optional)
    GITHUB_TOKEN=your_github_token
    GITHUB_USERNAME=your_username
    
    # LangChain Configuration (Optional)
    LANGCHAIN_TRACING_V2=true
    LANGCHAIN_API_KEY=your_langchain_key
    LANGCHAIN_PROJECT=Code-Review-New

🚀 Running the Application

streamlit run streamlit_app.py

Open your browser to http://localhost:8501

🔄 How Reactive AI Agents Work

📋 Review Workflow

Code Input → Analyzer Agent → Router Agent → [Specialist Agent] → Implementer → Quality Assessor → [Refinement Loop] → Final Report

Available Review Specialists:

  • 🔒 Security Specialist: Input validation, auth issues, injection attacks
  • Performance Specialist: Algorithm efficiency, caching, async processing
  • 🏗️ Architecture Specialist: Design patterns, SOLID principles, scalability
  • 🔧 General Reviewer: Overall code quality and best practices

⚡ Optimization Workflow

Review Results → Optimization Analyzer → Router → [Optimization Specialist] → Assessor → [Refinement Loop] → Optimized Code

Available Optimization Specialists:

  • 🚀 Performance Optimizer: Time complexity, vectorization, parallel processing
  • 💾 Memory Optimizer: Memory allocation, generators, efficient data structures
  • 📈 Scalability Optimizer: Async patterns, connection pooling, microservices
  • 🏛️ Architecture Optimizer: SOLID principles, design patterns, modularity

📁 Project Structure

updated_code_review/
├── streamlit_app.py                 # Main Streamlit application
├── workflow_reactive_review.py      # Reactive review workflow
├── workflow_reactive_optimize.py    # Reactive optimization workflow
├── prompts.py                      # AI prompts for all agents
├── state.py                        # Workflow state management
├── github_integration.py           # GitHub API integration
├── interconn_updated.py            # Code interconnection analysis
├── utils.py                        # Utility functions
├── requirements.txt                # Dependencies
├── .env.template                   # Environment template
└── README.md                       # This file

🎯 Usage Guide

Step 1: 📝 Input Your Code

Choose your preferred input method and select specialization focus.

Step 2: 🔍 Reactive AI Review

The system automatically:

  • Analyzes code complexity and characteristics
  • Routes to the most appropriate specialist agent
  • Generates comprehensive review reports
  • Self-corrects if quality is insufficient

Step 3: ⚡ Reactive AI Optimization

Based on review findings:

  • Analyzes optimization opportunities
  • Selects the best optimization strategy
  • Applies specialized improvements
  • Validates and refines results

Step 4: 🚀 Deploy Changes

  • Download optimized code
  • Create GitHub pull requests (for repositories)
  • View detailed before/after comparisons

🔧 GitHub Integration

For GitHub repositories, the tool can:

  • Clone repositories automatically
  • Create feature branches
  • Commit optimized code
  • Generate pull requests with detailed descriptions

Requirements:

  • GitHub Personal Access Token with repo scope
  • Push access to the target repository (or fork workflow for external repos)

🆘 Troubleshooting

Common Issues

  1. Azure OpenAI Errors: Verify API credentials and quota
  2. GitHub Integration: Check token permissions and repository access
  3. File Processing: Ensure valid Python syntax and file permissions

Getting Help

  • Check Streamlit error messages in the UI
  • Review console output for detailed errors
  • Verify all environment variables are set correctly

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Implement your changes
  4. Test with various code samples
  5. Submit a pull request

📄 License

MIT License - see LICENSE file for details.


Powered by Reactive AI Agents 🤖✨

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published