Skip to content

feat: add ChromaDB hosting and client integrations#1132

Open
ali-Hamza817 wants to merge 6 commits intoCommunityToolkit:mainfrom
ali-Hamza817:feature/chromadb-integration
Open

feat: add ChromaDB hosting and client integrations#1132
ali-Hamza817 wants to merge 6 commits intoCommunityToolkit:mainfrom
ali-Hamza817:feature/chromadb-integration

Conversation

@ali-Hamza817
Copy link

Pull Request: Add ChromaDB Hosting and Client Integrations

Summary

This PR adds a new hosting and client integration for ChromaDB, an open-source vector database essential for AI and RAG applications.

Features

  • Hosting Integration: Easily add ChromaDB as a container resource to your .NET Aspire orchestration using builder.AddChroma("chroma").
  • Client Integration: Provides a simple way to register ChromaClient in your application via builder.AddChromaClient("chroma").
  • Keyed Services: Native support for keyed client registration via builder.AddKeyedChromaClient("chroma").
  • Persistence: Built-in support for data persistence using both Docker volumes and bind mounts.
  • Health Checks: Automatic health check registration using Chroma's GetVersion() API.
  • Documentation: Comprehensive XML docs and README.md files for both packages.

PR Checklist

  • Created a feature/dev branch in your fork
  • Based off latest main branch of toolkit
  • PR doesn't include merge commits
  • New integration
    • Docs are written
    • Added description of major feature to project description for NuGet package
  • Tests for the changes have been added
  • Contains NO breaking changes
  • Every new API has full XML docs
  • Code follows all style conventions

Additional information

Verified with 8 unit tests covering hosting resource creation, endpoint configuration, persistence volumes, DI registration, and health checks.

This contribution adds support for ChromaDB as a .NET Aspire resource, including:
- Hosting integration for containerized ChromaDB
- Client integration with health checks and keyed service support
- Persistence support via volumes and bind mounts
- Comprehensive unit tests and documentation
@ali-Hamza817
Copy link
Author

@dotnet-policy-service agree

Copy link
Member

@aaronpowell aaronpowell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to have an example app included as part of the PR and a test covering that the sample starts and the resource becomes health.

Ideally, the sample should also actually use Chroma, so some kind of basic CRUD just to allow for more advanced testing and demonstrations.

You also need to add the test projects to the tests.yml workflow - we have a script in eng that will generate the properly formatted test list if you'd like.

But overall, a solid looking integration set.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is auto-generated on merging to main, so it should be removed.


private static ChromaClient CreateClient(IServiceProvider sp, ChromaClientSettings settings, string connectionName)
{
if (settings.Endpoint == null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (settings.Endpoint == null)
if (settings.Endpoint is null)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is generated when merging to main so it should be removed.

Comment on lines +13 to +15
public ChromaResource(string name) : base(name)
{
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use a primary constructor to be consistent with the coding style

- Removed auto-generated api files.
- Refactored ChromaResource to use a primary constructor.
- Corrected style for null checks (is null).
- Added example app with CRUD operations in examples/chromadb.
- Added integration tests for health and CRUD verification.
- Updated tests.yml workflow to include new tests.
Copilot AI review requested due to automatic review settings February 26, 2026 08:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive ChromaDB hosting and client integrations to the Aspire Community Toolkit, enabling developers to easily orchestrate and consume ChromaDB vector database services in their .NET Aspire applications.

Changes:

  • New hosting integration package (CommunityToolkit.Aspire.Hosting.Chroma) providing resource orchestration for ChromaDB containers with configurable persistence options
  • New client integration package (CommunityToolkit.Aspire.Chroma) providing ChromaClient registration with health checks and configuration support
  • Comprehensive test coverage including unit tests, integration tests, and AppHost tests
  • Example application demonstrating end-to-end usage with collection creation and querying

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/CommunityToolkit.Aspire.Hosting.Chroma/ChromaResource.cs Defines the ChromaDB container resource with connection string support
src/CommunityToolkit.Aspire.Hosting.Chroma/ChromaBuilderExtensions.cs Provides AddChroma extension method and persistence configuration helpers
src/CommunityToolkit.Aspire.Hosting.Chroma/ChromaContainerImageTags.cs Defines ChromaDB container image details (chromadb/chroma:0.5.0)
src/CommunityToolkit.Aspire.Chroma/AspireChromaExtensions.cs Implements ChromaClient DI registration with keyed service support
src/CommunityToolkit.Aspire.Chroma/ChromaHealthCheck.cs Provides health check implementation using GetVersion API
src/CommunityToolkit.Aspire.Chroma/ChromaClientSettings.cs Configuration model supporting endpoint, health checks, and timeout settings
tests/CommunityToolkit.Aspire.Hosting.Chroma.Tests/AddChromaTests.cs Unit tests for hosting resource configuration and annotations
tests/CommunityToolkit.Aspire.Hosting.Chroma.Tests/AppHostTests.cs Integration tests verifying ChromaDB startup and API service interaction
tests/CommunityToolkit.Aspire.Chroma.Tests/ChromaClientExtensionsTests.cs Unit tests for client registration and health check behavior
examples/chromadb/CommunityToolkit.Aspire.Hosting.Chroma.AppHost/Program.cs Example AppHost orchestrating ChromaDB and API service
examples/chromadb/CommunityToolkit.Aspire.Hosting.Chroma.ApiService/Program.cs Example API service demonstrating ChromaDB operations
Directory.Packages.props Adds ChromaDB.Client 1.0.0 package reference
CommunityToolkit.Aspire.slnx Adds new projects to solution
.github/workflows/tests.yaml Adds test projects to CI workflow

public bool DisableHealthChecks { get; set; }

/// <summary>
/// Gets or sets a integer value that indicates the ChromaDB health check timeout in milliseconds.
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar issue: "a integer" should be "an integer".

Suggested change
/// Gets or sets a integer value that indicates the ChromaDB health check timeout in milliseconds.
/// Gets or sets an integer value that indicates the ChromaDB health check timeout in milliseconds.

Copilot uses AI. Check for mistakes.

namespace CommunityToolkit.Aspire.Chroma.Tests;

public class AspireChromaClientExtensionsTests
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class name AspireChromaClientExtensionsTests does not match the file name ChromaClientExtensionsTests.cs. For consistency with the codebase (e.g., AspireMeilisearchClientExtensionsTest), consider either:

  1. Renaming the class to ChromaClientExtensionsTests to match the file name, or
  2. Renaming the file to AspireChromaClientExtensionsTests.cs to match the class name.

The former approach (matching the file name without the "Aspire" prefix) appears more common in client integration tests.

Suggested change
public class AspireChromaClientExtensionsTests
public class ChromaClientExtensionsTests

Copilot uses AI. Check for mistakes.
Copy link
Member

@aaronpowell aaronpowell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code-wise, this looks great, thanks for the contribution!

Copy link
Member

@aaronpowell aaronpowell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some test failures and then it should be good to merge

var appBuilder = DistributedApplication.CreateBuilder();

appBuilder.AddChroma("chroma")
.WithDataBindMount("C:/chroma/data");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to set a relative path here so it doesn't error on CI

@aaronpowell
Copy link
Member

Looks like

var rns = fixture.ResourceNotificationService;
is still failing

@ali-Hamza817
Copy link
Author

ali-Hamza817 commented Mar 8, 2026

@aaronpowell
3 workflows waiting for approval please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants