An AI-powered Python code analyzer that uses machine learning to evaluate code quality, detect code smells, and provide actionable improvement suggestions.
Coming Soon! Deploy to Railway, Render, or Heroku - see DEPLOYMENT.md
- π Static Code Analysis: Comprehensive metrics including cyclomatic complexity, maintainability index, and Halstead metrics
- π€ ML-Powered Quality Prediction: Machine learning model trained to predict code quality scores
- π Code Smell Detection: Automatically detects common anti-patterns and code smells
- π‘ Smart Suggestions: Provides actionable recommendations for code improvement
- π¨ Beautiful Web Interface: Modern, responsive UI for easy code submission and result visualization
- π Detailed Metrics: Lines of code, complexity, documentation ratio, and more
- Python 3.8 or higher
- pip package manager
- Clone the repository:
git clone https://github.com/Corpse-dead/AI-powered-Python-code-analyzer.git
cd AI-powered-Python-code-analyzer- Install dependencies:
pip install -r requirements.txt- Run the application:
python app.py- Open your browser and navigate to:
http://localhost:8000
- Upload a File: Click "Choose File" and select a Python (.py) file
- Paste Code: Copy and paste your Python code directly into the text area
- View Results: Get instant feedback with quality scores, metrics, and suggestions
curl -X POST "http://localhost:8000/api/analyze" \
-F "file=@your_code.py"curl -X POST "http://localhost:8000/api/analyze-text" \
-H "Content-Type: application/json" \
-d '{"code": "def hello(): print(\"Hello, World!\")"}'curl "http://localhost:8000/api/health"smart-code-review/
βββ app.py # FastAPI application entry point
βββ src/
β βββ __init__.py
β βββ code_analyzer.py # Static code analysis module
β βββ ml_models.py # ML-based quality prediction
βββ static/
β βββ index.html # Web interface
β βββ styles.css # Styling
β βββ script.js # Frontend logic
βββ requirements.txt # Python dependencies
βββ README.md # This file
- Lines of Code (LOC): Total lines including comments and blanks
- Logical Lines: Actual code lines (excluding comments/blanks)
- Comment Ratio: Percentage of comments in code
- Cyclomatic Complexity: Measure of code complexity
- Maintainability Index: Overall code maintainability (0-100)
The ML model assigns a quality score (0-100) based on:
- Code structure and organization
- Naming conventions
- Documentation quality
- Complexity metrics
- Best practices adherence
- A (85-100): Excellent code quality
- B (70-84): Good code with minor improvements needed
- C (55-69): Acceptable code, some refactoring recommended
- D (40-54): Poor code, significant improvements needed
- F (0-39): Very poor code, major refactoring required
- Backend: FastAPI (Python web framework)
- ML/AI: scikit-learn, RandomForest classifier
- Code Analysis: Radon, AST, Pylint
- Frontend: HTML5, CSS3, Vanilla JavaScript
- API: RESTful API with JSON responses
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Support for additional programming languages (JavaScript, Java, etc.)
- Integration with GitHub for automatic PR reviews
- Custom rule configuration
- Historical analysis and trend tracking
- VS Code extension
- Docker containerization
- Advanced NLP models (CodeBERT, GraphCodeBERT)
This project is licensed under the MIT License - see the LICENSE file for details.
Created by a CS student passionate about AI/ML and code quality!
- FastAPI for the excellent web framework
- scikit-learn for ML capabilities
- Radon for code metrics
- The Python community for amazing tools and libraries
Questions or suggestions? Feel free to open an issue or reach out!
β If you find this project useful, please consider giving it a star on GitHub!