We were inspired by the hackathon track name β "Clean Code" β and the broader Sustainable Web Design movement π.
As developers, we believe that writing efficient, sustainable code can have a meaningful impact on our planet, and we wanted to create a tool that empowers developers to take action β¨.
RepoReLeaf analyzes your GitHub repositories, estimates the carbon footprint of your code πΏ, suggests direct changes to make it more sustainable, and even pushes those improvements to a new branch automatically ππ±.
Our stack:
- Frontend: React + Vite β‘
- Backend: FastAPI + Gemini API (LLM) π§
We also developed a custom GitHub App π οΈ that interacts with repositories, enabling seamless integration and automatic branch creation with sustainability-focused improvements.
-
Parse the Code
We scan the repository code for static heuristics(file sizes, unused code, image formats, etc) that we find through our parsing script and estimate dynamic properties (DOM size, server response times, etc) using the Gemini LLM π§©. -
Analyze and Find Problems
Using sustainable web development practices π±, we prompt Gemini to analyze specific files and detect predefined problems (like inefficient image handling, unoptimized loops, etc.) π΅οΈββοΈ. -
Generate Solutions
For each identified problem in a file, we provide Gemini with instructions to generate code improvements targeted at fixing those issues π§π. -
Push Changes
Once the improved code is generated, we offer users the ability to push the changes directly to a new branch on their selected GitHub repository ππΏ.
Throughout the project, we learned:
- How to estimate digital emissions based on file storage and code complexity β‘π¦.
- Best practices for sustainable web development π.
- How to leverage LLMs like Gemini for large-scale code analysis and generation π€.
- Building and integrating a GitHub App to automate code contributions π§.
One major challenge was deciding how to estimate emissions from repository code π€.
After research and discussion, we chose to follow the methodology outlined in Sustainable Web Design's estimation guide, using storage size and additional heuristics inspired by sustainable web development guidelines π.
Another challenge was working with Gemini API for code generation π§©. Some of the larger reasoning tasks we needed β like suggesting holistic improvements for large files β were too slow to process in a single request π’.
We had to rethink our approach and break tasks down into smaller, faster operations β‘.
We hope RepoReLeaf helps developers make cleaner, greener code accessible to everyone β making sustainability a first-class citizen in the world of software development ππ.