Inspiration

EcoCode AI was inspired by a simple question: What does our code cost the planet? While developers optimize for speed and scalability, the environmental impact of inefficient software is often ignored. We wanted to create a platform that makes software sustainability measurable, actionable, and easy for developers to understand.

What it does

EcoCode AI is an AI-powered sustainable software engineering platform that analyzes Python code or GitHub repositories to measure estimated CO₂ emissions, CPU usage, memory consumption, and code complexity. It generates a Green Score, detects inefficient coding patterns, and provides AI-powered optimization suggestions using Google Gemini AI. The platform also includes before-vs-after performance comparisons, sustainability reports, and secure sandboxed execution.

How we built it

We built EcoCode AI using Python and Streamlit. Runtime analysis is powered by CodeCarbon, psutil, and tracemalloc, while static analysis uses Python’s AST module and Radon for complexity detection. A sandboxed execution engine safely runs untrusted code in isolated child processes with timeout protection. The optimization layer combines deterministic refactoring rules with Google Gemini AI for intelligent code improvements.

Gemini API Usage

EcoCode AI uses the Google Gemini API in gemini_analyzer.py for two purposes: Sustainability Reporting — After static analysis, the user's code and detected issues are sent to Gemini with a structured prompt. Gemini returns a plain-language report explaining what is inefficient, why it matters, and what the environmental cost is at scale.

Code Refactoring — Gemini receives the original code with a sustainability-focused prompt instructing it to reduce loop complexity, memory usage, and redundant computation. It returns a fully rewritten, optimized version along with a plain-language explanation of every change made. The API is called once per analysis. The refactored output is always shown alongside the original — never silently replacing it — so developers retain full control over what gets applied.

Challenges we ran into

One of the biggest challenges was securely executing untrusted code while accurately capturing runtime metrics before timeouts occurred. Measuring emissions for very short-running scripts was also difficult because carbon tracking tools are optimized for larger workloads. Another challenge was ensuring AI-generated optimizations remained transparent, reliable, and understandable for developers.

Accomplishments that we're proud of

We are proud of building a platform that turns invisible environmental costs into measurable insights. The secure sandboxed execution engine, real-time carbon tracking, and AI-powered optimization pipeline were major technical achievements. We are also proud that the Green Score system is transparent and explainable rather than a black-box metric.

What we learned

We learned that sustainable software engineering is closely connected to efficient software engineering. Reducing unnecessary computation, memory usage, and complexity not only lowers emissions but also improves performance and scalability. We also learned how challenging real-world carbon measurement can be at the software level.

What's next for EcoCode AI

We plan to expand support beyond Python to languages like JavaScript, Java, and C++. Future goals include CI/CD integration for automated carbon audits, IDE extensions for real-time sustainability feedback, improved AI-driven scoring models, and team dashboards for tracking engineering carbon footprints over time.


THANK YOU! Code Smarter. Emit Less.

Built With

Share this project:

Updates