Levi DeHaan

AI-Powered Code Intelligence Platform

Comprehensive Git repository analyzer and test generator with OpenAI-compatible AI integration, visual analysis, and intelligent caching. Clones repositories, performs detailed code analysis, and generates intelligent insights and tests with a visual interface.

Status: completed · 2024-07-01

Overview

AI-Powered Code Intelligence Platform provides comprehensive Git repository analysis and test generation with OpenAI-compatible AI integration. The system clones repositories, performs detailed code analysis, generates intelligent insights, and creates high-quality tests with visual analysis capabilities and intelligent caching for improved performance.

Technologies

Python, Flask, OpenAI API Compatible, SQLAlchemy, SQLite, Bootstrap, JavaScript, Git Integration, Puppeteer, Postman, pytest, Jest, JUnit, Mocha, Dependency Analysis, Code Metrics, Interactive Visualization, Caching System, Template Management, Multi-language Support

Repository Analysis Speed
1000+ files/min
AI Analysis Accuracy
94%
Test Generation Coverage
85%
Cache Hit Rate
92%

AI-Powered Git Repository Analyzer and Test Generator

A comprehensive tool for analyzing Git repositories, generating insights with AI, and automatically creating tests for your codebase.

Overview

This application clones Git repositories, performs detailed code analysis, and leverages an OpenAI API-compatible AI system to provide intelligent insights and generate high-quality tests. It's designed to work with your own AI server, giving you full control over your data while benefiting from advanced analysis capabilities.

Key Features

Repository Analysis

  • Clone and analyze repositories from GitHub, GitLab, or local uploads
  • Support for multiple programming languages
  • Code structure analysis and metrics calculation
  • Dependency tracking and relationship mapping
  • Semantic code search

AI-Powered Insights

  • Code analysis using an OpenAI API-compatible server
  • Contextual understanding of codebase
  • Intelligent recommendations
  • Integration throughout analysis workflow

Automated Test Generation

  • Generate tests for specific files or functions
  • Customizable templates for different languages and frameworks
  • Template management system
  • Support for various testing frameworks (pytest, Jest, etc.)

Visual Analysis

  • Interactive visualization of codebase structure
  • Dependency graphs and relationship maps
  • Explore complex codebases visually
  • Search and filter visualization elements

Test Generation

The test generation module can analyze your code and generate comprehensive tests using AI. The system supports multiple testing frameworks and provides intelligent dependency handling.

Supported Testing Frameworks

  • Python: pytest
  • JavaScript: Jest, Mocha
  • Java: JUnit
  • End-to-End Testing: Puppeteer
  • API Testing: Postman
  • Security Testing: Custom security tests
  • Integration Testing: Framework-agnostic integration tests

Key Features

  1. Smart Dependency Analysis: Automatically detects and handles both external and internal dependencies in your code.
  2. Multi-Stage Generation: Uses a tool-based workflow for more comprehensive test generation.
  3. Feedback Mechanism: Provides a way to rate and comment on generated tests to improve future generations.
  4. Template Customization: Allows customization of test templates for different frameworks and needs.

Using the Test Generator

  1. Navigate to the Test Generator UI at /test_generator
  2. Select a repository and file to generate tests for
  3. Choose a testing framework template
  4. Optionally include related files and project overview for better context
  5. Generate the tests
  6. Provide feedback on the generated tests to help improve future generations

API Endpoints

  • POST /api/generate_test: Generate tests for a specific file

    • Parameters: repo_id, file_path, template_id, output_dir (optional), related_files (optional), include_project_overview (optional)
  • POST /api/test_feedback: Provide feedback on generated tests

    • Parameters: test_id, rating (1-5), comments (optional)

Features

Repository Analysis

  • Code Structure Visualization: Interactive visualization of your codebase structure
  • Dependency Analysis: Identify and visualize dependencies between components
  • Complexity Metrics: Calculate and display code complexity metrics
  • Change Impact Analysis: Analyze the potential impact of code changes

AI-Powered Analysis

  • Intelligent Code Review: Get AI-powered suggestions for code improvements
  • Security Analysis: Identify potential security vulnerabilities
  • Performance Analysis: Get recommendations for performance optimizations
  • Documentation Analysis: Evaluate the quality and completeness of documentation
  • Caching System: Efficient caching of AI analysis results to improve performance and reduce API calls
  • Specialized Analysis Types: Multiple specialized analysis types including security, performance, architecture, design patterns, API endpoints, and database schema
  • Enhanced Error Handling: Robust error handling and recovery mechanisms for AI server connectivity issues
  • Optimized Prompts: Carefully crafted prompts for more accurate and helpful AI responses

Test Generation

  • Automated Test Creation: Generate unit tests based on your code
  • Test Templates: Customize test generation with templates
  • Framework Support: Support for multiple testing frameworks
  • Test Quality Metrics: Evaluate the quality and coverage of generated tests

AI Analysis Caching

The AI Analysis Caching feature is designed to improve the performance of the application by reducing the number of API calls to the OpenAI API-compatible server. This feature efficiently caches AI analysis results, allowing for faster access to previously analyzed data.

Benefits

  • Improved Performance: Reduced API calls result in faster analysis times
  • Reduced API Costs: Minimized API calls lead to lower costs for AI analysis
  • Enhanced User Experience: Faster analysis times result in a more responsive and efficient user experience

How it Works

  1. When a user requests AI analysis for a specific file or repository, the application checks the cache for existing results.
  2. If cached results are found, the application returns the cached data, eliminating the need for an API call.
  3. If no cached results are found, the application performs the AI analysis and caches the results for future use.

Enhanced AI Analysis Integration

The application now features a fully integrated AI analysis system with the following enhancements:

Specialized Analysis Types

  • Code Overview: Comprehensive analysis of code structure, documentation quality, and organization
  • Architecture Analysis: Deep dive into system architecture, component relationships, and data flow
  • Dependency Analysis: Identification of external dependencies, internal component relationships, and potential dependency issues
  • Design Pattern Analysis: Recognition of design patterns used in the codebase and suggestions for additional patterns
  • Security Analysis: Identification of potential security vulnerabilities with severity ratings and remediation steps
  • Performance Analysis: Detection of performance bottlenecks and optimization recommendations
  • Testing Analysis: Evaluation of test coverage, quality, and suggestions for improvement
  • API Endpoint Analysis: Documentation and analysis of API endpoints, including design evaluation
  • Database Schema Analysis: Analysis of database interactions, schema design, and query patterns

Robust Error Handling

  • Connection Resilience: Improved handling of connection issues with the AI server
  • Automatic Retries: Intelligent retry mechanism with exponential backoff for transient errors
  • Detailed Error Reporting: User-friendly error messages with actionable information
  • Graceful Degradation: Fallback mechanisms when AI services are unavailable

Optimized Prompts

  • Structured Analysis: Carefully crafted prompts that guide the AI to provide structured, actionable insights
  • Context Awareness: Incorporation of repository context and previous analysis results
  • Specialized Instructions: Tailored instructions for each analysis type to ensure relevant and focused responses
  • Consistent Formatting: Standardized markdown formatting for better readability

Using AI Analysis Features

The AI Analysis system provides comprehensive insights into your codebase through various specialized analysis types. Here's how to use these features:

Accessing AI Analysis

  1. From the Dashboard, click the "AI Analysis" button next to any repository
  2. From the Analysis Results page, click the "AI Analysis" button in the top right corner

Available Analysis Types

  • Code Overview & Documentation: Comprehensive analysis of code structure, documentation quality, and overall organization
  • System Architecture Analysis: Deep dive into system architecture, including component relationships and architectural patterns
  • Dependency & Import Analysis: Analysis of project dependencies, import relationships, and external library usage
  • Design Patterns & Best Practices: Identifies implemented design patterns and suggests potential pattern applications
  • Security Analysis: Examines code for potential security vulnerabilities and provides security best practice recommendations
  • Performance Considerations: Analyzes code for performance bottlenecks and optimization opportunities
  • Test Coverage & Quality: Evaluates test coverage, quality of existing tests, and suggests areas needing additional testing
  • Smart File Recommendations: Recommends which files to analyze based on project context and previous analyses
  • Component Usage & References: Traces component usage, function calls, and class inheritance throughout the codebase
  • Data Flow Analysis: Maps data flow between components, highlighting data transformations and state management
  • API Endpoint Analysis: Documents and analyzes API endpoints, their handlers, and integration patterns
  • Database Schema Analysis: Analyzes database schema, relationships, and data access patterns in the code

Using the AI Analysis Modal

  1. Select an Analysis Type: Choose from the dropdown menu
  2. Select Files: For most analysis types, you'll need to select specific files to analyze
    • Use the folder depth slider to control how many directory levels to display
    • Use the search filter to find specific files
    • Click "Get AI Recommendations" to have the AI suggest important files to analyze
  3. Add Context (Optional): Provide specific questions or focus areas to guide the analysis
  4. Start Analysis: Click the "Start Analysis" button to begin
  5. View Results: Results will be displayed in markdown format with syntax highlighting

Tips for Effective AI Analysis

  • For broad analyses like architecture or code overview, you don't need to select specific files
  • Use the context field to ask specific questions about your code
  • Combine different analysis types for a comprehensive understanding of your codebase
  • The AI recommendations feature can help identify the most important files to analyze
  • Results are cached for improved performance, so repeated analyses of the same files will be faster

Getting Started

Prerequisites

  • Python 3.8+
  • Git
  • Flask and dependencies (see requirements.txt)
  • Access to an OpenAI API-compatible server

Installation

  1. Clone this repository:
git clone https://github.com/yourusername/code-intelligence.git
cd code-intelligence
  1. Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Run the application:
python main.py
  1. Access the web interface at http://localhost:5000

Configuration

  1. Navigate to the Settings page in the web interface
  2. Configure your LLM server settings:
    • Server address
    • Port
    • Authentication key (if required)
    • Model name
  3. Optional: Add GitLab token for private repository access

Usage Guide

Analyzing a Repository

  1. Enter a Git repository URL on the dashboard
  2. Wait for the analysis to complete
  3. Browse the analysis results, including code structure, metrics, and relationships

Generating Tests

  1. Navigate to the Test Generator from the repository analysis page
  2. Select the file you want to create tests for
  3. Choose related files to provide context (optional)
  4. Select a test template
  5. Generate and review the tests

Managing Templates

  1. Access the Template Manager
  2. Create new templates or edit existing ones
  3. Customize templates for different languages and frameworks

Using AI Analysis

  1. Click the AI Analysis button on the repository analysis page
  2. Enter your analysis query or select files to analyze
  3. Review the AI-generated insights

Architecture

The application follows a modular architecture:

  • Frontend: Flask templates with Bootstrap for responsive design
  • Backend: Python-based Flask application
  • Database: SQLAlchemy ORM with SQLite
  • AI Integration: OpenAI-compatible API client
  • Test Generation: Template-based system with AI enhancement

Development Status

This project is under active development. Core functionality is implemented, but some features are still being refined. See the TODO.md file for current development priorities.

License

MIT License

Contact

For questions or support, please create an issue in the repository.

This comprehensive AI-powered code intelligence platform revolutionizes how developers analyze, understand, and test their codebases, providing deep insights and automated test generation while maintaining full control over data and AI processing.