$ show chroma-core/chroma
Chroma is an open-source vector database designed for AI applications, providing efficient storage and retrieval of embeddings with metadata. The system supports both single-node (SQLite) and distributed deployments (Spanner, S3, gRPC microservices) with a multi-language architecture: Python for the client API and embedding function ecosystem, Rust for high-performance data-plane services (frontend, worker, log, compaction, garbage collection), Go for the control-plane sysdb, and TypeScript/JavaScript for web clients. Key features include HNSW, SPANN, and MaxScore sparse indexing; RaBitQ quantization; write-ahead log replication (WAL3); conditional transactions for optimistic concurrency; authentication/authorization (basic, token, RBAC); rate limiting and quota enforcement; OpenTelemetry observability; and a CLI with TUI. The repository also contains an AI agent subsystem (Anthropic integration, trajectory storage) and a foundation API for hosted service capabilities. While the codebase is well-structured with extensive property-based testing and reusable patterns (operator/orchestrator, component system, configurable backends), it suffers from multi-language duplication and ongoing client migration (old vs new JS packages).
The LLM identified 128 files worth highlighting for reuse:
Provides interchangeable BTreeMap (random-access) and Vec (ordered, delete-as-noop) storage strategies behind a single enum for Arrow blockfile delta builders. Demonstrates clean separation of concerns and allows switching storage backends without altering the delta application logic. Reusable in any Arrow-based columnar storage system requiring incremental updates.
Implements size-bounded, UTF-8-safe chunking of large JSON values with SHA-256 verification for integrity. Designed to store reasoning trajectories as Chroma documents. The chunking algorithm respects UTF-8 boundaries and produces verifiable chunks, making it reusable for any system that needs to split large text payloads into indexed fragments.
Implements rendezvous hashing (highest random weight) with a pluggable Hasher trait (Murmur3 default). Provides assign() and assign_one() methods for distributing items across nodes. The design is generic over hash function and node type, making it reusable for any distributed system requiring consistent assignment with minimal redistribution on node changes.
Adaptive circuit breaker for multi-dimensional admission control. Tracks success/failure rates and opens the circuit when error rate exceeds a threshold, with automatic half-open recovery. The implementation is generic over request types and can be extracted for any service needing load shedding with configurable sensitivity.
Deterministic exponential backoff algorithm based on system headroom integral. Computes backoff duration from a continuous integral of headroom (available capacity), producing smooth, predictable delays without random jitter. Reusable in any retry or rate-limiting system that prefers deterministic behavior over probabilistic backoff.
Validates embedding function configurations for safety, specifically rejecting 'trust_remote_code' in local model loaders (HuggingFace, SentenceTransformer). Provides a reusable pattern for validating user-supplied configs against security risks before instantiation, applicable to any plugin system that loads external models.
Defines the ChromaError trait with gRPC status code mapping, enabling consistent error propagation across services. Includes implementations for common error types and conversion to tonic Status. The pattern of associating error codes with traits is reusable for any gRPC-based distributed system needing structured error reporting.
Generic dispatcher for the Chroma actor system, routing messages to component handlers based on message type. Supports synchronous and asynchronous handlers with backpressure via bounded channels. The dispatcher pattern is reusable for any actor-based system requiring type-safe message routing with configurable concurrency.
Provides a Stopwatch helper that records elapsed time in OpenTelemetry histograms with automatic label propagation. Simplifies timing instrumentation by wrapping code blocks and emitting duration metrics. Reusable in any Rust application using OpenTelemetry for performance monitoring.
Proc-macro crate that generates capability-based metering contexts. Annotated functions automatically emit metering events with context (tenant, collection, operation type). The macro approach reduces boilerplate and ensures consistent metering across services. Reusable for any system requiring usage-based billing or quota tracking.
Implements SignedRoaringBitmap, a data structure for delayed set-minus evaluation in metadata filtering. Tracks additions and removals separately, computing the actual set only when needed. Optimizes filter performance by deferring expensive set operations. Reusable in any system requiring efficient set difference queries on large bitmaps.
Buffers request bodies as JSON while preserving OpenTelemetry trace context. Allows tracing of request payloads without breaking streaming. The pattern of wrapping request bodies with tracing is reusable for any HTTP service needing detailed request logging without sacrificing performance.
LRU cache implementation with configurable size function and eviction callback. Supports segment caching with memory-aware eviction. The design is generic over key and value types, making it reusable for any Python application needing a bounded cache with custom size accounting and eviction hooks.
Async partitioned mutex that reduces contention by sharding lock acquisition across multiple internal mutexes. Provides try_lock and lock methods with configurable shard count. Reusable in any async Rust application needing fine-grained locking for high-concurrency scenarios.
Implements RaBitQ (Randomized Binary Quantization) for vector compression, supporting 1-bit and 4-bit codes with unbiased distance estimation. Includes mathematical derivations and shared distance computation functions. Reusable in any vector search system needing memory-efficient approximate nearest neighbor search with theoretical guarantees.
Implements the MaxScore algorithm for efficient top-k retrieval from sparse inverted indexes. Uses a min-heap for candidate scoring with early termination based on upper bounds. The implementation is optimized for sparse vectors and includes lazy loading of posting lists. Reusable in any information retrieval system requiring fast sparse vector search.
Defines the Operator trait and a collection of composable execution operators (fetch log, apply log, commit, filter, project, etc.) for the Chroma worker. Each operator implements a single unit of work with typed inputs and outputs, enabling orchestration via the system framework. The operator pattern is reusable for any pipeline-based execution engine.
Provides a Tool trait with automatic JSON schema generation from function signatures, enabling dynamic tool registration and invocation. Includes DynTool and ToolSet for runtime tool management. Reusable in any AI agent framework that needs to expose typed tools to language models with schema validation.
Defines collection configuration with Pydantic-based validation, supporting parameters like HNSW space, construction ef, and M. Provides methods for serialization, deserialization, and safe updates. The pattern of validated configuration objects is reusable for any system needing type-safe, evolvable configuration.
Implements basic authentication with bcrypt password hashing and jitter against timing attacks. Provides a reusable auth provider that can be plugged into the Chroma server. The timing-attack mitigation pattern is applicable to any authentication system.
Provides thread-safe SQLite connection pools with LockPool (single connection with lock) and PerThreadPool (one connection per thread). Handles connection lifecycle and cleanup. Reusable in any Python application needing concurrent SQLite access with minimal overhead.
Python implementation of rendezvous hashing for consistent assignment of items to nodes. Supports weighted nodes and pluggable hash functions. Reusable in any distributed Python system needing deterministic node selection with minimal redistribution on topology changes.
Generic LRU cache implementation with configurable capacity and eviction callback. Thread-safe via locking. Reusable in any Python application needing a bounded cache with least-recently-used eviction policy.
Read-write lock implementation allowing multiple concurrent readers or exclusive writer access. Uses threading primitives. Reusable in any Python application needing fine-grained concurrency control for shared resources.
Defines a hierarchy of Chroma-specific exceptions with HTTP status code mapping. Includes base ChromaError, subclasses for common failure modes (InvalidArgument, NotFound, Duplicate, etc.), and a helper to convert to HTTP responses. The pattern is reusable for any API service needing structured error reporting.
Provides custom JSON serialization for Chroma types (embeddings, metadata, where filters) with support for numpy arrays, UUIDs, and datetime objects. Includes a ChromaJSONEncoder and deserialization helpers. Reusable in any Python application needing robust JSON serialization of complex types.
Defines core types for the Chroma API: Embedding, Metadata, Document, IDs, and where filter expressions. Uses TypedDict and Literal for type safety. Reusable as a reference for any vector database client library.
Defines base types including SparseVector, Where, WhereDocument, and metadata containers. Provides validation and serialization methods. Reusable in any embedding database system needing standardized filter and vector representations.
Manages Chroma server configuration from environment variables and settings files. Provides typed settings classes with defaults and validation. Reusable in any Python application needing flexible configuration loading.
Implements a migration system for SQLite databases, applying SQL migration files in order with hash verification. Supports embedded migrations and custom migration directories. Reusable in any Python application needing schema versioning for SQLite.
Defines the abstract SysDB contract for tenant, database, collection, and segment management. Provides a clean interface that can be implemented with different backends (SQLite, Spanner, gRPC). Reusable as a pattern for defining storage abstractions in multi-backend systems.
Provides OpenTelemetry middleware for FastAPI, instrumenting requests with tracing and metrics. Includes automatic span creation, HTTP attribute propagation, and error recording. Reusable in any FastAPI application needing observability.
Provides OpenTelemetry interceptors for gRPC clients and servers, enabling distributed tracing across microservices. Reusable in any gRPC-based system needing end-to-end trace propagation.
Implements metadata segment storage using SQLite with full-text search support via FTS5. Handles metadata filtering, deletion, and batch operations. Reusable as a reference for implementing metadata backends in vector databases.
Implements a local HNSW (Hierarchical Navigable Small World) index for approximate nearest neighbor search. Supports configurable parameters (M, ef_construction, ef_search) and persistence. Reusable as a reference for integrating HNSW into vector databases.
Extends local HNSW with persistence to disk, including save/load operations and incremental updates. Handles versioning and migration of index files. Reusable as a pattern for making in-memory indexes persistent.
Provides batch processing utilities for vector segment operations, including batched insert, update, and delete. Optimizes throughput by grouping operations. Reusable in any system needing efficient batch updates to vector indexes.
Implements a brute-force exact nearest neighbor search index for small datasets. Provides reference implementation for correctness testing. Reusable as a baseline for evaluating approximate search algorithms.
Defines and validates HNSW index parameters (M, ef_construction, ef_search, space) with sensible defaults. Provides parameter conversion and serialization. Reusable in any system using HNSW for vector search.
Sets up the FastAPI server with routes for health check, version, and API endpoints. Configures middleware for CORS, telemetry, and error handling. Reusable as a template for building FastAPI-based services.
Provides an asynchronous API client for Chroma, supporting all operations (create collection, add, query, get, delete) with async/await. Reusable as a reference for building async clients for REST APIs.
Base HTTP client with retry logic, error handling, and request/response serialization. Supports both sync and async modes. Reusable as a foundation for building robust HTTP clients.
Synchronous client for Chroma API, wrapping the HTTP client with convenience methods for collection management and CRUD operations. Reusable as a reference for building synchronous API clients.
Defines collection configuration with Pydantic-based validation, supporting parameters like HNSW space, construction ef, and M. Provides methods for serialization, deserialization, and safe updates. The pattern of validated configuration objects is reusable for any system needing type-safe, evolvable configuration.
Implements conditional HTTP requests using ETags and If-Match headers for optimistic concurrency control. Provides a pattern for building conflict-free distributed operations. Reusable in any REST API needing conditional updates.
Provides an API for managing Chroma server configuration at runtime. Supports getting and setting configuration parameters. Reusable as a pattern for building configuration management APIs.
Async FastAPI client for Chroma, using httpx for HTTP requests. Provides all API operations with proper error handling. Reusable as a reference for building async clients for FastAPI services.
Provides API for managing attached functions (server-side embedding functions). Supports creating, listing, and invoking functions. Reusable as a pattern for extending vector databases with server-side computation.
Python client that uses Rust native bindings for performance-critical operations. Provides a fallback to HTTP client if bindings are not available. Reusable as a pattern for hybrid Python/Rust clients.
Internal API for segment management, used by the server to coordinate segment operations. Provides methods for creating, updating, and deleting segments. Reusable as a reference for building internal APIs in distributed systems.
Client that connects to a shared Chroma system (distributed mode). Provides tenant/database isolation and collection management. Reusable as a pattern for building multi-tenant clients.
Defines type hints for the Chroma API, including request and response models. Uses TypedDict and Literal for precise typing. Reusable as a reference for typing REST API interfaces.
Pydantic model for Chroma collections, including metadata, configuration, and embedding function. Provides methods for CRUD operations. Reusable as a reference for modeling domain entities in Python.
Async version of the collection model, providing async methods for add, query, get, update, delete. Reusable as a reference for building async domain models.
Implements conditional collection transactions with read-before-write semantics. Provides a pattern for building optimistic concurrency control in distributed systems. Reusable in any system needing atomic conditional updates.
Defines the authentication and authorization framework for Chroma, including abstract base classes for auth providers. Supports token-based and basic auth. Reusable as a pattern for building pluggable auth systems.
Implements token-based authentication with configurable token validation. Supports both client and server sides. Reusable as a reference for implementing token auth in Python services.
Implements simple role-based access control (RBAC) for Chroma operations. Defines roles and permissions for collection and tenant operations. Reusable as a pattern for building RBAC systems.
CLI for Chroma using Click, providing commands for running the server, managing collections, and configuration. Reusable as a reference for building CLI tools with Click.
Utility functions for the CLI, including configuration loading, server startup, and client creation. Reusable as a pattern for CLI utility modules.
SQLite implementation of the database abstraction layer, handling connection management, migrations, and query execution. Reusable as a reference for implementing database backends.
gRPC client for the SysDB service, providing access to tenant, database, collection, and segment metadata. Reusable as a reference for building gRPC clients in Python.
gRPC server for the SysDB service, implementing the metadata store interface. Reusable as a reference for building gRPC servers in Python.
Mixin for managing an embeddings queue, providing methods for enqueue, dequeue, and purge. Reusable as a pattern for building queue-based ingestion pipelines.
Mixin for SysDB operations, providing methods for tenant, database, collection, and segment management. Reusable as a pattern for building metadata management mixins.
Abstract executor defining the interface for executing query plans. Provides a contract for local and distributed executors. Reusable as a pattern for building execution engines.
Local executor that runs query plans in-process using the segment manager. Handles count, get, and KNN queries. Reusable as a reference for building single-node query executors.
Distributed executor that delegates query execution to remote workers via gRPC. Handles sharding and result aggregation. Reusable as a reference for building distributed query executors.
Defines expression operators for building query plans, including filter, project, limit, and KNN. Reusable as a pattern for building composable query expressions.
Defines the query plan structure, combining operators into a directed acyclic graph. Reusable as a reference for building execution plan representations.
Utility functions for the ingest pipeline, including batch processing and error handling. Reusable as a pattern for building ingestion systems.
Python client for the distributed log service, providing methods for pushing and pulling log entries. Reusable as a reference for building log service clients.
Simple quota enforcer that limits resource usage based on configurable limits. Reusable as a pattern for building quota enforcement systems.
Simple rate limiter using token bucket algorithm. Reusable as a reference for implementing rate limiting in Python services.
Local segment manager that creates and manages segments in-process. Handles segment lifecycle and caching. Reusable as a reference for building segment management systems.
Distributed segment manager that coordinates segments across multiple workers. Handles segment assignment and replication. Reusable as a reference for building distributed segment management.
LRU cache implementation with configurable size function and eviction callback. Supports segment caching with memory-aware eviction. The design is generic over key and value types, making it reusable for any Python application needing a bounded cache with custom size accounting and eviction hooks.
Provides distributed segment functionality, including memberlist-based segment discovery. Reusable as a reference for building distributed segment systems.
Manages a directory of segments in a distributed system, providing lookup and routing. Reusable as a pattern for building distributed directory services.
Utility functions for batching embedding operations, including splitting and merging batches. Reusable in any system needing batch processing of embeddings.
Provides data loader utilities for loading data into Chroma collections, including support for various input formats. Reusable as a reference for building data ingestion tools.
Utility for safely deleting files with retry logic. Reusable in any Python application needing robust file deletion.
Utility functions for directory operations, including creation, listing, and cleanup. Reusable in any Python application needing file system management.
Implements distance functions (cosine, L2, inner product) for vector comparison. Reusable in any system needing vector distance computation.
Utility functions for FastAPI, including custom middleware and route helpers. Reusable as a reference for building FastAPI utilities.
Generic LRU cache implementation with configurable capacity and eviction callback. Thread-safe via locking. Reusable in any Python application needing a bounded cache with least-recently-used eviction policy.
Utility for generating and parsing message IDs used in the log service. Reusable in any system needing unique message identifiers.
Read-write lock implementation allowing multiple concurrent readers or exclusive writer access. Uses threading primitives. Reusable in any Python application needing fine-grained concurrency control for shared resources.
Python implementation of rendezvous hashing for consistent assignment of items to nodes. Supports weighted nodes and pluggable hash functions. Reusable in any distributed Python system needing deterministic node selection with minimal redistribution on topology changes.
Utility functions for formatting and processing query results. Reusable in any system needing result transformation.
Utility functions for sparse embeddings, including normalization and conversion. Reusable in any system working with sparse vectors.
Utility functions for computing statistics on embeddings and collections. Reusable in any system needing data profiling.
Registry and base classes for embedding functions, providing a plugin system for adding new embedding providers. Reusable as a pattern for building plugin architectures.
Validates embedding function configurations for safety, specifically rejecting 'trust_remote_code' in local model loaders (HuggingFace, SentenceTransformer). Provides a reusable pattern for validating user-supplied configs against security risks before instantiation, applicable to any plugin system that loads external models.
Utility functions for embedding functions, including normalization and batch processing. Reusable in any system needing embedding utilities.
Schema definitions for embedding function configurations, providing JSON Schema-based validation. Reusable as a pattern for building schema-driven configuration systems.
Utility functions for working with embedding function schemas, including validation and merging. Reusable in any system needing JSON Schema utilities.
Registry for embedding function schemas, allowing dynamic lookup and validation. Reusable as a pattern for building schema registries.
Schema and implementation for BM25 tokenizer configuration. Reusable in any system needing BM25 tokenization.
Embedding function for OpenAI models, with configurable model name, API key, and dimensions. Reusable as a reference for building embedding function adapters.
Embedding function for Cohere models, with configurable model and API key. Reusable as a reference for building embedding function adapters.
Embedding function for HuggingFace models, with configurable model name and device. Includes safety validation for trust_remote_code. Reusable as a reference for building embedding function adapters.
Embedding function for Ollama models, with configurable model and base URL. Reusable as a reference for building embedding function adapters.
Embedding function for Jina AI models, with configurable model and API key. Reusable as a reference for building embedding function adapters.
Embedding function for Google models (Gemini, PaLM, Vertex), with configurable model and API key. Reusable as a reference for building embedding function adapters.
Embedding function for Voyage AI models, with configurable model and API key. Reusable as a reference for building embedding function adapters.
Embedding function for Mistral AI models, with configurable model and API key. Reusable as a reference for building embedding function adapters.
Embedding function for Perplexity AI models, with configurable model and API key. Reusable as a reference for building embedding function adapters.
Embedding function for Together AI models, with configurable model and API key. Reusable as a reference for building embedding function adapters.
Embedding function for Cloudflare Workers AI models, with configurable model and API key. Reusable as a reference for building embedding function adapters.
Embedding function for Amazon Bedrock models, with configurable model and AWS credentials. Reusable as a reference for building embedding function adapters.
Embedding function for Baseten models, with configurable model and API key. Reusable as a reference for building embedding function adapters.
Embedding function for Instructor models, with configurable model name and device. Reusable as a reference for building embedding function adapters.
Embedding function for Nomic AI models, with configurable model and API key. Reusable as a reference for building embedding function adapters.
Embedding function for OpenCLIP models, supporting multimodal embeddings (text and images). Reusable as a reference for building multimodal embedding functions.
Embedding function for Roboflow models, with configurable model and API key. Reusable as a reference for building embedding function adapters.
Embedding function for SentenceTransformer models, with configurable model name and device. Includes safety validation for trust_remote_code. Reusable as a reference for building embedding function adapters.
Embedding function for Text2Vec models, with configurable model name. Reusable as a reference for building embedding function adapters.
Embedding function using ONNX runtime with MiniLM-L6-v2 model. Provides a lightweight, local embedding option. Reusable as a reference for building ONNX-based embedding functions.
BM25 embedding function for sparse retrieval. Implements BM25 scoring with configurable parameters. Reusable as a reference for building sparse embedding functions.
Chroma's optimized BM25 embedding function with improved tokenization and scoring. Reusable as a reference for building optimized sparse embedding functions.
Embedding function for Chroma Cloud's Qwen model, with configurable API key and base URL. Reusable as a reference for building cloud embedding function adapters.
Embedding function for Chroma Cloud's SPLADE model, producing sparse embeddings. Reusable as a reference for building sparse embedding function adapters.
Adapter for using LangChain embedding functions with Chroma. Reusable as a reference for building integration adapters.
Embedding function using FastEmbed for sparse embeddings. Reusable as a reference for building sparse embedding function adapters.
Embedding function for HuggingFace sparse models (e.g., SPLADE). Reusable as a reference for building sparse embedding function adapters.
Embedding function for Morph models, with configurable model and API key. Reusable as a reference for building embedding function adapters.
Embedding function for Morph models, with configurable model and API key. Reusable as a reference for building embedding function adapters.