TerraGrid is a 3-agent autonomous logistics engine that transforms reactive fleet management into proactive, AI-driven rerouting. Powered by the Gemini API and live NASA satellite data, it detects climate anomalies and reroutes commercial fleets in real-time to save cargo, time, and carbon.
It's Tuesday at 2:30 AM. A Category 3 storm just formed over the Nevada corridor. You're responsible for 6 commercial fleets carrying $30 million in cargo across the US West Coast. Your operations center is flooded with weather alerts, your drivers are calling in, and your dispatch software is still showing yesterday's routes.
This scenario inspired TerraGrid—an autonomous engine designed to act before the crisis hits, providing a "Nano Melon" level of precision and organic efficiency to global supply chains.
TerraGrid utilizes a sequential 3-Agent Chain-of-Thought pipeline:
- 🛰️ Ecological Watcher: Ingests real-time climate anomaly data (NASA FIRMS) and GPS telemetry, flagging severe weather threats or wildfires the moment they appear.
- 🧠 Causal Reasoner: Cross-references anomalies against historical route data and carbon models to calculate the optimal path bypass.
- ⚔️ Adversarial Verifier: Red-teams every reroute decision to eliminate hallucinations and validate logistics feasibility before broadcasting to assets.
Key Metrics:
- Carbon Intelligence: Automatically calculates CO2 offsets for every reroute (e.g., 127kg saved per incident).
- Explainable AI: Every decision is accompanied by a live-streaming Chain-of-Thought console.
- Frontend: Next.js (App Router) + Tailwind CSS + Leaflet.js
- Backend: Python + FastAPI (Multi-Agent Orchestration)
- AI Engine: Google Gemini API (Agentic Reasoning Pipeline)
- Database: Neon Postgres (Real-time telemetry storage)
- Data Sources: NASA FIRMS API (Satellite thermal hotspots & wildfire tracking)
- Multi-Agent Logic Synchronization: Coordinating a three-agent sequential pipeline—Watcher, Reasoner, and Verifier—required complex state management. Ensuring that the "Adversarial Verifier" could effectively critique and roll back the "Causal Reasoner's" logic without causing infinite loops was a major orchestration hurdle.
- Structured JSON from LLMs: Getting Gemini to reliably return deterministic route coordinates + carbon offset JSON required rigorous prompt engineering and output validation schemas.
- Real-time Geospatial Sync: Keeping the map, telemetry feed, and AI console in sync during a live anomaly event required building a custom event-bus to manage state across the frontend.
- Live Satellite Integration: The threats on the map aren't simulated; they are pulled from real NASA thermal hotspot data.
- Autonomous Sustainability: We made carbon footprint reduction a hard constraint for the AI, not just an afterthought.
- Zero-Hallucination Pipeline: By using an adversarial agent, we ensure the reroutes stay on actual roads rather than "hallucinating" paths through mountains.
- MarineTraffic API: Expanding into sea-freight tracking for global shipping lanes.
- Mobile Driver App: Pushing real-time reroute waypoints directly to driver dashboards.
- Carbon Credit Market: Automatically converting CO2 savings into tradeable offset credits.
git clone https://github.com/your-username/terragrid.git
cd terragrid/frontend
npm install
npm run devcd ../backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txtCreate a .env in the backend folder:
GEMINI_API_KEY=your_key
NASA_FIRMS_API_KEY=your_key
DATABASE_URL=your_neon_postgres_urlpython -m scripts.seed_db
uvicorn main:app --reload --port 8000