# Database and Storage Integrations

**Database and Storage Integrations**\
SynaptiQ Systems provides seamless integration with various databases and storage solutions, enabling flexible and efficient data management for diverse use cases. These integrations support both structured and unstructured data, empowering developers to handle everything from knowledge graphs to embeddings and decentralized storage.

#### Supported Integrations

**1. MongoDB**

MongoDB is a NoSQL database designed for handling large volumes of unstructured or semi-structured data. It is ideal for applications requiring flexibility and scalability.

**Features:**

* JSON-like document storage.
* High performance for read/write operations.
* Scalable and distributed architecture.

**Example Use Case:** Store agent metadata, task history, or logs.

**Code Example:**

```python
pythonCopy codefrom src.integrations.mongodb.mongodb_client import MongoDBClient

mongo_client = MongoDBClient()
doc_id = mongo_client.insert_document("agents", {"name": "Agent-1", "role": "worker"})
print(f"Document inserted with ID: {doc_id}")
mongo_client.close_connection()
```

**2. Neo4j**

Neo4j is a high-performance graph database used to store and query relationships between entities. It enhances SynaptiQ Systems’ knowledge graph capabilities by providing powerful graph traversal and querying.

**Features:**

* Native graph storage.
* Advanced querying with Cypher.
* Ideal for agent collaboration and relationship modeling.

**Example Use Case:** Model agent interactions, swarm behavior, or decision dependencies.

**Code Example:**

```python
pythonCopy codefrom src.integrations.neo4j.neo4j_client import Neo4jClient

neo4j_client = Neo4jClient(password="your_password")
node_id = neo4j_client.create_node("Agent", {"name": "Agent-1", "role": "worker"})
print(f"Node created with ID: {node_id}")
neo4j_client.close()
```

**3. Qdrant**

Qdrant is a vector database designed for managing embeddings, enabling similarity searches and semantic clustering. It is essential for applications that require context-aware search and advanced AI-driven insights.

**Features:**

* High-performance vector search.
* Supports semantic search and clustering.
* Flexible for AI-driven tasks.

**Example Use Case:** Store embeddings from LLMs or multi-modal agents for similarity searches.

**Code Example:**

```python
pythonCopy codefrom src.integrations.qdrant.qdrant_client import QdrantClientWrapper

qdrant = QdrantClientWrapper(collection_name="agents")
qdrant.create_collection(vector_size=3)
qdrant.add_vector([0.1, 0.2, 0.3], {"name": "Agent-1", "role": "worker"})
results = qdrant.search([0.1, 0.2, 0.3])
print(f"Search results: {results}")
```

**4. SQLite**

SQLite is a lightweight, file-based relational database. It is perfect for local storage or small-scale applications where simplicity and portability are key.

**Features:**

* Simple and lightweight.
* No need for a server setup.
* File-based storage.

**Example Use Case:** Store task logs, temporary data, or local configurations.

**Code Example:**

```python
pythonCopy codefrom src.integrations.sqlite.sqlite_client import SQLiteClient

sqlite = SQLiteClient()
sqlite.create_table("agents", "id INTEGER PRIMARY KEY, name TEXT, role TEXT")
sqlite.insert_data("agents", "name, role", "'Agent-1', 'worker'")
data = sqlite.query_data("agents", "*")
print(f"Query results: {data}")
sqlite.close()
```

#### How to Use Integrations

**Configuration:**

* For MongoDB, Neo4j, and Qdrant, ensure the respective services are running and properly configured.
* Set environment variables for connection details as needed (e.g., MongoDB URI, Neo4j credentials).

**Add to Your Project:**

* Import the respective client from `src.integrations.<module>`.
* Use the client to interact with the database as per your requirements.

**Extend or Customize:**

* Each integration is modular, allowing you to extend or replace the functionality based on your needs.

#### When to Use Each Integration

| **Integration** | **Best Use Cases**                              | **Strengths**                                  |
| --------------- | ----------------------------------------------- | ---------------------------------------------- |
| **MongoDB**     | Storing large, flexible datasets like logs.     | High scalability and JSON-like storage.        |
| **Neo4j**       | Building and querying knowledge graphs.         | Optimized for relationships and graph queries. |
| **Qdrant**      | Embedding storage, semantic search, clustering. | High-performance vector search.                |
| **SQLite**      | Lightweight, local task storage.                | Simple, portable, and serverless.              |

#### Future Enhancements

* Add integration testing for all modules.
* Extend Qdrant integration for multi-agent semantic clustering.
* Provide full support for cross-database queries (e.g., combining MongoDB and Neo4j data).
