Inspiration
We often discuss electric vehicles and renewable energy, but we ignore the invisible polluter: The Cloud. The internet and the systems powering it emit approximately 1.6 billion tons of $CO_2$ annually—more than the entire aviation industry.
As developers, we are taught to write code that works, but rarely code that is efficient. A single inefficient loop running on a server farm 24/7 isn't just technical debt; it's an environmental liability. We realized that while hardware is becoming more energy-efficient, software is becoming more bloated. We built Sequoia to bridge the gap between performance engineering and climate action, turning "Green Coding" from a buzzword into a quantifiable, gamified engineering standard.
What it does
Sequoia is an intelligent observability and optimization platform that empowers developers to measure and reduce their code's carbon footprint in real-time.
Real-Time Carbon Profiling: Users input code (snippets or entire repositories), and Sequoia executes it in a secure sandbox, measuring CPU cycles, memory pressure, and energy consumption to calculate the exact carbon emission using the formula: $$C_{total} = E_{kWh} \times I_{grid}$$ Where $E$ is energy consumed and $I$ is the carbon intensity of the local grid.
AI-Powered Refactoring: It doesn't just complain; it fixes. Sequoia detects inefficient algorithms (e.g., $O(n^2)$ complexity) and automatically generates an optimized version (e.g., $O(n \log n)$), providing a side-by-side impact analysis.
Self-Correction Pipeline: If a user submits broken or incomplete code, our "Self-Healing" agent detects syntax errors, fixes the code structure, and ensures it is executable before analysis begins.
Gamified Sustainability: We built a reward system where "Carbon Saved" translates to XP, badges, and leaderboard rankings, incentivizing engineering teams to write cleaner code.
How we built it
We architected a high-performance, AI-driven pipeline designed for precision and scalability.
- The Frontend: Built with Next.js 15 and TypeScript, utilizing the App Router for server-side performance. We used TailwindCSS and Framer Motion for a cinematic, high-contrast UI, and Recharts for visualizing complex telemetry data.
- The Backend: A robust FastAPI microservice architecture. We utilize Docker containers to safely execute untrusted user code, isolating processes to measure
psutilmetrics without background noise. - The Intelligence Layer (AI Stack):
- Optimization Logic: We utilize CodeLlama-70b via high-speed inference to analyze AST (Abstract Syntax Trees) and propose algorithmic optimizations.
- Self-Healing Code: We implemented DeepSeek-Coder-V2 to handle the "Code Fixer" module. It excels at understanding broken context and patching syntax errors so our execution engine never chokes.
- Explainability: We leverage Mistral-Large to generate human-readable explanations of why a specific change reduces energy consumption.
- The Data Engine: Every execution metric is logged into PostgreSQL via Prisma. This creates a proprietary dataset mapping Code Structure $\rightarrow$ Energy Consumption. We are continuously feeding this data into a custom XGBoost regression model, which is being trained to predict energy usage instantly without needing Docker execution in the future.
Challenges we ran into
- The "Observer Effect": Measuring the energy consumption of a script requires running a monitoring script, which itself consumes energy. We had to calibrate our backend to subtract the "overhead" of the monitoring agent to get the true metric of the user's code.
- Sandboxing & Security: Allowing users to run arbitrary Python code is dangerous. We had to build a strict Docker orchestration layer that spins up ephemeral containers, executes the logic, and kills them immediately, all while piping telemetry data back to the main thread in milliseconds.
- AI Hallucination in Logic: Initially, the AI would suggest "optimizations" that broke the code's functionality. We implemented a Validation Loop where the system runs the optimized code against the same inputs as the original code to ensure the output remains identical before suggesting it to the user.
Accomplishments that we're proud of
- The "Auto-Fix" Workflow: We successfully built a pipeline where the system can take broken code, fix it using DeepSeek, analyze it, and then optimize it using CodeLlama—all without user intervention.
- Visualizing the Invisible: Taking abstract concepts like "CPU Cycles" and translating them into "Trees Saved" or "mg of $CO_2$" creates an emotional connection to the code.
- Performance: The entire analysis pipeline, from execution to AI suggestion, runs in under 5 seconds for standard scripts.
What we learned
- Algorithmic Efficiency $\ne$ Energy Efficiency: Sometimes code that runs faster consumes more peak power. We learned to balance execution time against resource intensity.
- The Power of Specialized Models: Using a massive generalist model for everything was slow. Splitting tasks (Fixing vs. Optimizing vs. Explaining) across different specialized LLMs (DeepSeek, CodeLlama) drastically improved our throughput and accuracy.
What's next for Sequoia
- From Execution to Prediction: As our database of Code-to-Carbon metrics grows, we will fully switch to our trained ML model, allowing us to estimate carbon footprints instantly without running the code.
- IDE Integration: A VS Code extension that highlights high-carbon code blocks in red (like a spellchecker) as you type.
- CI/CD Gates: A GitHub Action that fails a Pull Request if the new code increases the project's carbon footprint beyond a set threshold.
Built With
- codecarbon
- codellama
- deepseek
- docker
- fastapi
- framer-motion
- groq
- lucide-react
- mistral
- next.js
- postgresql
- prisma
- python
- recharts
- shadcn-ui
- tailwindcss
- typescript
- xgboost
Log in or sign up for Devpost to join the conversation.