An AI-powered code analysis tool that provides comprehensive code quality insights, automated issue detection, and intelligent Q&A capabilities using an advanced code-aware RAG system with a professional CLI interface.
- Multi-Language Support: Python, JavaScript, TypeScript
- AI-Powered Analysis: Advanced code quality assessment with AST parsing
- Professional CLI Interface: Beautiful, interactive command-line experience
- Interactive Q&A: Chat with AI about your codebase
- GitHub Integration: Analyze remote repositories directly from URLs
- Enhanced RAG System: Advanced code-aware RAG with AST parsing, entity extraction, and relationship mapping
- Docker Support: Containerized deployment with memory optimization
- Free LLM Support: Powered by Groq (free tier) with OpenAI fallback
# One command to run everything
docker-compose up code-analyzer-pro# Run with pre-built image
docker run --rm -it code-analyzer-pro \
python -m code_quality_agent chat https://github.com/username/repo-
Install dependencies:
pip install -r requirements.txt
-
Configure API key (or use setup script):
python setup.py # Interactive setup -
Start interactive chat:
python -m code_quality_agent chat https://github.com/username/repo
Quick Run:
python -m code_quality_agent chat <your repo name>
# Interactive setup script (recommended)
python setup.pyThe setup script will:
- π€ Ask for LLM provider (Groq/OpenAI)
- π Request API keys
- π§ Let you choose models
- βοΈ Configure analysis settings
- πΎ Create
.envfile automatically
Create .env file manually:
GROQ_API_KEY=your_groq_api_key_here
OPENAI_API_KEY=your_openai_key_here
LLM_PROVIDER=groq# Analyze GitHub repository with interactive chat
python -m code_quality_agent chat https://github.com/username/repo
# Analyze local codebase with interactive chat
python -m code_quality_agent chat /path/to/codeFeatures:
- π¨ Beautiful CLI UI with professional panels and colors
- π¬ Interactive Q&A - Ask natural language questions
- π Built-in Commands -
analyze,security,performance,help - π Real-time Analysis - Live code quality metrics
- π GitHub Integration - Direct URL analysis
analyze- Run comprehensive code quality analysissecurity- Check for security vulnerabilitiesperformance- Identify performance bottleneckscomplexity- Analyze code complexitydocumentation- Review documentation gapstesting- Assess testing coveragehelp- Show detailed command referencequit- Exit the application
# Analyze a directory
python -m code_quality_agent analyze ./my-project
# Analyze with enhanced mode
python -m code_quality_agent analyze ./my-project --enhanced
# Save results to file
python -m code_quality_agent analyze ./my-project --output results.json# Analyze a GitHub repository
python -m code_quality_agent analyze https://github.com/user/repo
# Analyze specific branch
python -m code_quality_agent analyze https://github.com/user/repo@develop
# Search for popular repositories
python -m code_quality_agent search python --limit 10# Chat with AI about your code
python -m code_quality_agent chat ./my-projectCreate a .env file in the project root:
# LLM Provider Configuration
LLM_PROVIDER=groq
# Groq API Configuration (Free tier available)
GROQ_API_KEY=your_groq_api_key_here
GROQ_MODEL_NAME=llama-3.1-8b-instant
# OpenAI API Configuration (Paid - optional fallback)
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL_NAME=gpt-3.5-turbo
# Analysis Configuration
MAX_FILE_SIZE_MB=10
SUPPORTED_LANGUAGES=python,javascript,typescript
DEFAULT_SEVERITY_THRESHOLD=medium
# RAG Configuration
VECTOR_DB_PATH=./data/vector_db
EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
## ποΈ Architecture
### Core Components
- **`analyzer.py`**: Main code analysis engine
- **`qa_agent.py`**: AI-powered Q&A system
- **`rag_system.py`**: Retrieval-Augmented Generation
- **`github_analyzer.py`**: GitHub repository integration
- **`interactive_cli.py`**: Professional CLI interface
- **`cli.py`**: Command-line interface
### AI Integration
- **Groq**: Free LLM for Q&A and analysis
- **OpenAI**: Optional paid fallback
- **Local Embeddings**: Free vector embeddings
- **LangChain**: AI framework integration
## ποΈ Architecture & Improvements
### Enhanced CLI Interface
- **Professional UI Design**: Beautiful panels with Rich library styling
- **Interactive Commands**: Built-in commands for analysis, security, performance
- **Real-time Feedback**: Live progress indicators and status updates
- **Color-coded Output**: Professional color scheme for better readability
### Advanced Code-Aware RAG System
- **AST-Based Understanding**: Deep code structure analysis beyond simple text processing
- **Entity Extraction**: Intelligent identification of functions, classes, variables, and imports
- **Relationship Mapping**: Code dependency tracking, call chains, and inheritance analysis
- **Enhanced Metadata**: Rich contextual information including line numbers, dependencies, and callers
- **Semantic Search**: Vector similarity search enhanced with code relationship context
- **Source Attribution**: Precise file, line, and function-level source tracking
### Memory Optimization
- **Docker Memory Limits**: Optimized for 1GB RAM usage
- **CPU-only PyTorch**: Reduced memory footprint
- **Environment Variables**: Memory optimization settings
- **Lightweight Dependencies**: Minimal package requirements
### GitHub Integration
- **Direct URL Analysis**: Analyze repositories without cloning locally
- **Automatic Download**: Temporary repository cloning and cleanup
- **Repository Metadata**: Stars, forks, language detection
- **Path Resolution**: Automatic path handling for downloaded repos
## π Analysis Features
### Code Quality Metrics
- **Security Issues**: Vulnerabilities and security risks
- **Performance Problems**: Bottlenecks and optimization opportunities
- **Code Smells**: Maintainability issues
- **Testing Gaps**: Missing test coverage
- **Documentation Issues**: Incomplete or missing docs
- **Complexity Analysis**: Cyclomatic complexity and code complexity
### Issue Detection
- **Automated Scanning**: AST-based analysis
- **Pattern Recognition**: Common anti-patterns
- **Best Practices**: Coding standard violations
- **Severity Scoring**: P0-P4 priority levels
## π³ Docker Deployment
### Containerized Setup
- **Memory Optimized**: Runs efficiently with 1GB RAM
- **Environment Isolation**: Clean, reproducible environment
- **Volume Mounting**: Access to local code and configuration
- **Multi-platform**: Works on Windows, macOS, and Linux
### Docker Commands
#### Simple Usage (Recommended)
```bash
# Use Docker Compose (easiest)
docker-compose up code-analyzer-pro
# Or simple Docker run
docker run --rm -it code-analyzer-pro \
python -m code_quality_agent chat https://github.com/username/repo# Build the image
docker build -t code-analyzer-pro .
# Run with custom settings
docker run --rm -it --memory=1g --memory-swap=1g \
-v ${PWD}:/workspace:ro \
-v ${PWD}/.env:/app/.env:ro \
code-analyzer-pro \
python -m code_quality_agent chat https://github.com/username/repoUnlike vanilla RAG systems that treat code as simple text, our system provides deep code understanding:
- Code Structure Analysis: AST parsing understands syntax and semantics
- Entity-Aware Processing: Identifies functions, classes, variables, and their relationships
- Dependency Tracking: Maps how code pieces connect and depend on each other
- Contextual Retrieval: Finds relevant code based on meaning, not just keywords
- Code Indexing: Vector embeddings with rich metadata and structural information
- Semantic Search: Find relevant code sections based on functionality and relationships
- Context-Aware Q&A: AI understands your codebase structure and can explain how components work together
- Source Attribution: Precise tracking of which files, lines, and functions provide information
- Local Processing: No external API calls for embeddings - all processing happens locally
python -m code_quality_agent analyze ./my-python-project --enhancedpython -m code_quality_agent chat ./my-project
# Ask sophisticated questions that showcase enhanced RAG:
# "What are the main functions in this code?"
# "How does the authentication system work?"
# "What are the dependencies between modules?"
# "Show me the call chain for user registration"
# "What functions depend on the database connection?"
# "How can I improve the performance of this specific function?"
# "What security vulnerabilities exist in the auth module?"
# "Explain the data flow from API request to database storage"python -m code_quality_agent analyze https://github.com/microsoft/vscode-python- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Groq: For providing free LLM access
- LangChain: For AI framework capabilities
- ChromaDB: For vector storage
- Rich: For beautiful CLI output
For issues and questions:
- Check the documentation
- Search existing issues
- Create a new issue with details
- Join our community discussions
Made with β€οΈ for developers who care about code quality


