Weave Code
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 Supabase Store Laravel Package

symfony/ai-supabase-store

Supabase vector store integration for Symfony AI Store using PostgreSQL pgvector. Connect your Symfony AI apps to Supabase vector columns and the match_documents RPC for similarity search, with links to Supabase docs and Symfony AI contribution/resources.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Laravel/Symfony Compatibility: While designed for Symfony AI, this package can be adapted for Laravel via Symfony’s Bridge or Laravel’s Symfony integration (e.g., symfony/http-client for Supabase API calls). The StoreInterface abstraction allows for modular swapping if Laravel’s ecosystem (e.g., spatie/laravel-ai) evolves to support similar patterns.
  • Vector Store Placement: Fits well in AI/ML pipelines (e.g., RAG, semantic search) where embeddings are generated (e.g., via symfonycasts/laravel-ai) and stored/retrieved. Avoids reinventing vector storage for Laravel apps using Supabase.
  • PostgreSQL Dependency: Requires pgvector in Supabase or self-hosted PostgreSQL. Laravel apps using MySQL/SQLite would need a workaround (e.g., proxy via Supabase API).

Integration Feasibility

  • Laravel Service Provider: Can be wrapped in a Laravel service provider to expose the store via dependency injection, mimicking Symfony’s container integration.
  • Query Abstraction: The query() method with filter support aligns with Laravel’s Eloquent query builder patterns, easing adoption for Laravel devs familiar with where() clauses.
  • Supabase API Fallback: If pgvector isn’t feasible, the package’s RPC calls could be replaced with direct Supabase REST API calls (e.g., supabase-js PHP port), though this reduces pgvector-specific optimizations.

Technical Risk

  • Laravel-Symfony Friction: Laravel’s DI container differs from Symfony’s, requiring adapter layers (e.g., symfony/service-contracts wrappers) or manual instantiation.
  • Limited Laravel Ecosystem: No Laravel-specific documentation or examples increases ramp-up time. Risk of undocumented edge cases (e.g., Supabase RPC timeouts).
  • Performance Overhead: Supabase API calls may introduce latency compared to direct pgvector queries. Benchmark against alternatives like Laravel Scout (Elasticsearch) or Meilisearch.
  • Schema Rigidity: Assumes Supabase’s match_documents RPC; custom schemas would need manual RPC adjustments.

Key Questions

  1. Laravel Compatibility: How much effort is needed to adapt Symfony’s StoreInterface for Laravel’s service container?
  2. Alternatives: Would a Laravel-specific vector store (e.g., spatie/laravel-ai + custom pgvector driver) be more maintainable?
  3. Supabase API Limits: How do Supabase’s RPC rate limits impact high-frequency queries (e.g., real-time search)?
  4. Data Migration: What’s the effort to migrate existing Laravel vector data (e.g., from Redis/Elasticsearch) to Supabase?
  5. Cost vs. Control: Is Supabase’s managed pgvector cost-effective compared to self-hosted solutions (e.g., Dockerized pgvector + Laravel)?

Integration Approach

Stack Fit

  • Laravel + Supabase: Ideal for Laravel apps already using Supabase (e.g., for auth, PostgreSQL) and needing vector search without switching databases.
  • AI/ML Workflows: Fits Laravel apps using LLM integrations (e.g., symfonycasts/laravel-ai, tighten/laravel-ai) for RAG or embeddings.
  • PostgreSQL Users: Best for Laravel apps using PostgreSQL (via illuminate/database); MySQL/SQLite users would need a proxy layer.

Migration Path

  1. Infrastructure Setup:
    • Enable pgvector in Supabase or self-hosted PostgreSQL.
    • Configure Supabase RPCs (match_documents) if using Supabase.
  2. Laravel Adapter Layer:
    • Create a Laravel service provider to instantiate the Symfony store:
      // app/Providers/SupabaseStoreServiceProvider.php
      use Symfony\AI\Store\SupabaseStore;
      use Illuminate\Support\ServiceProvider;
      
      class SupabaseStoreServiceProvider extends ServiceProvider {
          public function register() {
              $this->app->singleton('supabase.store', function ($app) {
                  return new SupabaseStore(
                      new \Symfony\AI\Store\SupabaseClient(
                          config('supabase.url'),
                          config('supabase.key')
                      ),
                      config('supabase.store.table'),
                      config('supabase.store.embedding_column')
                  );
              });
          }
      }
      
  3. Configuration: Add to config/supabase.php:
    'store' => [
        'table' => 'documents',
        'embedding_column' => 'embedding_vector',
        'id_column' => 'id',
    ],
    
  4. Data Migration:
    • Export existing vectors (e.g., from Redis/Elasticsearch) to a CSV.
    • Use SupabaseStore::add() in a Laravel command to bulk-import:
      use Illuminate\Support\Facades\Artisan;
      
      Artisan::call('supabase:import', [
          'file' => 'path/to/vectors.csv',
          'table' => 'documents',
      ]);
      

Compatibility

  • Laravel 10+: Requires PHP 8.1+ and Symfony components (e.g., symfony/http-client for Supabase API).
  • Supabase PHP SDK: Needs supabase/supabase-php or a custom client wrapper.
  • pgvector: PostgreSQL ≥10 with pgvector extension. Self-hosted Laravel apps must manually enable it.

Sequencing

  1. Prototype: Test with a single AI feature (e.g., semantic search for a blog) to validate performance.
  2. Benchmark: Compare against Laravel-native solutions (e.g., Elasticsearch via Scout).
  3. Phase Rollout:
    • Phase 1: Non-critical AI features (e.g., product recommendations).
    • Phase 2: Core search functionality with fallback caching (e.g., Redis).
  4. Monitor: Track Supabase RPC latency and error rates using Laravel’s logging.

Operational Impact

Maintenance

  • Dependency Management: Monitor Symfony AI and Supabase PHP SDK updates for breaking changes. Use composer require with --update-with-dependencies cautiously.
  • Schema Updates: Manual adjustments may be needed if Supabase alters RPC signatures or pgvector behavior. Document schema changes in a DATABASE_MIGRATIONS.md.
  • Logging: Add Laravel-specific logging for RPC calls and query performance:
    // Log vector queries
    \Log::debug('Vector query', [
        'query' => $query->getEmbedding(),
        'filters' => $query->getFilters(),
        'response' => $response->getResults(),
    ]);
    

Support

  • Community: Limited Laravel-specific support. Issues may require:
    • Symfony AI GitHub issues.
    • Supabase community forums.
    • Reverse-engineering Symfony’s implementation.
  • Fallback: Implement retry logic for transient Supabase API failures:
    use Symfony\Component\HttpClient\RetryableHttpClient;
    
    $client = new RetryableHttpClient(
        new \Symfony\Contracts\HttpClient\HttpClientInterface(),
        [
            'max_retries' => 3,
            'delay' => 100,
        ]
    );
    
  • Documentation: Create internal Laravel-specific docs covering:
    • Service provider setup.
    • Query examples with Eloquent-like syntax.
    • Troubleshooting Supabase RPC errors.

Scaling

  • Horizontal Scaling: Supabase handles this, but pgvector performance degrades with >10M vectors without optimization (e.g., hnsw indexes). Consider:
    • Approximate Nearest Neighbors (ANN): Use Supabase’s match_documents with ef/ivf parameters.
    • Sharding: Distribute vectors across multiple Supabase tables.
  • Cost: Supabase’s pricing may scale unpredictably with RPC volume. Monitor usage via Supabase’s dashboard.
  • Self-Hosted: Alternative is to self-host pgvector with Laravel, but loses Supabase’s managed services (e.g., backups, scaling).

Failure Modes

Failure Point Impact Mitigation
Supabase API downtime Vector queries fail Implement circuit breakers with Laravel’s Illuminate\Cache\Repository.
pgvector index corruption Slow queries Regular backups; monitor query plans via EXPLAIN ANALYZE.
Schema mismatches Runtime errors Use Laravel migrations to validate schema before queries.
High RPC latency Poor user experience Cache frequent queries in Redis with a TTL.
Laravel-Symfony DI conflicts Service registration failures Use symfony/service-contracts adapters or manual instantiation.

Ramp-Up

  • Learning Curve: Moderate for Laravel devs familiar with Symfony components. Steep for teams new to:
    • Symfony’s StoreInterface.
    • Supabase RPCs and pgvector syntax.
  • Training Focus:
    • Day 1: Service provider setup and
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.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony