Hey there, this kicks off a three-episode guide where I walk you through putting together a solid vector search feature tailored for enterprise-level SaaS apps.

  • Episode 1: Design Foundations and Tenant Isolation Tactics 👈 Right where we are now
  • Episode 2: Ensuring Reliability in Live Environments and Tracking Performance (Dropping mid-week)
  • Episode 3: Trimming Expenses and Key Takeaways from the Journey (Out by week's end)

Quick Summary: We're diving deep into an enterprise SaaS setup that handles over two million compliance files each month via vector search. In this episode, I'll break down the overall design, how it integrates with Rails, and strategies for keeping data separate across multiple users.

Understanding the Core Issue

Picture this setup: A SaaS tool designed for big players in finance, medicine, and drug industries, helping them navigate tricky rules and regulations.

What's hurting them: These groups get bombarded with tons of official papers every month, like stock reports, health agency rules, quality benchmarks, and privacy law changes. Their teams waste more than 60 hours weekly digging through digital files to pinpoint the right info.

The big hurdle: We needed to engineer an intelligent search system powered by AI that grasps the nuances of legal jargon and delivers spot-on matches from a massive pool of documents.

Key limitations we faced:

  • Over 150 major clients sharing the same system (requiring smart tenant separation)
  • A whopping 2.1 million files in the system, adding about 50,000 more each month
  • Typical file size: Around 200 pages and half a megabyte
  • Must meet strict standards like SOC2 and GDPR (including tracking changes and securing data silos)
  • Guaranteed 99.9% availability, with hefty fines of $10k per hour of downtime
  • Keeping costs under $2,500 monthly for the tech stack

Our Custom-Built System: The Big Picture

A Bird's-Eye View

Main Building Blocks:

  • Rails Backend - Handles shared processing for documents across tenants
  • Vectra - A flexible client for vector databases that works with any provider
  • Qdrant - Our in-house vector storage solution (keeps expenses low and meets privacy rules)
  • Sidekiq - Manages tasks that run in the background
  • Sentence-Transformers - On-site tool for creating embeddings

Handling Documents Across Multiple Tenants

Tackling Large-Scale PDF Management

Starting Point: A user drops in a hefty 300-page document, say a standard financial disclosure form like an SEC 10-K.

What Needs to Happen:

  • Pull out the readable content from the PDF
  • Break it down into bite-sized pieces ready for searching (...[продолжение статьи]