Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Ai Surreal Db Store Laravel Package

symfony/ai-surreal-db-store

SurrealDB vector store integration for Symfony AI Store, enabling similarity search over embeddings using SurrealQL vector functions and MTREE/HNSW indexes.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • AI/ML Infrastructure Modernization: Enables Laravel applications to adopt SurrealDB as a vector store backend, reducing reliance on proprietary solutions (e.g., Pinecone, Weaviate) or PostgreSQL extensions (pgvector). Aligns with trends toward unified, multi-model databases for AI workloads, simplifying infrastructure.
  • Cost Optimization: SurrealDB’s open-source model and potential for self-hosting can reduce cloud costs compared to managed vector services, especially for high-volume or long-term projects. As of v0.14.0, stores expose count capabilities, which makes it practical to meter usage (documents/embeddings stored per tenant, per feature, per environment) — the missing piece for cost attribution and quota enforcement in multi-tenant AI products.
  • Roadmap Alignment: Supports Laravel’s AI/ML feature expansion by providing a native bridge to SurrealDB, avoiding custom integrations. Justifies investment if the team prioritizes Symfony AI compatibility or is evaluating SurrealDB for hybrid workloads (e.g., relational + vector data).
  • Build vs. Buy: Buy—avoids reinventing vector store integration for SurrealDB, leveraging Symfony’s ecosystem. The v0.14.0 VectorDocumentInterface strengthens this case: documents are now modeled against a shared contract rather than a SurrealDB-specific shape, so the cost of switching or adding a second backend later drops materially.
  • Exit-Risk / Portability Insurance (new): VectorDocumentInterface gives us a backend-agnostic document model. Combined with count(), we can run the same feature code against SurrealDB and a comparison backend (pgvector) and measure corpus size + retrieval quality side by side — de-risking the “nascent vector search” concern with data rather than opinion.
  • Use Cases:
    • Semantic Search: Power search functionality (e.g., e-commerce product discovery, document retrieval) with SurrealDB’s native vector search.
    • Recommendation Systems: Real-time similarity matching for personalized content (e.g., news feeds, music suggestions).
    • Generative AI Pipelines: Enable Retrieval-Augmented Generation (RAG) by storing embeddings in SurrealDB and fetching context dynamically.
    • Multi-Tenant AI Apps: SurrealDB’s namespace/scope isolation simplifies multi-tenant vector storage (e.g., SaaS platforms with customer-specific embeddings). count() now supports per-tenant quota enforcement and usage-based billing surfaces.
    • Hybrid Data Models: Combine vector search with graph/document queries in a single database (e.g., fraud detection with both relational and vector data).
    • Embedding Governance / Ops Dashboards (new): Count documents per index to detect stale or orphaned embeddings, track index growth, and alert on ingestion regressions.

When to Consider This Package

Adopt If:

  • Your Laravel application uses or plans to use Symfony AI for vector operations (e.g., embeddings, similarity search).
  • You’re evaluating SurrealDB as a unified database for both relational and vector data, avoiding polyglot persistence.
  • Your use case requires filtering on vectors (e.g., WHERE metadata.field = 'X' AND vector_similarity > 0.8), which is less common in early-stage vector stores.
  • You need corpus/inventory visibility as a product requirement: usage dashboards, per-tenant quotas, billing metering, or ingestion QA. The v0.14.0 count capability covers this without bespoke queries.
  • You want a documented migration path off SurrealDB or toward a second backend. VectorDocumentInterface (v0.14.0) standardizes how embeddings are represented, lowering the cost of a future swap.
  • You prioritize open-source, self-hosted solutions over managed services (e.g., Pinecone, Milvus) to reduce vendor lock-in.
  • Your team has SurrealDB expertise or is willing to invest in learning its query language (SurrealQL) and schema design.
  • You need real-time sync for vector data (SurrealDB’s ACID compliance and WebSocket support may be advantageous).
  • Your workload involves moderate-scale vector operations (e.g., <10K QPS). For higher scales, benchmark SurrealDB against dedicated vector databases.

Look Elsewhere If:

  • You’re not using Symfony AI: This package is tightly coupled to Symfony’s AI ecosystem. Laravel teams would need to either:
    • Use Symfony AI as a dependency (adding complexity).
    • Build a custom wrapper (increasing maintenance overhead).
  • Your primary requirement is high-scale vector search (e.g., >50K QPS). SurrealDB’s vector search is nascent; dedicated solutions like Weaviate, Pinecone, or pgvector may offer better performance. Note: count() is a convenience capability, not a performance or index-maturity improvement — don’t treat v0.14.0 as closing the scale gap.
  • You lack SurrealDB expertise: Migration, schema design, and query optimization may require significant effort.
  • Your application demands advanced vector indexing (e.g., dynamic dimension handling, approximate nearest neighbor with fine-tuned parameters) not yet fully supported in this bridge.
  • You’re constrained by budget for SurrealDB hosting (self-managed or cloud). Compare costs with alternatives like PostgreSQL + pgvector or Redis + Redisearch.
  • Your team prefers Laravel-native solutions (e.g., Scout for Elasticsearch, custom pgvector integrations) to avoid Symfony dependencies.
  • You depend on stable, non-0.x APIs for critical paths. At v0.14.0 the store document model is still evolving (new interfaces landing in minor releases); pin versions and expect occasional refactors.

How to Pitch It (Stakeholders)

For Executives:

*"This package enables us to leverage SurrealDB—a high-performance, open-source database—as a vector store for our AI features, directly within our Laravel stack. By integrating Symfony’s AI tools with SurrealDB, we can:

  • Reduce cloud costs by avoiding proprietary vector databases (e.g., Pinecone) and self-hosting SurrealDB.
  • Unify our data model by storing both relational and vector data in a single database, simplifying infrastructure.
  • Measure and control AI spend: the latest release (v0.14.0) adds usage counting for vector stores, so we can attribute embedding volumes to customers and features, and enforce quotas.
  • Limit lock-in: v0.14.0 also standardizes how vector documents are represented, so our retrieval code isn’t welded to one vendor — we retain a credible exit to pgvector or another backend. For example, if we’re building a semantic search feature for our product catalog, this lets us store embeddings in SurrealDB and retrieve relevant results in real time—without sacrificing control or incurring high licensing fees. Recommend piloting this for a high-impact AI feature to validate performance and cost savings."

For Engineering:

*"The symfony/ai-surreal-db-store package bridges SurrealDB into Symfony’s AI ecosystem, giving us:

  • Seamless vector store integration for Laravel apps using Symfony AI (e.g., for embeddings, RAG pipelines).
  • Filtering support for vectors (e.g., WHERE metadata = 'X'), which is rare in early-stage vector databases.
  • count support on stores (v0.14.0): query corpus size per index without pulling records — useful for pagination, tenant quotas, and ingestion sanity checks.
  • VectorDocumentInterface (v0.14.0): a shared document contract, so retrieval code isn’t coupled to SurrealDB-specific record shapes. This makes A/B benchmarks against pgvector realistic and gives us a clean seam for a second backend.
  • Open-source agility: No proprietary dependencies, and we can contribute back to the Symfony community. Tradeoffs:
  • Symfony dependency: We’d need to add symfony/ai to our stack (or build a Laravel wrapper).
  • SurrealDB maturity: Vector search is less battle-tested than alternatives like pgvector or Weaviate—benchmark performance for your workload. v0.14.0 is a developer-ergonomics release, not a performance one.
  • Pre-1.0 API churn: new interfaces are still arriving in minor versions; pin the version and budget a small refactor window per upgrade.
  • Schema design: SurrealDB’s flexible model requires careful planning for vector queries (e.g., index types, distance metrics). Recommendation:
  1. Pilot for a non-critical AI feature (e.g., semantic search) to validate performance and integration effort.
  2. Compare with alternatives (e.g., PostgreSQL + pgvector) using real-world queries — implement against VectorDocumentInterface so the comparison is apples-to-apples.
  3. Plan for a fallback (e.g., Redis cache layer) if SurrealDB becomes a bottleneck. Example integration:
// Configure in Laravel's service container
$this->app->bind(\Symfony\AI\Store\VectorStoreInterface::class, function ($app) {
    $client = new \Surreal\Client($app['config']['surrealdb.dsn']);
    return new \Symfony\AI\Store\SurrealDbStore($client, 'hnsw_index');
});

// Use in a Laravel service
$store = app(VectorStoreInterface::class);
$results = $store->find($queryEmbedding, limit: 5);

// v0.14.0: inventory / quota checks without fetching records
$indexed = $store->count();

Example integration:

// Configure in Laravel's service container
$this->app->bind(\Symfony\AI\Store\VectorStoreInterface::class, function ($app) {
    $client = new \Surreal\Client($app['config']['surrealdb.dsn']);
    return new \Symfony\AI\Store\SurrealDbStore($client, 'hnsw_index');
});

// Use in a Laravel service
$store = app(VectorStoreInterface::class);
$results = $store->find($queryEmbedding, limit: 5);
```"

---

### **For Data Scientists/ML Engineers:**
*"This package lets us **store and retrieve embeddings in SurrealDB**, enabling:
- **Real-time similarity search** for AI applications (e.g., recommendation systems, chatbots).
- **Hybrid data models**: Combine vector search with SurrealDB’s graph/document capabilities (e.g., link embeddings to user profiles).
- **Cost-effective scaling**: SurrealDB’s open-source model reduces reliance on expensive vector services.
- **Cheap corpus bookkeeping (v0.14.0)**: `count` lets us verify that an ingestion job wrote what we expect (e.g., 1M source docs → 1M embeddings) before running evals, and to size experiments without scanning the store.
- **Portable documents (v0.14.0)**: `VectorDocumentInterface` standardizes vectors + metadata, so the same eval harness can run against SurrealDB and pgvector for a fair latency/recall comparison.
*Considerations*:
- **Query flexibility**: SurrealQL supports filtering vectors by metadata (e.g., `SELECT * WHERE vector_similarity(embedding, ?) > 0.8 AND category = 'tech'`).
- **Performance**: Benchmark against your current solution (e.g., pgvector) for latency and throughput. Counting documents is not an index-quality signal — keep separate recall/latency benchmarks.
- **Schema design**: Work with the team to define how vectors and metadata will be structured in SurrealDB tables/records.
*Next steps*:
- Collaborate with engineers to **design the SurrealDB schema** for your embeddings.
- Test **vector indexing strategies** (e.g., HNSW vs. MTREE) for your use case.
- Validate **embedding update patterns** (e.g., batch inserts, real-time sync), using `count()` as an ingestion assertion."*

---
### **For Product Managers:**
*"This package supports our **AI-driven product roadmap** by enabling cost-effective, scalable vector search without vendor lock-in. Key benefits:
- **Unified Data Model**: Store vectors alongside relational data in SurrealDB, reducing infrastructure complexity.
- **Cost Savings**: Avoid recurring fees for managed vector databases (e.g., Pinecone) with self-hosted SurrealDB.
- **Metering & Quotas (v0.14.0)**: With store `count` support we can show customers how much content is indexed, enforce plan limits, and report AI usage — a prerequisite for pricing AI features.
- **Lower Switching Cost (v0.14.0)**: The new vector document interface means an eventual move to pgvector or another backend is a contained engineering task, not a rewrite.
- **Flexibility**: SurrealDB’s multi-model capabilities allow us to experiment with **graph + vector hybrids** (e.g., knowledge graphs for RAG).
*Recommendations*:
1. **Prioritize for high-impact AI features** (e.g., semantic search, recommendations) where cost and flexibility are critical.
2. **Pilot with a non-critical feature** to validate performance and integration effort.
3. **Compare with alternatives** (e.g., pgvector) to ensure SurrealDB meets our scale and latency requirements.
4. **Align with engineering** to assess tradeoffs (e.g., Symfony dependency, schema design effort).
5. **Scope metering early**: if AI features will be priced or quota-limited, design the `count`-based usage reporting in the first iteration rather than retrofitting it.
*Example use case*: If we’re building a **personalized content recommendation system**, this package lets us store user embeddings in SurrealDB and retrieve similar items in real time—while keeping costs low and infrastructure simple."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
teamzac/geocoder
ideatica/config-writer
keaton-php/pipe-dream
jacksonwebservices/laravel-user-suite
maksimru/conditional-laravel-debugbar
gismatul/nova-support-chat
gismatul/laravel-support-chat
networkrailbusinesssystems/oracle-api
alphabalex/messaging-made-easy
rawphp/warp
shootkiran/merobug
narakode/fineauth
numencode/wn-syncops-plugin
ibnnajjaar/mib-global-pay
ably/pubsub-server
mstfkhazaal/defender
mfonte/base62x
karnoweb/metapilot
tobya/bcsapiwrapper
swalker2/cpanel