# Database and Storage Integrations in Axion Framework

####

<figure><img src="https://3132812403-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFGYnX4Q9DDFhpyOXKQmr%2Fuploads%2FQtWzs1WdIlmZBK38aSSP%2FIMG_0016.JPG?alt=media&#x26;token=845d9830-01f0-4e92-8a72-ac2358881ad7" alt=""><figcaption></figcaption></figure>

The Axion Framework provides robust integrations with a wide range of databases and storage solutions, allowing agents to manage structured and unstructured data effectively. From lightweight local storage to distributed vector databases, these integrations are tailored to enhance multi-agent systems' performance and scalability.

***

#### Supported Integrations

**1. MongoDB Integration**

MongoDB is a NoSQL database ideal for handling large, semi-structured datasets. It’s best suited for managing agent metadata, task logs, and configurations.

**Key Features:**

* JSON-like document storage.
* High-performance read/write operations.
* Scalability for large-scale deployments.

**Example: Storing Agent Metadata**

```python
from axion.integrations.mongodb_client import MongoDBClient

# Initialize MongoDB client
mongo_client = MongoDBClient(database="AxionDB")
doc_id = mongo_client.insert_document("agents", {"name": "Agent-1", "role": "worker", "status": "active"})
print(f"Agent metadata stored with ID: {doc_id}")

# Query agent metadata
agent_data = mongo_client.query_documents("agents", {"status": "active"})
print(f"Active agents: {agent_data}")

mongo_client.close_connection()
```

***

**2. Neo4j Integration**

Neo4j is a graph database optimized for storing relationships between entities, making it perfect for modeling agent interactions and swarm decision-making.

**Key Features:**

* Graph-based data storage for relationships.
* Cypher query language for advanced graph queries.
* Scalable graph traversal.

**Example: Modeling Agent Relationships**

```python
from axion.integrations.neo4j_client import Neo4jClient

# Connect to Neo4j
neo4j_client = Neo4jClient(uri="bolt://localhost:7687", user="neo4j", password="password")

# Add nodes and relationships
agent1_id = neo4j_client.create_node("Agent", {"name": "Agent-1", "role": "worker"})
agent2_id = neo4j_client.create_node("Agent", {"name": "Agent-2", "role": "manager"})
neo4j_client.create_relationship(agent1_id, agent2_id, "reports_to")

# Query the graph
relationships = neo4j_client.query_relationships("MATCH (a:Agent)-[r:reports_to]->(b:Agent) RETURN a, b")
print(f"Agent relationships: {relationships}")

neo4j_client.close()
```

***

**3. Qdrant Integration**

Qdrant is a vector database for storing and querying high-dimensional embeddings, enabling semantic search and clustering.

**Key Features:**

* Semantic search for AI-driven tasks.
* High-performance vector indexing.
* Flexible storage for embeddings.

**Example: Managing Embeddings for Semantic Search**

```python
from axion.integrations.qdrant_client import QdrantClient

# Initialize Qdrant client
qdrant_client = QdrantClient(collection_name="embeddings")

# Create a collection and add vectors
qdrant_client.create_collection(vector_size=128)
qdrant_client.add_vector(
    vector=[0.12, 0.45, 0.67, 0.89], 
    payload={"name": "Document A", "type": "report"}
)

# Perform semantic search
results = qdrant_client.search(vector=[0.12, 0.45, 0.67, 0.88], top=3)
print(f"Search results: {results}")
```

***

**4. SQLite Integration**

SQLite is a lightweight, serverless database ideal for temporary or local storage needs in resource-constrained environments.

**Key Features:**

* File-based storage for simplicity.
* No server setup required.
* Ideal for small-scale data handling.

**Example: Storing Local Logs**

```python
from axion.integrations.sqlite_client import SQLiteClient

# Initialize SQLite client
sqlite_client = SQLiteClient(database="local_logs.db")

# Create a table
sqlite_client.create_table(
    "task_logs", 
    columns="id INTEGER PRIMARY KEY, task_description TEXT, status TEXT, timestamp DATETIME DEFAULT CURRENT_TIMESTAMP"
)

# Insert a log
sqlite_client.insert_data(
    table="task_logs", 
    columns="task_description, status", 
    values="'Analyze market trends', 'completed'"
)

# Query logs
logs = sqlite_client.query_data("task_logs", "*")
print(f"Task logs: {logs}")

sqlite_client.close()
```

***

#### Choosing the Right Integration

| **Integration** | **Best Use Cases**              | **Strengths**                                   |
| --------------- | ------------------------------- | ----------------------------------------------- |
| **MongoDB**     | Metadata storage, task history  | JSON flexibility, scalable performance          |
| **Neo4j**       | Knowledge graphs, relationships | Optimized for graph traversal and relationships |
| **Qdrant**      | Embedding storage, AI search    | Semantic clustering, high-performance indexing  |
| **SQLite**      | Local storage, small datasets   | Lightweight, simple to set up                   |

***

####
