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

Technical Evaluation

Architecture Fit

  • Vector Store Integration: The package enables SurrealDB as a vector store backend for Symfony AI, which can be leveraged in Laravel via PSR-15 interfaces or abstraction layers. This aligns well with Laravel applications requiring AI/ML capabilities (e.g., semantic search, recommendation systems) while avoiding proprietary vector databases.
  • SurrealDB Advantages:
    • Unified data model: Combines relational, document, and vector data in a single database, reducing infrastructure complexity.
    • Native vector search: Supports HNSW/MTREE indexes and vector functions (e.g., vector_similarity), enabling efficient similarity queries.
    • Real-time sync: SurrealDB’s ACID compliance and WebSocket support simplify real-time AI workflows (e.g., dynamic embeddings).
  • v0.14.0 Architecture Signals:
    • VectorDocumentInterface (#2495) introduces a canonical document contract between the store and the application. Architecturally this is a portability win: our Laravel service layer can type-hint the interface rather than SurrealDB-shaped arrays, so a future swap to pgvector/Weaviate touches adapter code only, not domain code. It also implies the store now hydrates objects rather than raw arrays — existing call sites that assume array shapes will need review.
    • count capabilities (#1755) close a genuine gap: previously corpus sizing required bespoke SurrealQL or an application-side counter. This unlocks index/collection-level metrics without custom glue, and makes store-level observability a first-class concern rather than a workaround.
  • Potential Challenges:
    • Symfony Dependency: Laravel teams may need to adopt Symfony AI or build a custom bridge, adding complexity.
    • Maturity Risk: SurrealDB’s vector search is less battle-tested than alternatives like pgvector or Weaviate, particularly at scale. The package itself is still pre-1.0 (v0.14), so the abstraction surface is still moving.
    • Schema Flexibility: SurrealDB’s schema-less design requires careful planning to optimize vector queries (e.g., indexing strategies, distance metrics).

Integration Feasibility

  • Laravel Compatibility:
    • Symfony AI Integration: Laravel can use this package via Composer or wrap it in a Laravel service provider to abstract Symfony dependencies.
    • Direct SurrealDB Driver: Alternatively, use surrealdb/surrealdb directly and implement a Laravel-specific vector store interface for tighter control.
  • Key Dependencies:
    • Requires Symfony AI (symfony/ai) and SurrealDB PHP client (surrealdb/surrealdb).
    • Laravel’s service container can bind the store to an interface (e.g., VectorStoreInterface) for modularity. With v0.14, also bind/alias VectorDocumentInterface in a Repository or Bindings provider so domain code never depends on the concrete document class.
  • Data Migration:
    • Existing vector data (e.g., PostgreSQL, Elasticsearch) can be migrated via SurrealQL or custom ETL scripts.
    • Schema design must balance flexibility (SurrealDB’s strength) with performance (e.g., indexing strategies for vectors).
    • Upgrade path from v0.13 → v0.14 is low-friction on paper (additive features, no listed deprecations), but the new document contract means any code that serialized store responses to arrays or JSON should be re-validated once against a real dataset.

Technical Risk

  • High:
    • Performance Uncertainty: SurrealDB’s vector search may not match pgvector/Weaviate at scale; benchmarking is critical.
    • Symfony Overhead: Adding Symfony AI may introduce unnecessary dependencies or complexity for Laravel teams.
    • Schema Design Risk: Poorly structured SurrealDB tables/records can degrade query performance (e.g., missing indexes, inefficient joins).
    • Connection Latency: SurrealDB’s HTTP/WebSocket API may introduce higher latency than native drivers (e.g., pgvector).
  • Medium (new in v0.14):
    • Pre-1.0 Churn: v0.14 introduces a new public interface and a new capability in the same minor bump. Under 0.x semver conventions, minor releases may contain breaking changes; treat every bump as a potential migration event and pin exact or tilde versions in composer.json.
    • count Cost Model Unknown: A store-level count over a large vector collection may be a full scan on SurrealDB rather than an index-assisted operation. If we surface counts in UI or dashboards, an expensive count can become a top-N slow query overnight.
    • Interface Adoption Refactor: If the store’s return types moved toward VectorDocumentInterface, existing pilot code and tests will need adjustment — budget a small refactor, not just a version bump.
  • Mitigation:
    • Benchmark: Compare SurrealDB’s latency/throughput against alternatives (e.g., pgvector, Elasticsearch) for your workload — extend the harness to cover count at target corpus size and filtered vs. unfiltered counts.
    • Fallback Strategy: Implement a feature flag to switch between SurrealDB and a secondary store (e.g., Redis for caching).
    • Testing: Validate concurrency (SurrealDB’s API may bottleneck under high QPS) and failure recovery (e.g., retries, circuit breakers). Add a contract test suite asserting behaviour against VectorDocumentInterface so future 0.x bumps surface breakage in CI, not production.

Key Questions

  1. Performance:
    • How does SurrealDB’s vector search scale compared to pgvector/Elasticsearch for our expected query volume (e.g., 10K+ QPS)?
    • Are index rebuilds (for new collections) disruptive in production, and how can we minimize downtime?
  2. Cost:
    • What are the hosting costs (self-managed vs. cloud) for SurrealDB compared to alternatives like Pinecone or Weaviate?
  3. Schema:
    • How will we model metadata + vectors in SurrealDB to optimize query performance (e.g., tables vs. records, index types)?
  4. Laravel Integration:
    • Should we use Symfony AI directly or build a Laravel-specific wrapper (e.g., laravel-surreal-vector) to reduce dependencies?
    • How will we handle authentication (e.g., SurrealDB’s NSM vs. Laravel’s Passport) and connection management?
  5. Failure Modes:
    • What’s the RTO/RPO for SurrealDB outages, and how can we mitigate downtime (e.g., local cache layers, retries)?
  6. Long-Term Viability:
    • Is SurrealDB’s roadmap (e.g., serverless, multi-region support) aligned with our needs?
    • How will we handle SurrealDB version upgrades (e.g., breaking changes in vector functions or APIs)?
  7. v0.14-Specific:
    • Is count index-assisted or a scan, and is it filter/namespace-scoped? Can it be used safely in request-path code, or only in async jobs?
    • Does VectorDocumentInterface replace the previous array-based document handling, or is the old shape still supported/deprecated? Any timeline for removal?
    • Is the package committing to a 1.0 / LTS milestone, and what is the expected release cadence for 0.x?

Integration Approach

Stack Fit

  • Laravel + Symfony AI:
    • Symfony AI provides the StoreInterface; this package implements it for SurrealDB, enabling Laravel to use SurrealDB as a vector store.
    • Laravel Service Container: Bind the store to an interface (e.g., VectorStoreInterface) for loose coupling and easy swapping (e.g., for testing or fallback). Also alias VectorDocumentInterface to a concrete document class so application code depends on the contract only.
    • Alternatives:
      • Direct SurrealDB Driver: Use surrealdb/surrealdb and implement a Laravel-specific vector store to avoid Symfony dependencies.
      • Hybrid Approach: Use Symfony AI for vector operations but abstract SurrealDB-specific logic in a Laravel service layer.
  • Recommended Stack:
    Component Package/Library Notes
    Laravel laravel/framework Host application
    Symfony AI symfony/ai Vector store abstraction
    SurrealDB Store symfony/ai-surreal-db-store Vector store implementation — pin ~0.14
    SurrealDB Client surrealdb/surrealdb PHP driver for SurrealDB
    Laravel Service Layer Custom (e.g., app/Services/VectorStore) Abstraction over SurrealDB-specific logic; type-hint VectorDocumentInterface
    Metrics (new) Store count API Replace bespoke SurrealQL counters

Migration Path

  1. Assessment Phase:
    • Benchmark SurrealDB’s vector search performance against alternatives (e.g., pgvector, Elasticsearch) using real-world queries.
    • Design a SurrealDB schema for vectors + metadata, focusing on indexing strategies (e.g., HNSW for high-dimensional data).
    • Add a count benchmark (full collection and filtered) to the same harness.
  2. Package Upgrade (v0.13 → v0.14):
    • Bump to ~0.14 in a branch; run the existing test suite and the contract tests.
    • Inventory call sites that consume store responses and migrate them to VectorDocumentInterface where applicable.
    • Replace any ad-hoc SurrealQL count queries with the new count capability, after confirming its cost profile.
    • Keep the previous tagged version deployable for a fast rollback; the upgrade should ship independently of any feature work.
  3. Pilot Integration:
    • Integrate the package in a non-critical feature (e.g., semantic search for a blog or product catalog).
    • Use feature flags to toggle between SurrealDB and a fallback store (e.g., Redis or PostgreSQL).
  4. Full Migration:
    • Migrate existing vector data from legacy stores (e.g., PostgreSQL, Elasticsearch) to SurrealDB using ETL scripts or SurrealQL.
    • Replace all vector store calls in Laravel with the new SurrealDB-backed implementation.
  5. Optimization:
    • Monitor query performance and adjust SurrealDB indexes (e.g., DEFINE INDEX for new collections).
    • Implement caching layers (e.g., Redis) for frequently accessed vectors to reduce SurrealDB load.
    • Cache count results with a short TTL if they are surfaced in product UI.

Compatibility

  • Symfony AI Compatibility:
    • The package adheres to Symfony AI’s StoreInterface, ensuring compatibility with Symfony AI’s embedding generation, similarity search, and hybrid search features.
    • Laravel can leverage Symfony AI’s abstraction layer without tightly coupling to Symfony components.
  • SurrealDB Compatibility:
    • Requires SurrealDB v1.0+ (for vector search support).
    • Compatible with SurrealDB’s HTTP/WebSocket API, but may introduce latency compared to native drivers.
  • Package Version Compatibility (new):
    • v0.14.0 introduces VectorDocumentInterface and count as additive surface; no deprecations are listed in the changelog, so v0.13 → v0.14 is expected to be non-breaking but not yet verified by our own test suite.
    • Because the package is pre-1.0, treat minor bumps as review-gated: pin ~0.14.x, read the changelog on every release, and avoid floating constraints.
  • Laravel-Specific Considerations:
    • Authentication: SurrealDB uses NSM (Namespace/Set/Member) for access control, which may require a custom Laravel middleware or integration with Laravel’s auth system.
    • Connection Management: SurrealDB connections should be reused (e.g., via Laravel’s connection facade or a singleton service) to avoid overhead.
    • Serialization: If VectorDocumentInterface objects now cross the store boundary, ensure they serialize correctly for queues and HTTP resources (e.g., implement JsonSerializable or an API Resource transformer).

Sequencing

  1. Phase 1: Proof of Concept (2-4 weeks)
    • Set up SurrealDB locally/on a cloud provider.
    • Integrate symfony/ai-surreal-db-store in a Laravel app using Symfony AI.
    • Test basic operations: insert, find, remove, count vectors.
    • Exercise VectorDocumentInterface end-to-end (create → store → retrieve → serialize).
    • Benchmark performance against alternatives (e.g., pgvector).
  2. Phase 2: Pilot Feature (4-6 weeks)
    • Implement SurrealDB for a low-risk AI feature (e.g., semantic search for a blog).
    • Add fallback logic (e.g., Redis cache) and monitor failures.
    • Validate schema design and query performance.
  3. Phase 3: Full Integration (6-8 weeks)
    • Migrate all vector data to SurrealDB.
    • Replace legacy vector store calls with the new implementation.
    • Wire count into ingestion/backfill monitoring and dashboards.

Operational Impact

Maintenance

  • Version Pinning Is Mandatory: The package is at v0.14 and shipped a new public interface in a minor release. Floating constraints (^0.13) invite silent surface changes; pin ~0.14.0 and upgrade deliberately.
  • Upgrade Cadence: v0.13 → v0.14 landed ~two feature changes plus housekeeping, suggesting a fast-moving repo. Budget roughly half a developer-day per minor bump for changelog review, test suite runs, and contract test fixes — more if a bump touches document hydration.
  • Dual Dependency Surface: We now maintain compatibility with both Symfony AI and SurrealDB server versions. Track both upgrade paths; a Symfony AI interface change can force a store bump, and a SurrealDB release can change vector function behaviour.
  • Abstraction Debt: VectorDocumentInterface reduces long-term lock-in but adds a mapping layer to maintain for every new vector attribute (metadata, filters, scores).

Support

  • Upstream Support Model: Community-maintained under the Symfony organisation. No vendor SLA. Issues route through GitHub; response times are best-effort.
  • Internal Ownership: Assign a named owner for the vector-store integration (code + SurrealDB instance). Without one, count/interface changes will surface as surprise breakage in feature work.
  • Escalation Path: For anything on the critical path (search-driven revenue features), assume no upstream escalation and rely on the fallback store as the real safety net.
  • Documentation Gap: The new count capability and document interface are documented only by changelog entries at present — expect to write internal runbook notes from source reading.

Scaling

  • Ingestion Monitoring (new): count makes backfill and re-embedding jobs observable — assert expected document counts post-ingest, alert on drift. This is a meaningful operational win over bespoke counters.
  • Query Cost of count: Validate whether counts are index-assisted. If they scan, restrict to async jobs and cached dashboards, never per-request product UI. Set a hard rule before adoption spreads.
  • Vector Index Scaling: HNSW build/rebuild times grow with corpus size; plan index changes as scheduled maintenance windows rather than ad-hoc.
  • Connection Pooling: SurrealDB’s HTTP/WebSocket transport is the throughput ceiling; long-lived connections and a bounded worker pool are required before horizontal scale-out of the Laravel app tier.
  • Cache Tier: Redis in front of hot vectors and counts absorbs both query latency and the cost of accidental count fan-out.

Failure Modes

  • SurrealDB Unavailable: Feature-flagged fallback to a secondary store or degraded (non-semantic) results. Define the degraded UX explicitly — an empty result set reads as "no matches," which is worse than a banner.
  • Count Endpoint Slow/Failing: Must not cascade into ingestion pipelines. Wrap count calls in try/catch with a timeout and emit a metric instead of blocking the job.
  • Interface Mismatch After Upgrade: A 0.x bump changing document hydration could break serialization silently (missing fields, null metadata). Contract tests plus a staging smoke test on real data are the control.
  • Index Missing on New Collection: New collections without a defined vector index return correct-but-slow results — invisible in functional tests, visible in p95 latency. Add an index-existence assertion to deploy checks.
  • Partial Ingestion: Store and source-of-truth drift after a failed backfill. Reconcile with count comparisons and a sampled re-embed job.
  • Data Loss / Recovery: Confirm SurrealDB backup tooling and restore drills before the pilot exits; validate RTO/RPO against product expectations rather than assuming ACID equals recoverable.

Ramp-Up

  • Learning Curve: Two unfamiliar surfaces at once — Symfony AI abstractions (unusual in a Laravel codebase) and SurrealDB/SurrealQL (unusual alongside Eloquent). Estimate 1–2 weeks for a mid-level Laravel engineer to be productive, most of it on SurrealQL and vector index concepts.
  • Onboarding Assets: Provide a short internal guide covering store binding, VectorDocumentInterface usage, count cost caveats, and the fallback toggle. Without it, each new contributor re-derives the same decisions.
  • Pilot as Training Ground: Phase 1–2 is where the team builds SurrealDB fluency at low blast radius; keep it there long enough to produce the benchmark numbers the go/no-go decision depends on.
  • Go/No-Go Gate: Recommend a formal decision point after Phase 2, with explicit thresholds on p95 similarity-search latency, count cost, and operational toil per upgrade — otherwise the pilot becomes the production system by default.
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