AgroLD as VersaAgro's KG Source of Truth
AgroLD v2 is an open-source, SPARQL-queryable RDF knowledge graph developed by INRAE and Montpellier SupAgro that federates 8 major agronomic ontologies into a single queryable endpoint. VersaAgro uses AgroLD as the external ontological source of truth for grounding NLP queries, enriching alert recommendations, and providing verifiable IRI-attributed citations to end users.
Open-Source KG Source
AgroLD integrates Gene Ontology, Trait Ontology, Plant Ontology, Crop Ontology, NCBI Taxonomy, Gramene, OBO Relations, and AGROVOC — providing a single SPARQL endpoint across 8 ontologies and >100K agronomic relationships.
CORS-Constrained Endpoint
The AgroLD SPARQL endpoint (https://v2.agrold.org/sparql) does not include Access-Control-Allow-Origin headers, meaning browsers block direct fetch() calls. A server-side proxy is required for production use.
Two-Layer Architecture
The prototype uses a curated static layer — 36 entities with canonical IRIs in data/agrold-entities.json — for zero-latency, CORS-safe demo. Production routes through a server-side SPARQL proxy for live federated queries.
NLP → SPARQL Pipeline
User plain-language queries are classified by intent, entities are resolved against AgroLD IRIs, and SPARQL templates are hydrated and executed server-side. Results are merged with internal VersaAgro triple store data and returned as cited responses.
Canonical IRI Attribution
Every entity in the VersaAgro system retains its canonical AgroLD IRI (e.g., agrold:Aphis_glycines). This preserves full provenance linkage from a user-facing response back to the source ontology node — enabling academic-grade auditability.
Federated Query Design
Production SPARQL queries federate across: (1) AgroLD external endpoint for ontology data, (2) VersaAgro's internal triple store for sensor and field triples, and (3) open CORS-enabled APIs (Open-Meteo, GBIF) for real-time enrichment — all joined server-side.
The CORS Problem Explained
Browser Same-Origin Policy (SOP) is a W3C security mechanism that prevents JavaScript running on versaagro.com from making HTTP requests to v2.agrold.org unless the server at v2.agrold.org explicitly opts in via CORS response headers.
fetch('https://v2.agrold.org/sparql?query=...'), the browser first makes a preflight OPTIONS request. AgroLD's server returns the query result but does not include Access-Control-Allow-Origin: * in the response headers. The browser intercepts the response and throws: "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource." The JavaScript fetch() rejects. No data is returned to the page.
const res = await fetch(
'https://v2.agrold.org/sparql?' +
'query=SELECT...'
);
// NetworkError: Cross-Origin Request Blocked
// Headers received: none (CORS headers missing)
// Result: 0 bytes returned to page
const res = await fetch(
'/api/kg/query', {
method: 'POST',
body: JSON.stringify({ nlp, field_id })
}
);
// Server proxies to AgroLD (server-to-server)
// No CORS issue — server is not a browser
CORS-Safe APIs VersaAgro Can Use Directly From the Browser
Full Architecture Flow
The two-layer architecture separates the static prototype layer (used in this demo) from the production SPARQL proxy layer. Both layers preserve canonical AgroLD IRIs in all responses.
/api/kg/query on the same VersaAgro domain.Code Examples
Reference implementations for both the static layer (current prototype) and the production server-side SPARQL proxy pattern.
Static Layer Implementation — Fetches data/agrold-entities.json and performs client-side fuzzy matching. Canonical AgroLD IRIs are preserved in every result, ensuring production-ready provenance linkage from day one. This is the current implementation in knowledge-graph.html.
Browser Client Call — In production, the browser calls VersaAgro's own CORS-enabled API rather than the AgroLD endpoint directly. The server handles SPARQL execution and returns merged, cited results. This pattern avoids exposing any API keys or backend credentials to the browser.
Server-Side SPARQL Proxy (Node.js) — The proxy runs on the VersaAgro backend. It receives the translated SPARQL query, calls the AgroLD endpoint server-to-server (no CORS restriction), and returns results to the client. Express.js with node-fetch or Axios handles the outbound call.
NLP → SPARQL Translator — The translator maps intent-classified query components to SPARQL template slots, resolves entity names against AgroLD entity IRIs from the curated dataset, and hydrates a SPARQL 1.1 query. The resolved IRI ensures the response cites the canonical ontology source.
Federated SPARQL JOIN — A single SPARQL 1.1 federated query can join VersaAgro's internal triple store with the AgroLD endpoint in one query using the SERVICE keyword. This is the most elegant production pattern but requires VersaAgro's own SPARQL endpoint to support SERVICE federation. The server-side proxy ensures no browser CORS issues arise.
SPARQL Query Templates by Use Case
Production-ready SPARQL query templates hydrated from AgroLD entity IRIs. All queries are executed server-side by the proxy layer.
Ontologies Integrated via AgroLD v2
AgroLD federates 8 authoritative open ontologies into a single SPARQL endpoint. VersaAgro's curated entity dataset preserves the source ontology reference for each entity.
Curated Entity Catalogue
The data/agrold-entities.json static snapshot contains 36 entities across 8 types. All entities are searchable via the Knowledge Graph Explorer. Each entry retains its canonical AgroLD IRI, ontology source, SPARQL query example, and VersaAgro signal description.
| Label | Scientific Name | Ontology | Canonical IRI | VersaAgro Signal |
|---|---|---|---|---|
| Soybean Aphid | Aphis glycines Matsumura | NCBI Taxonomy + TO | agrold:Aphis_glycines | NDVI drop >0.05 + temp >21°C |
| Fall Armyworm | Spodoptera frugiperda | NCBI Taxonomy + TO | agrold:Spodoptera_frugiperda | Irregular NDVI depletion + warm >28°C + wind trajectory |
| Coffee Berry Borer | Hypothenemus hampei | NCBI Taxonomy + CO | agrold:Hypothenemus_hampei | Temp 20–30°C for 15+ days + >75% humidity |
| Label | Scientific Name | Ontology | Canonical IRI | Key Signal |
|---|---|---|---|---|
| Fusarium Head Blight | Fusarium graminearum | NCBI Taxonomy + GO | agrold:Fusarium_graminearum | Humidity >85% × 3 days at anthesis |
| Stripe Rust | Puccinia striiformis f. sp. tritici | NCBI Taxonomy + TO | agrold:Puccinia_striiformis | NDVI 0.45–0.60 canopy yellowing + cool/humid |
| Coffee Leaf Rust | Hemileia vastatrix | NCBI Taxonomy + TO | agrold:Hemileia_vastatrix | LAI decline >15% + EVI drop + wet season onset |
| Label | Scientific Name | Ontology | Canonical IRI |
|---|---|---|---|
| Common Wheat | Triticum aestivum L. | NCBI + CO + TO | agrold:TriticumAestivum |
| Soybean | Glycine max (L.) Merr. | NCBI + CO + TO | agrold:GlycineMax |
| Blue Agave | Agave tequilana Weber | NCBI + AGROVOC | agrold:AgaveTequilana |
| Arabica Coffee | Coffea arabica L. | NCBI + CO + GO | agrold:CoffeaArabica |
data/agrold-entities.json and searchable via the interactive Knowledge Graph Explorer.
Static Layer → Production SPARQL Proxy
The architecture is designed for a clear two-phase implementation: a demo-ready static layer that already shows the full data model, evolving to live SPARQL federation in production.
- 36 curated AgroLD entities in
data/agrold-entities.json - Canonical IRIs preserved in every entity
- Client-side fuzzy search in
knowledge-graph.html - Entity detail panel with SPARQL examples + attribution
- KG Source chips on all 3 alert cards in
alerts.html - AgroLD attribution on 6 glossary term cards
- Zero CORS issues — fully CORS-safe implementation
- Node.js/Python SPARQL proxy at
/api/kg/query - NLP → SPARQL translator (LLM-backed intent classification)
- VersaAgro internal SPARQL triple store (Apache Jena / Blazegraph)
- Federated JOIN with AgroLD live endpoint (SERVICE keyword)
- Real-time alert enrichment with AgroLD trait associations
- Caching layer (Redis) for frequent AgroLD queries — <50ms
- GBIF + Open-Meteo real-time enrichment via direct browser calls
