DBX + Jurix — Zero-Leakage Per-Tenant Vector Memory Powered by Amazon Bedrock

💡 Inspiration

Generative AI is revolutionizing business workflows, but in regulated enterprise industries—such as legal practice, financial audit, and healthcare—adoption has hit a hard wall. That wall is data sovereignty and tenant leakage.

Standard AI architectures rely on shared vector databases where embeddings from thousands of different customers are pooled into a single global index. If a developer misconfigures a query filter, a prompt injection bypasses guardrails, or a cross-tenant scan occurs, confidential data leaks. In corporate law, if Client A’s confidential acquisition agreement surfaces in Client B’s retrieval window, that constitutes an immediate breach of attorney-client privilege and legal malpractice.

Running a separate, dedicated database cluster for every single client or legal matter is financially cost-prohibitive and operationally impossible.

Our inspiration: What if we engineered an ultra-fast, memory-efficient vector engine from scratch that guarantees mathematical, cryptographic, and memory-boundary tenant isolation at the speed of in-memory caching, and paired it with the enterprise-grade foundation models of Amazon Bedrock?

That vision produced DBX—a per-tenant memory engine written in Go—and Jurix—the legal diligence and contract audit workspace demonstrating DBX and Amazon Bedrock in action.

⚙️ What It Does

DBX + Jurix is a full-stack, enterprise-grade AI infrastructure and vertical application suite:

DBX (The Per-Tenant Vector Database):

Provides isolated, low-latency state and vector memory partitions for every client/matter. Runs natively on the Redis Serialization Protocol (RESP) alongside an HTTP control plane. Isolates tenants into dedicated memory segments with independent Write-Ahead Logs (WAL), preventing cross-tenant leakage at the storage engine level. Delivers sub-millisecond approximate nearest neighbor (ANN) vector search. Jurix (The Legal Diligence & Contract Audit Workspace):

A commercial contract diligence and risk audit cockpit built for attorneys and enterprise reviewers. Uses Amazon Bedrock (Claude 3.5 Sonnet and Amazon Titan Text Embeddings V2) to evaluate contracts (NDAs, MSAs, DPAs) against custom firm playbooks (liability floors, indemnities, breach notification windows, and governing laws). Generates exact, clickable source citations down to the character offset without hallucinations. Tracks reviewer decisions (Accept, Reject, Resolve) using tamper-evident evidence fingerprints. Features a dedicated Pre-bill review engine that audits timekeeper narratives against the official ABA litigation and activity codes before client billing.

🧠 Math & Core Mechanics

DBX is built on principled systems programming and applied mathematics, avoiding off-the-shelf vector wrapper libraries:

  1. Hierarchical Navigable Small World (HNSW) Graphs For high-dimensional similarity search, DBX implements a native multi-layer HNSW graph:

Probabilistic Layer Assignment: Vectors are assigned to hierarchical layers according to a geometric distribution: $$l = \lfloor -\ln(\text{uniform}(0, 1)) \cdot m_L \rfloor$$ where $m_L = \frac{1}{\ln(M)}$. Top layers have sparse, long-range links for rapid coarse-grained exploration (resembling a skip-list), while lower layers provide dense clustering for high precision. Bounded Beam Search: Graph exploration uses dynamic candidate queues bounded by $efConstruction$ and $efSearch$ to balance query latency against recall accuracy (>99% recall at sub-millisecond response times).

  1. Distance Metrics & 8-Bit Scalar Quantization (SQ8) Cosine Distance & Normalized Inner Product: $$\text{Cosine}(u, v) = \frac{u \cdot v}{|u|2 |v|2} = \frac{\sum{i=1}^{d} u_i v_i}{\sqrt{\sum{i=1}^{d} u_i^2} \sqrt{\sum_{i=1}^{d} v_i^2}}$$ SQ8 Memory Compression: High-dimensional FP32 vectors (typically 4 bytes per dimension) consume massive RAM. DBX implements 8-bit Scalar Quantization (SQ8), compressing 32-bit floats into 8-bit integers via per-vector linear min-max scaling: $$q_i = \text{round}\left(255 \times \frac{x_i - x_{\min}}{x_{\max} - x_{\min}}\right)$$ When paired with Amazon Titan Text Embeddings V2, this achieves a 75% memory reduction with virtually zero degradation in ranking accuracy.
  2. Late Fusion Hybrid Scoring Pure semantic vector search often misses exact statutory numbers, dates, or party names. DBX combines sparse BM25 keyword matching with dense Bedrock embeddings using Reciprocal Rank Fusion (RRF): $$RRF(d) = \sum_{m \in M} \frac{1}{k + r_m(d)}$$ where $r_m(d)$ is the rank of document $d$ in system $m$, and $k$ is a smoothing constant ($k \approx 60$).

  3. Sharded Concurrency & Cryptographic Boundaries 256 Concurrent Memory Shards: Rather than relying on a single global mutex that bottlenecks under heavy multi-tenant read/write loads, DBX partitions key-spaces across 256 independent memory shards using FNV-1a hashing: $$\text{hash} = \left(\text{hash} \oplus \text{byte}\right) \times 16777619$$ Append-Only Write-Ahead Logging (WAL): Every vector insertion and state mutation is written to an fsync-flushed, CRC32-checksummed append log before being committed to memory, guaranteeing durability without blocking read throughput. Evidence Fingerprinting in Jurix: Reviewer decisions are anchored to an SHA-256 state fingerprint: $$\text{Fingerprint} = \text{SHA256}(\text{SourceQuote} \parallel \text{LineRange} \parallel \text{PolicyVersion})$$ If a contract is revised or a playbook rule changes, old decisions are automatically marked stale while preserving the audit history.

    🏗️ Architecture & How We Built It

    +-----------------------------------------------------------------------------------+ | JURIX FRONTEND | | React 19 + TypeScript + Vite + Tailwind CSS + Lucide | | (Line Anchors, Diligence Matrix, Playbook Editor, Pre-bill) | +-----------------------------------------------------------------------------------+ | HTTP / REST + CSRF | +-----------------------------------------------------------------------------------+ | JURIX SERVER | | FastAPI + SQLite WAL (AES-256-GCM) | | - Line Anchor Extraction (pypdf/docx) - Regulatory Watches | | - Policy Engine & Heuristics - Pre-bill ABA Code Auditor | +-----------------------------------------------------------------------------------+ | | AWS SDK / Bedrock API RESP Protocol (TCP 6380) | | +---------------------------+ +-----------------------------------+ | AMAZON BEDROCK | | DBX DATABASE | | - Claude 3.5 Sonnet / | | Custom Go Storage Engine | | Haiku Reasoning Models | | - 256 Memory Shards (FNV-1a) | | - Amazon Titan Text V2 | | - HNSW Multi-Layer ANN Search | | Embeddings | | - Per-Tenant Dedicated WALs | | - Zero Training on Data | | - Control Plane Orchestrator | +---------------------------+ +-----------------------------------+ Storage Engine: Engineered in Go for native memory control, goroutine-backed concurrency, and minimal garbage collection overhead. Application API: Built with Python 3.13, FastAPI, and SQLite WAL encrypted with 256-bit AES-GCM payloads. AI Intelligence: Powered by Amazon Bedrock using Anthropic Claude 3.5 Sonnet for structured clause reasoning and Amazon Titan Text Embeddings V2 for semantic representations. Frontend: Crafted in React 19, TypeScript, and Tailwind CSS, featuring dark/light modes, responsive diligence grids, and zero bloated component libraries. Deployment & CI: Containerized via multi-stage Docker builds, automated under GitHub Actions, and orchestrated for cloud-native deployment.

    🚧 Challenges We Faced

    Eliminating Mutex Contention in Vector Graphs: Problem: HNSW graph construction requires exploring neighbors and updating bidirectional edge lists. Under concurrent multi-tenant ingestion, a global lock degraded performance. Solution: Implemented fine-grained, per-node read-write locks and partitioned memory into 256 independent shards, allowing different tenants to insert and index simultaneously without contention. Deterministic Evidence Anchoring: Problem: Generative models tend to summarize or slightly rephrase quotes, breaking legal citations when matching back to original documents. Solution: Implemented an exact character-and-byte verification pass in Jurix. Before an anchor is rendered, the system verifies its presence and coordinates in the ingested text; missing clauses are explicitly flagged without hallucinated quotes. CI/CD Cache & Cross-Platform Testing: Problem: Differences between Windows filesystem permissions and Linux GitHub Actions runners caused CI test failures when creating temporary pytest directories and resolving dependency vulnerabilities. Solution: Diagnosed runner execution logs via GitHub's API, integrated directory provisioning scripts into the workflow, and updated locked lockfiles to achieve 100% green test passes across 102 integration tests.

    🏆 Accomplishments We Are Proud Of

    Built a Real Database from Scratch: We did not just build a UI on top of Pinecone or Milvus. We wrote a high-performance vector and key-value database engine in Go with native RESP protocol support. True Zero-Leakage Architecture: Demonstrated that Tenant B cannot query, scan, or access Tenant A's vector space, even when hosted on the same physical node. 102 Passing Integration Tests: Built comprehensive automated test coverage spanning account isolation, evidence immutability, foreign-tenant boundaries, and concurrency stress testing. Enterprise AI Synergy: Demonstrated how Amazon Bedrock’s zero-training privacy guarantee pairs with DBX’s per-tenant memory to solve the biggest enterprise AI adoption hurdle.

    📚 What We Learned

    Tenant Isolation Belongs at the Storage Layer: Trying to enforce tenant privacy purely through application-level SQL WHERE tenant_id = ? or vector metadata filters is prone to human error, injection attacks, and developer oversights. True multi-tenancy must be enforced at the memory and file boundary. Vector Quantization is Essential: Moving from FP32 to SQ8 quantization yields a 4x reduction in RAM requirements while preserving over 98% of top-k recall, dramatically slashing cloud infrastructure costs. Lawyers Value Determinism Over Creativity: In legal tech, an AI that hallucinates a single statute or slightly misquotes a liability cap is worse than useless. Deterministic rules, clear audit trails, and human-in-the-loop verification are what legal practitioners actually require.

    🔮 What's Next for DBX + Jurix on Amazon

    Alexa+ / Conversational Diligence: Integrating an Alexa+ skill allowing corporate attorneys to run hands-free, voice-driven diligence inquiries (e.g., "Alexa, check if Acme Corp's contract has a 24-month term violation"). Native Bedrock Knowledge Bases Connector: Building a custom external connector so Amazon Bedrock Knowledge Bases can query DBX’s isolated tenant shards directly. AWS Graviton & GPU Acceleration: Compiling DBX for AWS Graviton4 instances for optimal cost-to-performance, and integrating GPU-accelerated HNSW index construction. Clustered Multi-Region Raft: Implementing a Raft-based consensus protocol in DBX for active-active high availability and automated disaster recovery backed by Amazon S3.

Built With

Share this project:

Updates

Submission history