Official Submission for the Darukaa.Earth AI Biodiversity Challenge
Connecting Climate, Capital, Community, and Code
Transforming complex multi-pillar biological metrics into verifiable, audit-grade natural capital restoration intelligence.
π Explore Live Application β’ π System Architecture β’ π¬ Scientific Coupling Matrix β’ β‘ Quickstart β’ π‘ API Reference
Modern nature-tech and biodiversity credit markets face a critical bottleneck: unsubstantiated, single-variable ecological advice. Traditional AI tools issue isolated suggestions (such as "plant more trees") without modeling non-linear interactions across soil chemistry, aridity indices, habitat fragmentation, and local biomes.
TERRA-MIND solves this challenge through an autonomous Multi-Agent StateGraph powered by LangGraph, ChromaDB, and Google Gemini 2.5. Rather than treating environmental indicators independently, TERRA-MIND enforces a Coupled Multi-Metric Synthesis where Soil Organic Carbon (SOC), moisture regimes, and canopy fragmentation are analyzed simultaneously. Every recommendation is deterministically validated against curated academic literature (FAO, IPCC AR6 WGII, IPBES, ICRAF, IUCN) and outputted as strictly typed Pydantic v2 models with verifiable citations, quantitative metric deltas, and implementation time horizons.
Experience the full multi-agent workflow live in production:
- Production URL: https://terra-mind.onrender.com/
- Hosted on: Render Cloud Container Infrastructure
- Features Available Live: Interactive Folium GIS Coordinate Picker, Multi-Pillar Slider Calibration, Dynamic LangGraph Agent Execution, Metric Delta Projections, Academic Citation Expanders, and Raw Pydantic v2 JSON Inspection.
| Pillar | Engineering Innovation | Evaluation Benefit |
|---|---|---|
| Multi-Metric Coupling | Simultaneous mathematical coupling across |
Eliminates simplistic single-variable advice; models true ecological cascades. |
| Self-Correcting Triage | Autonomous evaluation of data completeness ( |
Prevents hallucinated advice on underspecified queries; asks intelligent follow-up questions. |
| Scientific Hybrid RAG | Offline-capable ChromaDB vector database ingested with peer-reviewed FAO/IPCC/IPBES publications. | Guarantees audit-grade advice backed by published DOIs, authors, and publication years. |
| Deterministic Fallback Engine | Dual-mode architecture pairing Gemini 2.5 synthesis with an offline scientific rule matrix. | Zero-crash guarantee: 100% availability even during network drops or API rate limits. |
| Strict Pydantic v2 Schemas | Output structures validated against strict type constraints with quantitative projection bounds. | Provides production-ready JSON payloads for ESG reporting and natural capital asset tokenization. |
TERRA-MIND operates as a cyclical LangGraph StateGraph, orchestrating four specialized agents and an intelligent conditional router.
flowchart TD
Start([User Query & Parameters]) --> Triage[Agent 1: Intake Triage Node]
Triage --> CompletenessCheck{Completeness Score >= 0.5?}
%% Branch: Incomplete
CompletenessCheck -- No (< 0.5) --> Clarification[Agent: Clarification Node]
Clarification --> ClarificationOut([Return Suggested Clarification Questions])
%% Branch: Complete
CompletenessCheck -- Yes (>= 0.5) --> Spatial[Agent 2: Spatial Reasoning Node]
Spatial --> GeoProfile[Identify Ecoregion & Biome Constraints]
GeoProfile --> Retriever[Agent 3: Scientific Hybrid RAG Retriever]
Retriever --> ChromaDB[(ChromaDB: FAO/IPCC/IPBES Ingested Vector Store)]
ChromaDB --> ContextDocs[Curated Scientific Documents]
ContextDocs --> Synthesis[Agent 4: Multi-Metric Synthesis Auditor Node]
Synthesis --> LLM[Google Gemini 2.5 Flash / Pro Synthesis Engine]
LLM --> PydanticValidation[Pydantic v2 Strict Schema Enforcement]
PydanticValidation --> FinalOutput([Structured Ecological Audit & Actionable Plan])
- Role: Evaluates the input query and metrics across four mandatory environmental pillars: Soil (SOC, pH), Climate (Precipitation, Temp), Land Cover (Cover type, Canopy %, Fragmentation), and Spatial Coordinates.
-
Scoring Mechanism: Assigns a normalized completeness score (
$0.0 - 1.0$ ). If score$< 0.50$ , routing diverts immediately toclarification_node, requesting specific missing ecological parameters rather than generating ungrounded advice.
- Role: Resolves GPS coordinates into regional agro-ecological zones (e.g., Semi-Arid Steppe / Deccan Traps, Tropical Wet Evergreen, Coastal Mangrove Brackish Wetlands).
- Impact: Determines baseline native species palettes, limiting climatic factors, and vulnerability thresholds.
- Role: Executes dense vector similarity search across a persistent ChromaDB collection containing curated FAO, IPCC, IPBES, and ICRAF datasets.
-
Filtering: Automatically maps the spatial ecoregion and degraded land metrics into query vectors to retrieve the top
$k=3$ empirically verified restoration methodologies.
- Role: Fuses retrieved scientific literature, user telemetry, and spatial constraints into an actionable restoration matrix using Gemini 2.5.
-
Pydantic Validation: Validates the model output against
ScientificAnalysisOutput, extracting:- Intervention name and implementation category.
- Priority level (
Immediate,Medium-term,Long-term). - Expected quantitative metric deltas (e.g.,
$+18%$ to$+24%$ SOC,$-35%$ runoff). - Scientific mechanism with formal academic citations (Author, Year, DOI).
- Overall statistical confidence score (
$0.0 - 1.0$ ).
A core differentiator of TERRA-MIND is its Coupled Ecological Matrix Engine (src/engine/multi_metric_matrix.py). In natural ecosystems, interventions do not scale linearly. For example:
+-----------------------------------------------------------------------------------+
| COUPLED MULTI-METRIC MATRIX |
+--------------------------+-----------------------+--------------------------------+
| Environmental Conditions | Coupled Vulnerability | Prescribed Intervention |
+--------------------------+-----------------------+--------------------------------+
| SOC < 0.5% | High aridity limits | High-density multi-strata |
| Rainfall < 500mm | microbial activity; | silvopasture with drought-hardy|
| Fragmentation > 0.5 | wind erosion accelerates| nitrogen-fixing trees |
| | topsoil loss. | (Acacia senegal, P. cineraria) |
+--------------------------+-----------------------+--------------------------------+
| Canopy Cover < 20% | Thermal stress kills | Stepped micro-basin swales, |
| Mean Temp > 28Β°C | soil biota; moisture | continuous mulch blanket, and |
| Monoculture Wheat/Cotton | evaporates instantly. | native vegetative corridors. |
+--------------------------+-----------------------+--------------------------------+
Every recommendation generated by TERRA-MIND explicitly maps its coupled variables, showing how addressing one metric (e.g., planting windbreaks) systematically rehabilitates secondary metrics (microclimate cooling
The local knowledge base (knowledge_base/raw_documents/) contains curated scientific extracts structured with metadata:
- FAO Soil Organic Carbon Technical Manual (2020): Focuses on carbon sequestration dynamics in semi-arid and degraded arable soils (
fao_soil_organic_carbon_2020.json). - IPCC AR6 WGII Land Degradation Chapter (2022): Explores desertification thresholds, compound climatic extremes, and ecosystem vulnerability (
ipcc_ar6_wg2_land_degradation.json). - IPBES Global Assessment Report on Biodiversity (2019): Global biodiversity indices, drivers of terrestrial species decline, and corridors (
ipbes_global_assessment_biodiversity.json). - ICRAF Semi-Arid Agroforestry Handbook (2021): Quantitative yield and carbon balance deltas for leguminous tree integration in drylands (
agroforestry_semi_arid_systems.json). - IUCN Mangrove & Coastal Wetland Handbook (2022): Hydrological restoration and blue carbon metrics for coastal wetlands (
mangrove_coastal_restoration_handbook.json).
- Python 3.11 or 3.12
- Git
git clone https://github.com/12ATHARAV/terra-mind.git
cd terra-mindpython -m venv venv
# On Windows:
.\venv\Scripts\activate
# On Linux / macOS:
source venv/bin/activate
# Install requirements
pip install -r requirements.txtCopy the example environment configuration:
cp .env.example .envOpen .env in any text editor and supply your Google Gemini API Key:
GOOGLE_API_KEY=AIzaSy...your_gemini_api_key...
LLM_MODEL=gemini-2.5-flash
CHROMA_PERSIST_DIR=data/chroma_db# Windows users (to bypass Anaconda DLL conflicts):
.\RUN_APP.bat
# Standard CLI:
streamlit run ui/streamlit_app.pyOpen your browser at http://localhost:8501.
uvicorn src.api.app:app --host 0.0.0.0 --port 8000 --reloadInteractive Swagger UI will be live at http://localhost:8000/docs.
Executes full LangGraph multi-agent reasoning over user-provided environmental metrics.
{
"query_text": "Low organic carbon on semi-arid farm with declining pollinators.",
"soil": {
"organic_carbon_pct": 0.35,
"ph": 7.4
},
"climate": {
"annual_rainfall_mm": 480.0,
"mean_temperature_c": 29.0
},
"land_use": {
"land_cover_type": "Monoculture Cotton",
"canopy_cover_pct": 12.0,
"fragmentation_index": 0.65
},
"spatial": {
"latitude": 19.7515,
"longitude": 75.7139
}
}{
"status": "success",
"summary": "Semi-arid agroecosystem presenting critical organic carbon depletion (<0.4%) coupled with elevated landscape fragmentation.",
"recommendations": [
{
"intervention_name": "Multi-Strata Silvopastoral Agroforestry Corridor",
"priority_level": "Immediate",
"time_horizon": "Short-term (1-3 years)",
"confidence_score": 0.94,
"coupled_variables": ["Soil Organic Carbon", "Canopy Cover", "Precipitation Retention"],
"scientific_mechanism": "Integration of deep-rooting leguminous trees (Acacia senegal, Leucaena leucocephala) with native grasses reduces surface soil temperatures, fixes atmospheric nitrogen, and establishes pollinator stepping-stone corridors.",
"impacted_metrics": [
{
"metric_name": "Soil Organic Carbon (%)",
"baseline_value": "0.35%",
"projected_value": "0.65%",
"delta_percentage": "+85.7%"
},
{
"metric_name": "Canopy Cover (%)",
"baseline_value": "12.0%",
"projected_value": "32.0%",
"delta_percentage": "+166.7%"
}
],
"citations": [
{
"authors_or_organization": "FAO",
"year": 2020,
"source_title": "Global Assessment of Soil Carbon Stocks in Drylands",
"doi_or_url": "https://doi.org/10.4060/ca7414en"
}
]
}
]
}TERRA-MIND includes a 100% passing test suite built with pytest:
pytest tests/ -vtests/test_schemas.py: Asserts Pydantic v2 input and output validations, boundary checking, and constraints.tests/test_retriever.py: Validates ChromaDB dense retrieval, document metadata extraction, and cosine relevance scores.tests/test_engine.py: Confirms multi-metric coupling matrices trigger expected agro-ecological rules based on multi-variable thresholds.tests/test_graph_flow.py: Verifies LangGraph cyclical routing, ensuring incomplete payloads properly branch toclarification_nodewhile complete payloads transition through spatial, retrieval, and synthesis nodes.
The application is fully containerized for cloud native environments:
# Build and run with Docker
docker build -t terra-mind .
docker run -p 7860:7860 -e GOOGLE_API_KEY="your_key" terra-mindOr run via Docker Compose:
GOOGLE_API_KEY="your_key" docker compose up --build- Lead Architect & Developer: Atharv Dhumone
- Target Challenge: Darukaa.Earth AI Biodiversity Challenge
- Organization: Darukaa.Earth