A comprehensive Python code analyzer that evaluates code for sustainability, efficiency, and environmental impact. This tool promotes eco-conscious coding practices by providing actionable insights to write more efficient, secure, and environmentally-friendly code.
- β»οΈ Green Score (0β100) based on code efficiency and sustainability
- π Security Analysis (detects
eval
,exec
, hardcoded credentials, injections) - π§ AI-Powered Suggestions for performance and optimization
- π Interactive Dashboard with real-time Plotly visualizations
- π Carbon Footprint Estimation (energy, COβ, real-world equivalents)
- π Gamification with user levels, badges, and global leaderboard
- π§Ύ Downloadable Reports for professional insights and sharing
green-code-checker/
βββ streamlit_app.py # Main Streamlit application
βββ analyzer.py # Core code analysis engine
βββ suggestions.py # Improvement recommendations
βββ security_checker.py # Security vulnerability detection
βββ carbon_calculator.py # Environmental impact calculations
βββ ai_refactor.py # AI-powered code optimization
βββ gamification.py # User levels and achievements
βββ visualization.py # Interactive charts and graphs
βββ database.py # PostgreSQL database operations
βββ history_tracker.py # Analysis history management
βββ report_generator.py # Report creation utilities
βββ sample_code.py # Sample code for testing
βββ test_guide.md # Comprehensive testing guide
βββ replit.md # Project documentation and preferences
βββ README.md # This file
Layer | Tools/Frameworks |
---|---|
Frontend | Streamlit, Plotly |
Backend | Python (AST), AI logic, Refactoring |
Database | PostgreSQL, SQLAlchemy |
Analytics | Custom carbon model + visual stats |
- Input: Python code via web interface
- Validation: Syntax checking and AST parsing
- Analysis: Multi-dimensional code evaluation
- Scoring: Green score calculation (0-100)
- Enhancement: AI-powered optimization suggestions
- Storage: Database persistence for tracking
- Visualization: Interactive dashboard presentation
- Python 3.11+
- PostgreSQL database (provided by Replit)
- Required packages (automatically installed)
- Clone or access the project
- Run the application:
streamlit run streamlit_app.py --server.port 5000
- Access the web interface at
http://localhost:5000
- Code Efficiency (40%): Loop optimization, built-in usage
- Resource Management (25%): Memory and CPU efficiency patterns
- Code Quality (20%): Structure, readability, best practices
- Security Considerations (15%): Vulnerability detection
- 90-100: Excellent - Highly optimized and secure
- 70-89: Good - Minor improvements possible
- 50-69: Average - Several optimization opportunities
- 30-49: Below Average - Significant improvements needed
- 0-29: Poor - Major refactoring required
- Energy Consumption: Estimated microjoules based on code complexity
- Carbon Emissions: CO2 equivalent calculations
- Efficiency Ratings: A+ to F scale classification
- Real-world Equivalents: Smartphone charges, car miles, etc.
This application is designed for deployment on Replit:
- Environment: Nix-based with automatic dependency management
- Database: Built-in PostgreSQL integration
- Hosting: Autoscale deployment with public access
- Configuration: Streamlit server on port 5000
Contributions are welcome! Feel free to fork the repo and submit a pull request.
Let's build together π!
Make sure to check our guidelines before you start.
Development Guidelines
- Follow PEP 8 Python style guidelines
- Add comprehensive docstrings and comments
- Include unit tests for new features
- Update documentation for API changes
- Environmental impact enhancements
- Additional programming language support
- Advanced AI optimization algorithms
- Extended gamification mechanics
This project is licensed under the MIT License - see the LICENSE file for details.
- Streamlit: For the amazing web framework
- Plotly: For interactive visualization capabilities
- Python AST: For code analysis foundation
- PostgreSQL: For robust data persistence
- Green AI Community: For inspiration and best practices
Subuhana B
GitHub: @subuhana2303
Email: subuhanabasheer41@gmail.com
Made with π for sustainable coding practices
Green Code Checker - Helping developers write more efficient, secure, and environmentally-conscious code, one analysis at a time.