"EcoSphere AI: Why I separated 'logic' from 'AI' when building a carbon footprint assistant" EcoSphere AI separates its carbon footprint calculation logic from its AI layer, using a deterministic TypeScript engine for consistent, auditable emissions numbers and Google Gemini AI only for natural language explanations. The approach ensures reliable tracking and enables thorough unit testing, with deployment on Vercel and Google Cloud Run. 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. 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. 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. 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." 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: https://ecosphere-ai-tan.vercel.app/ https://ecosphere-ai-tan.vercel.app/ 💻 GitHub: https://github.com/ajx1tech/ecosphere-ai https://github.com/ajx1tech/ecosphere-ai