AI builder who teaches what he ships — new production AI lessons
    All Architectures
    Data InfrastructureIntermediate

    pgvector Semantic Search

    A production semantic-search stack that keeps vectors next to your product data. PostgreSQL pgvector stores embeddings with HNSW indexes; SQL filters (tenant, price, stock) run in the same query. Redis caches hot embedding lookups and ranked result pages so you do not re-embed or re-rank on every keystroke.

    1K – 200Kusers supported
    $120 – $1,800/month infrastructure

    Architecture Diagram

    Interactive — hover over any node to see its role and description.

    UserSearch UINext.jsSearch APIFastAPIEmbedderOpenAIpgvectorHNSW + SQLRerankerCohereRedis CacheIngest WorkerQueueUserFrontendAPIAI / MLDatabaseCacheQueue

    Use Cases

    Product and catalog search that understands intent, not just keywords
    Internal document search across wikis, tickets, and PDFs
    Similar-item recommendations from existing catalog embeddings
    Support-article retrieval for chat and help centres
    Multi-tenant SaaS search with row-level ACL in the same SQL query

    Technology Stack

    frontend

    Next.jsReactTypeScript

    backend

    Node.jsPython FastAPIPrisma

    database

    PostgreSQL 16 + pgvectorRedis

    infrastructure

    AWS RDS / AuroraElastiCacheDocker

    ai

    OpenAI text-embedding-3-largeCohere Rerank

    Scalability Roadmap

    Stage 10 – 5K users· RDS Postgres + pgvector ivfflat

    One RDS instance. ivfflat index is enough under ~1M vectors. Redis on the same VPC.

    Stage 25K – 50K users· HNSW + read replica + ElastiCache

    Switch to HNSW. Read replica for search traffic. Dedicated Redis for cache.

    Stage 350K – 200K users· Aurora + partitioned indexes

    Aurora PostgreSQL. Partition pgvector tables by tenant. Parallel ingest workers.

    Stage 4200K+ users· Aurora Global + regional Redis

    Write region plus pgvector read replicas per continent. Redis Cluster per region for sub-50ms cache hits.

    Cost Breakdown

    Development Cost

    $8,000 – $22,000 (6–12 weeks)

    Infrastructure Cost

    $120 – $1,800/month (RDS + Redis + embedding API)

    Maintenance Cost

    $1,000 – $3,000/month for index tuning, ingest, and eval sets

    Security Considerations

    Tenant filters applied in the same SQL as the vector query — no orphaned hits
    Embedding API keys stay in the worker VPC, never the browser
    PII stripped before documents are chunked and embedded
    Redis keys namespaced per tenant with TTL so stale ACL results cannot leak

    More Architectures

    Need This Architecture Built?

    Get a detailed architecture plan, technology recommendations, development roadmap, and infrastructure estimation for your project.