Cortex

Apr 2026May 2026

An Effect-native abstraction layer for vector databases, bringing ORM-level ergonomics (schemas, typed queries, and composable infrastructure) to AI storage.

card image
Vector DBRAGEffectTypeScript

Overview

Cortex is an Effect-native abstraction layer for vector databases. It provides schemas, typed collections, and composable infrastructure for vector operations, the same kind of structure ORMs brought to relational databases, applied to AI storage.

Problem

Most vector database tooling operates at a low level. You piece together SDKs, handwritten schemas, validation layers, metadata parsers, retry logic, and storage-specific query APIs until the codebase becomes infrastructure glue. As RAG systems grow, metadata becomes inconsistent, filters become fragile, and retrieval logic spreads across the application. Runtime parsing breaks assumptions, types collapse into Record<string, unknown>, and the compiler stops helping. This is the same problem relational databases had before ORMs existed.

Approach

Cortex brings structure and safety to vector database operations through three design decisions.

Built natively for Effect. Cortex is not an adapter or optional integration. It uses Effect's primitives directly. Vector operations become Effect programs, adapters become layers, collections become services, and resource management becomes predictable. Effect provides typed failures, dependency injection, and structured concurrency as the foundation.

Schema-driven infrastructure. Collections are structured, vectors are validated, and operations are composable. Metadata chaos is addressed by treating vector databases as structured application infrastructure rather than loosely typed storage. The compiler enforces assumptions before runtime can fail, removing a category of bugs common in RAG pipelines.

Adapters instead of lock-in. The vector database ecosystem changes constantly. Cortex uses adapters so application logic stays independent from storage implementations. Your application describes what it needs from vector infrastructure, not how a vendor implements it.

How It Works

import { Effect } from "effect";
import { VectorDB, DocumentId, Vector } from "@thaletto/cortex";

const program = Effect.gen(function* () {
  const db = yield* VectorDB;
  const id = DocumentId.make("user-1-preference");
  
  yield* db.upsert({
    id,
    content: "User prefers TypeScript over JavaScript",
    category: "preferences",
    tags: "typescript",
    metadata_json: JSON.stringify({ source: "onboarding" }),
    vector: Vector.make(new Array(384).fill(0)),
    expires_at: new Date("2026-12-31"),
  });
});

Tech Stack

  • Runtime: Effect (TypeScript)
  • Package: @thaletto/cortex
  • Adapters: Zvec, PageIndex (planned)