JSPM

gaya-code

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q55155F
  • License MIT

๐ŸŒฑ Analyze the environmental impact of your Node.js code with beautiful dashboards and actionable insights

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gaya-code) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    ๐ŸŒฑ GayaCode

    Analyze the environmental impact of your Node.js code with beautiful dashboards and actionable insights

    npm version License: MIT Node.js Version

    GayaCode is a powerful CLI tool that measures and visualizes the environmental impact of your Node.js applications. Get detailed insights into energy consumption, COโ‚‚ emissions, and receive actionable recommendations to make your code more sustainable.

    โœจ Features

    • ๐Ÿ”‹ Energy Consumption Analysis - Track real-time energy usage
    • ๐ŸŒ COโ‚‚ Emission Calculations - See your carbon footprint
    • ๐Ÿ“Š Beautiful Interactive Dashboards - Stunning visualizations with animations
    • ๐ŸŒŠ Live Carbon Flow Visualization - Real-time particle effects
    • ๏ฟฝ Virtual Forest Impact - See how many trees you'd need
    • โšก Power Consumption Radar - Multi-dimensional performance analysis
    • ๐ŸŽฏ Eco Score Rating - Get graded on environmental impact (A+ to F)
    • ๐Ÿ“ˆ Scaling Projections - See impact at different scales
    • ๐ŸŒ Real-World Equivalents - Compare to everyday activities
    • ๐Ÿ—๏ธ SOLID Architecture - Clean, modular, and extensible code

    ๐Ÿš€ Installation

    npm install -g gayacode

    Local Installation

    npm install gayacode
    npx gayacode <script>

    ๐Ÿ“– Usage

    Basic Usage

    # Analyze a script and open dashboard
    gayacode your-script.js
    
    # Analyze without opening browser
    gayacode your-script.js --no-open
    
    # Custom output directory
    gayacode your-script.js -o ./my-reports
    
    # Custom emission factor
    gayacode your-script.js --emission-factor 500

    Advanced Options

    gayacode --help
    Usage: gayacode [options] <script>
    
    ๐ŸŒฑ Analyze the environmental impact of your Node.js code
    
    Arguments:
      script                      Path to the Node.js script to analyze
    
    Options:
      -V, --version               output the version number
      -o, --output <path>         Output directory for the dashboard (default: "./gayacode-report")
      --no-open                   Skip opening the dashboard in browser
      --emission-factor <factor>  COโ‚‚ emission factor (g/kWh) (default: "400")
      --timeout <ms>              Maximum execution time (ms) (default: "60000")
      -h, --help                  display help for command

    ๐Ÿ“Š Dashboard Features

    Performance Timeline

    • Real-time CPU and memory usage graphs
    • Interactive Chart.js visualizations
    • Detailed execution metrics

    Carbon Flow Visualization

    • Animated particle system
    • Real-time COโ‚‚ flow representation
    • Dynamic color coding based on emission rates

    Virtual Forest Impact

    • Growing tree animations
    • Calculate trees needed to offset emissions
    • Beautiful forest visualization with seasonal effects

    Power Consumption Radar

    • Multi-dimensional performance analysis
    • CPU efficiency, memory usage, execution speed
    • Interactive radar charts

    Real-World Impact

    • Energy equivalents (smartphone charges, LED hours, etc.)
    • Carbon equivalents (tree years, car km, flight km)
    • Scaling projections (1K, 1M, 1B executions)

    ๐Ÿ—๏ธ Architecture

    GayaCode follows SOLID principles with a clean, modular architecture:

    src/
    โ”œโ”€โ”€ core/interfaces/         # Core interfaces and types
    โ”œโ”€โ”€ monitoring/             # Process monitoring strategies
    โ”œโ”€โ”€ calculations/           # Environmental calculation strategies
    โ”œโ”€โ”€ utils/                 # Utility functions and formatters
    โ”œโ”€โ”€ dashboard/
    โ”‚   โ”œโ”€โ”€ components/        # Modular dashboard components
    โ”‚   โ”œโ”€โ”€ templates/         # HTML template engine
    โ”‚   โ””โ”€โ”€ DashboardGenerator.js
    โ”œโ”€โ”€ analyzer/              # Main environmental analyzer
    โ””โ”€โ”€ cli/                   # Command-line interface

    Key Components

    • Strategy Pattern: Pluggable monitoring and calculation strategies
    • Component-Based: Modular dashboard components
    • Dependency Injection: Clean separation of concerns
    • Template Engine: Flexible HTML generation
    • Interface Segregation: Well-defined contracts

    ๐ŸŽฏ Eco Score Rating

    GayaCode provides a comprehensive eco score (0-100) with letter grades:

    • A+ (90-100): Excellent - Minimal environmental impact
    • A (80-89): Very Good - Low environmental impact
    • B (70-79): Good - Moderate environmental impact
    • C (60-69): Fair - Room for improvement
    • D (50-59): Poor - Significant environmental impact
    • F (0-49): Very Poor - High environmental impact

    ๐ŸŒ Environmental Metrics

    Energy Consumption

    • Real-time power usage calculation
    • CPU and memory power coefficients
    • High-precision timing measurements

    COโ‚‚ Emissions

    • Configurable emission factors
    • Grid-based carbon intensity
    • Regional emission calculations

    Real-World Equivalents

    • Smartphone battery charges
    • LED light hours
    • Laptop usage time
    • Tree absorption years
    • Car driving distance
    • Flight emissions

    ๐Ÿ“ˆ Example Output

    ๐ŸŒฑ GayaCode - Environmental Impact Analyzer v2.0
    
    โœ… Analysis complete
    
    ๐Ÿ“Š Quick Results:
       โšก Energy: 0.59 ยตWh
       ๐ŸŒ COโ‚‚: 0.0002 g
       โฑ๏ธ  Time: 1242 ms
       ๐Ÿ–ฅ๏ธ  Peak CPU: 160.0%
       ๐Ÿ’พ Peak Memory: 156.7 MB
       ๐ŸŽฏ Eco Score: 61/100 (B)
    
    ๐Ÿ“ Report saved to: ./gayacode-report/index.html

    ๏ฟฝ๏ธ Programmatic Usage

    You can also use GayaCode programmatically in your Node.js applications:

    import { EnvironmentalAnalyzer } from 'gayacode'
    
    const analyzer = new EnvironmentalAnalyzer({
      emissionFactor: 400,
      maxExecutionTime: 60000
    })
    
    const result = await analyzer.analyzeScript('./my-script.js')
    console.log(`Eco Score: ${result.ecoScore.overall}/100`)
    console.log(`COโ‚‚ Emissions: ${result.metrics.co2Grams}g`)

    ๐Ÿค Contributing

    We welcome contributions! Please see our Contributing Guide for details.

    Development Setup

    git clone https://github.com/shalevo13/GayaCode.git
    cd GayaCode
    npm install
    npm run dev test-script.js

    ๏ฟฝ License

    MIT ยฉ GayaCode Contributors

    ๏ฟฝ Acknowledgments

    • Built with โค๏ธ for a more sustainable future
    • Inspired by the need for environmentally conscious software development
    • Uses pidusage for process monitoring
    • Visualizations powered by Chart.js

    Made with ๐ŸŒฑ by developers who care about the planet

    • Local execution (no cloud resources)
    • Efficient monitoring algorithms
    • Optimized frontend bundle size
    • Sustainable development practices

    Made with ๐ŸŒฑ for sustainable software development