Skip to content

GreenCodeChecker is a tool that analyzes code for environmental efficiency and carbon footprint. It helps developers write cleaner, greener code by providing sustainability-focused feedback.

License

Notifications You must be signed in to change notification settings

subuhana2303/GreenCode_Checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌱 Green Code Checker

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 Code Checker Python Streamlit License

πŸš€ Key Features

  • ♻️ 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

πŸŽ₯All Demo cases included:

▢️ Watch Demo

Example Output for High Carbon Cost Code (Heavy Looping)

2025-06-19 (1) 2025-06-19 (2) 2025-06-19 (4) 2025-06-19 (5)


πŸ“ Project Structure

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

πŸ—οΈ Architecture

Layer Tools/Frameworks
Frontend Streamlit, Plotly
Backend Python (AST), AI logic, Refactoring
Database PostgreSQL, SQLAlchemy
Analytics Custom carbon model + visual stats

Data Flow

  1. Input: Python code via web interface
  2. Validation: Syntax checking and AST parsing
  3. Analysis: Multi-dimensional code evaluation
  4. Scoring: Green score calculation (0-100)
  5. Enhancement: AI-powered optimization suggestions
  6. Storage: Database persistence for tracking
  7. Visualization: Interactive dashboard presentation

πŸ› οΈ Installation & Setup

Prerequisites

  • Python 3.11+
  • PostgreSQL database (provided by Replit)
  • Required packages (automatically installed)

Quick Start

  1. Clone or access the project
  2. Run the application:
    streamlit run streamlit_app.py --server.port 5000
  3. Access the web interface at http://localhost:5000

πŸ† Scoring System

Green Score Components

  • 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

Score Ranges

  • 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

🌍 Environmental Impact

Carbon Footprint Calculation

  • 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.

πŸš€ Deployment

This application is designed for deployment on Replit:

  1. Environment: Nix-based with automatic dependency management
  2. Database: Built-in PostgreSQL integration
  3. Hosting: Autoscale deployment with public access
  4. Configuration: Streamlit server on port 5000

🀝 Contribution Welcome!

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

Feature Requests

  • Environmental impact enhancements
  • Additional programming language support
  • Advanced AI optimization algorithms
  • Extended gamification mechanics

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • 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

πŸ‘©β€πŸ’» Author

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.

About

GreenCodeChecker is a tool that analyzes code for environmental efficiency and carbon footprint. It helps developers write cleaner, greener code by providing sustainability-focused feedback.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages