The Trap Most Carbon Apps Fall Into
When you say "build a carbon footprint app," the obvious move is: collect some inputs,
ask an LLM "how much CO2 does this produce," and display whatever it says.
That's a trap. LLMs are not reliable calculators. Ask the same model the same emissions
question twice and you'll get two different numbers. For a "track your carbon footprint"
tool, that's disqualifying — the entire premise of tracking requires consistent,
auditable numbers.
The Architecture Decision
EcoSphere AI splits the problem in two:
1. A deterministic carbon engine — pure TypeScript functions using documented
emission factors (diet type, transport mode, energy use, shopping habits). Same input,
same output, every time. Fully unit tested. This is what computes your actual footprint,
your Carbon DNA archetype, your Risk Score, and your ranked recommendations.
2. Google Gemini AI — used only for what LLMs are actually good at: natural language
explanation, contextual conversation, and pattern narration. The AI coach receives the
engine's real computed numbers as context and explains them — it never invents the
math itself.
This split mattered more than any single feature. It's the difference between a project
that looks AI-powered and one that is genuinely intelligent.
What I Built
- Carbon DNA: A personality-style profile ("Urban Explorer", "Frequent Flyer") derived from rule-based logic on your habits
- Carbon Twin: An optimized version of you, with savings calculated from the same emission factors — not arbitrary
- AI Sustainability Coach: Ask anything, get answers grounded in your actual data
- What-If Simulator: Drag sliders, watch projected 2050 footprint update live
- Carbon Risk Score: 0-100, like a credit score for environmental impact
- Gamification: Weekly missions auto-generated to target your highest-impact category
Cloud Services Used
Gemini API powers the conversational coach and weekly AI-generated summaries — always
fed real context, never guessing.
Firebase Firestore stores monthly profile snapshots, enabling a deterministic
habit-change detector that flags "+17% this month, likely from increased food delivery"
— again, computed, not hallucinated.
Deployment: Initially deployed on Vercel for rapid iteration, with a Dockerized Google Cloud Run architecture staging for final production.
Testing Strategy
Because the carbon engine is pure functions, it was trivial to write 20+ meaningful
unit tests — ordering checks (vegan footprint < high-meat footprint), boundary checks
(risk score clamped 0-100), and invariant checks (Carbon Twin always projects lower
than current). This is testing that actually validates logic, not just "does it render."
The Antigravity Build Process
Six structured master prompts: scaffold + security → deterministic engine → Firebase/AI
layer → core UI → coach/gamification UI → tests/Docker/README. Each prompt built on
the last, intent-driven the whole way.
Live Demo & Code
🔗 Live: https://ecosphere-ai-tan.vercel.app/
💻 GitHub: https://github.com/ajx1tech/ecosphere-ai
Top comments (0)