Connecting ArangoDB¶
Odin's reference backend is ArangoDB. This guide covers connecting to it, doing so safely in production, and scoping exploration to a community.
Connecting¶
Install the ArangoDB Python driver with the arango extra. It imports as
arango; connect, select a database, and wrap the connected handle in
ArangoBackend:
from arango import ArangoClient
from odin import OdinEngine
from odin.backends.arango import ArangoBackend, ArangoGraphConfig
client = ArangoClient(hosts="http://localhost:8529")
db = client.db("my_graph", username="root", password="")
graph = ArangoGraphConfig(
node_collection="CaseRecords",
edge_collection="EvidenceLinks",
relation_field="predicate",
entity_type_field="record_type",
)
backend = ArangoBackend(db, graph)
engine = OdinEngine(backend)
The important detail is that OdinEngine takes a backend, while ArangoBackend
uses an already-connected StandardDatabase object and never manages credentials
itself. That keeps secrets in your connection code and out of Odin entirely.
Map your graph data¶
ArangoGraphConfig is required and makes the backend portable across your
existing Arango schemas. Odin reads node IDs from _id, edge endpoints from
_from and _to, and relation labels from the field you configure. It does
not require collection names such as ExtractedEntities or a node label field.
For the configuration above, an edge looks like:
predicate must be a non-empty string on every edge included in training.
record_type is optional, but when configured its non-null node values must be
non-empty strings. Odin adds these as has_type training triples. Optional
retrieval metadata such as weight, created_at, and provenance can remain in
your own fields; it is not required to train or retrieve. To make a numeric
edge field affect structural traversal, set edge_weight_field explicitly.
Without it, Odin assigns every edge a structural weight of 1.0 and does not
assume a field named weight.
Set edge_timestamp_field, edge_valid_from_field, edge_valid_to_field,
edge_status_field, or edge_provenance_fields only when your graph supplies
those signals. Omitted fields disable the corresponding signal rather than
falling back to a named Arango property. The standalone Arango analytics and
content helpers likewise require their collection and field mappings and return
complete source documents; normal engine use needs only the graph mapping above.
Optional status and provenance filters¶
edge_status_field exposes metadata. Set allowed_edge_statuses=("active",) to
filter edges by mapped status values. provenance_target_collections=("Reports",)
restricts mapped provenance edges to those source collections. A configured
provenance collection must exist; missing collections raise
BackendConfigurationError.
Production connections¶
Outside local development, never disable authentication. Use a dedicated, least-privilege user and pull secrets from the environment rather than the source:
import os
from arango import ArangoClient
client = ArangoClient(hosts=os.environ["ARANGO_HOSTS"]) # e.g. https://db.internal:8529
db = client.db(
os.environ["ARANGO_DB"],
username=os.environ["ARANGO_USER"],
password=os.environ["ARANGO_PASSWORD"],
)
Secrets
Do not hard-code passwords in source or notebooks. Load them from environment variables or a secrets manager. Odin never logs your credentials.
A local database with Docker¶
For development, Docker gives you an instance in one command:
ARANGO_NO_AUTH is fine locally but never in production. For an authenticated local instance, set a root password instead:
Scoping to a community¶
A community restricts exploration to a named subset of the graph. Reach for community_mode="mapping" when you have partitioned a large multi-tenant graph and want scoped retrieval. Training remains global for the Arango backend:
# Global exploration (default); `graph` is the explicit mapping above.
backend = ArangoBackend(db, graph)
engine = OdinEngine(backend, community_id="global", community_mode="none")
# Scoped to one partition. Add all three membership fields to `graph`.
backend = ArangoBackend(db, graph)
engine = OdinEngine(backend, community_id="medicare_claims", community_mode="mapping")
Mapping mode requires membership_collection, membership_entity_field, and
membership_community_field together. Without that complete mapping Odin
raises BackendConfigurationError; it never guesses a membership schema.
Property mode instead requires community_property_field; Odin does not assume
a node field named community_id.
Bridge mapping requires bridge_collection, bridge_entity_field,
bridge_strength_field, and bridge_community_field. Store full document IDs
in the mapped entity field. Affinity mapping requires affinity_collection,
affinity_from_field, affinity_to_field, and affinity_score_field.
Each signal can be configured independently. Unconfigured signals issue no queries.
Algorithm filters are opt-in: set membership_algorithm_field,
bridge_algorithm_field, or affinity_algorithm_field with community_algorithm.
Membership lookups use the same filter in scoped and global access. Configured
query failures raise BackendIOError and are not cached as absent data.
Membership metadata remains available in community_mode="none", allowing
cross-community affinity scoring during global exploration. Scoped traversal
continues to respect its boundary.
Verifying it worked¶
get_status() confirms the connection and which intelligence mode you are in:
print(engine.get_status())
# {'community_id': 'global', 'npll_loaded': True,
# 'intelligence_mode': 'NPLL', 'cache_size': 5000}
An intelligence_mode of Constant means NPLL was explicitly disabled with
auto_train=False. Requested training failures raise. See Model Lifecycle.
Other backends¶
ArangoBackend is the only complete backend today. A JanusGraph accessor supports retrieval only, and Neo4j is planned. To build your own, see Adapters and Backend contracts.
Next¶
With a connection in place, run Your First Retrieval, or let an agent discover the graph's structure with Schema Introspection.