Principle:ANative Lab EvoAgentX Storage Abstraction
| Knowledge Sources | |
|---|---|
| Domains | Storage, Architecture |
| Last Updated | 2026-10-21 00:00 GMT |
Overview
Pattern for abstracting multiple storage backends (database, vector, graph) behind a unified handler interface with factory-based initialization.
Description
Storage Abstraction decouples the storage backend choice from the application logic. A single StorageHandler manages three backend types: a database (SQLite for metadata and relational data), a vector store (FAISS for embedding similarity search), and an optional graph store (Neo4j for knowledge graphs). Each backend is created via a factory class based on configuration. The handler provides uniform `load()`, `save()`, and `parse_result()` methods regardless of the underlying technology.
Usage
Use this principle when your application needs persistent storage for agents, workflows, RAG indices, or memory. The `StorageHandler` with `StoreConfig` is the standard implementation:
- RAG: Provides DB (metadata), vector (embeddings), and graph (entities) backends to `RAGEngine`
- Agent persistence: Used by `AgentManager` for loading/saving agents
- Pluggable backends: Swap SQLite for PostgreSQL, FAISS for Qdrant via config changes
Theoretical Basis
The abstraction uses factory pattern for backend creation:
# Abstract pattern (not real implementation)
class StorageHandler:
def __init__(self, config):
self.db = DBFactory.create(config.db_name, config.dbConfig)
self.vector = VectorFactory.create(config.vector_name, config.vectorConfig)
self.graph = GraphFactory.create(config.graph_name, config.graphConfig)
def save(self, data, table):
self.db.insert(table, data)
def load(self, table):
return self.db.query(table)
Key properties:
- Factory pattern: Backend selection by config string (e.g., "sqlite", "faiss", "neo4j")
- Composable: DB is required; vector and graph are optional
- Unified interface: Same load/save API regardless of backend
- Config-driven: All backend settings in StoreConfig