Skip to content

Choose a Cratis Chronicle application host

Choose a console app, .NET Worker Service, or ASP.NET Core app to host your Cratis Chronicle client. The client connects to a separate kernel process that stores events and coordinates processing. Choosing an application host does not choose how you deploy that kernel.

Start with a console app to learn the event flow, a worker for background processing, or ASP.NET Core for HTTP endpoints. Then start a local kernel using Docker or Aspire below. Your first checkpoint is a healthy kernel and an accessible workbench; the host-specific guide will take you through recording an event and reading the state built from it.

The Chronicle kernel — run it your way

Your application host — pick a level

Arc application layer — commands, queries, proxies

Console app — explicit client

Worker service — generic host + DI

ASP.NET Core — web endpoints + DI

Local Docker / Compose

Aspire AppHost

Managed by your platform

The app host decides how much wiring you own

Section titled “The app host decides how much wiring you own”
Host or application layer What you write What Chronicle supplies Use it when
Console new ChronicleClient(...), GetEventStore(...), append events yourself Default artifact discovery; you create the client and manage its lifetime. You are learning, debugging a small reproduction, or writing a script.
Worker Service Host.CreateApplicationBuilder, AddCratisChronicle(...), a BackgroundService DI registration and artifact discovery for reactors, reducers, and projections. You process events, run background workflows, or keep derived state updated.
ASP.NET Core WebApplication.CreateBuilder, AddCratisChronicle(...), UseCratisChronicle() DI registration, artifact discovery, and request-pipeline integration. You expose HTTP endpoints, controllers, or minimal APIs that append events.
Arc + Chronicle Arc commands and queries; Chronicle-backed command return values and projections Arc’s command/query pipeline plus Chronicle event appending, identity, tenancy, and read-model integration. You want a typed full-stack CQRS app with generated TypeScript proxies.

Artifacts are the definitions Chronicle discovers in your code: event types, projections that build queryable state, reducers that compute state from events, and reactors that run code when events arrive. You can reuse these domain definitions across hosts. Client startup and service registration change with the host, so follow its guide rather than copying the entire application setup.

The kernel runs separately from your application and needs storage. For local development, the bundled development image supplies both. For a team or production environment, choose who owns the kernel, storage, credentials, and certificates:

How you run it What it gives you Use it when
Local Docker One kernel reachable at chronicle://localhost:35000, with the workbench at https://localhost:35000 on the same port. You need the fastest local feedback loop.
Docker Compose Chronicle and storage as named services in a local or CI topology. You want repeatable local infrastructure for a team or pipeline.
Aspire AppHost Chronicle as an Aspire resource with endpoints and storage references wired into dependent projects. Your .NET solution already uses Aspire to compose services locally.
Production-managed kernel A Chronicle container, durable storage, TLS, secrets, health checks, and versioned deployment owned by your platform. The application should only know the Chronicle connection string and credentials.

Here, “managed” means your team or platform operator runs the kernel and its storage. It does not name a separate client mode or a hosted Cratis service. Your application connects to that kernel using its configured endpoint and credentials.

For the host guides, start a local kernel using one of the options below.

The kernel must be running and reachable before your application can append an event. You can reuse the same local kernel across the host guides; start it again whenever it is no longer running.

The latest-development image includes MongoDB. With Docker running, start the kernel and publish its ports only on your machine:

Terminal window
docker run -d --name chronicle \
-p 127.0.0.1:35000:35000 \
-p 127.0.0.1:27017:27017 \
cratis/chronicle:latest-development

The 127.0.0.1: prefixes publish both ports on this machine only. That matters here: the development workbench accepts well-known credentials and the bundled MongoDB has no authentication. Wait for the kernel to report Healthy before connecting to it, and remove it with docker rm -f chronicle when you are done:

Terminal window
curl --insecure --fail --retry 30 --retry-all-errors --retry-delay 1 https://localhost:35000/health

The kernel serves client connections and the workbench over TLS on port 35000. MongoDB uses a separate port:

Port What it is
35000 The kernel endpoint your app connects to (chronicle://localhost:35000), and the Chronicle workbench — a web UI for browsing your event store — at https://localhost:35000.
27017 The bundled MongoDB, where projections write their read models.

Use this bundled MongoDB setup for the host guides, which query MongoDB read models directly. If you’d rather run against a database you already have — or a different engine entirely — read on; otherwise jump to picking your host guide.

The latest-development-slim image leaves the database out, so you point Chronicle at one you run yourself. Two environment variables tell it where to go:

  • Cratis__Chronicle__Storage__Type
  • Cratis__Chronicle__Storage__ConnectionDetails

The Compose files below bring up the kernel and a database together. Pick the tab for your engine.

Chronicle uses MongoDB transactions and change streams, so MongoDB must run as a replica set (or a sharded cluster) — a standalone mongod won’t do. This file initializes a single-node replica set for local development:

services:
chronicle:
image: cratis/chronicle:latest-development-slim
depends_on:
- mongodb
- mongodb-init
environment:
- Cratis__Chronicle__Storage__Type=MongoDB
- Cratis__Chronicle__Storage__ConnectionDetails=mongodb://mongodb:27017/?directConnection=true
ports:
- 127.0.0.1:35000:35000
mongodb:
image: mongo:8.2
command: ["mongod", "--replSet", "rs0", "--bind_ip_all"]
ports:
- 127.0.0.1:27017:27017
mongodb-init:
image: mongo:8.2
depends_on:
- mongodb
restart: "no"
command:
- /bin/bash
- -lc
- |
until mongosh --host mongodb --quiet --eval "db.adminCommand('ping')" >/dev/null 2>&1; do
sleep 1
done
mongosh --host mongodb --quiet --eval "
try {
rs.status();
} catch (e) {
rs.initiate({
_id: 'rs0',
members: [{ _id: 0, host: 'localhost:27017' }]
});
}"

Why this setup:

  • host: 'localhost:27017' makes the replica set topology usable from host tools (for example mongosh and Compass) when they connect to mongodb://localhost:27017/?replicaSet=rs0.
  • Chronicle still reaches MongoDB over the Docker network (mongodb:27017) and uses directConnection=true to avoid following the advertised host back to localhost inside the Chronicle container.
  • directConnection=true does not disable transactions; transactions still work because MongoDB is running as a replica set.
  • If your existing data volume was initialized with a different replica-set host, run docker compose down -v (or wipe the MongoDB data volume) before starting again so rs.initiate() can apply the new host.

Bring any of these up the usual way, in the background:

Terminal window
docker compose up -d

Every published port in these files is bound to 127.0.0.1, because the credentials in them are development placeholders. Drop the prefix only on a network you trust, and never with these credentials. docker compose down stops the stack; docker compose down -v also deletes its data volumes.

Want local observability too — logs, traces, and metrics next to the kernel? The Docker Compose hosting guide adds the Aspire dashboard to the same topology.

The Chronicle workbench is the kernel’s web UI for inspecting event stores. Open https://localhost:35000 and sign in with the development credentials (username Admin, password ChangeMeNow!). The development kernel generates a self-signed TLS certificate, so your browser will warn you. Accept it only for this local development endpoint.

A healthy response from the earlier health check and a successful workbench sign-in confirm that the local kernel is reachable. They do not yet confirm an application append. After following a host guide, select its Quickstart event store and open Sequences to find the book event you recorded.

If your solution uses Aspire, add Chronicle to its AppHost instead of starting a separate Compose stack. The AppHost describes the services to run and the connections between them. Add the Cratis.Chronicle.Aspire package to that project:

Terminal window
dotnet add package Cratis.Chronicle.Aspire

In development run mode, AddCratisChronicle() uses the image with bundled MongoDB. Reference the Chronicle resource from the application that needs to connect to it:

using Aspire.Hosting;
public static class GetStartedHostingBasicAppHost
{
public static void ConfigureAppHost(string[] args)
{
var builder = DistributedApplication.CreateBuilder(args);
var chronicle = builder.AddCratisChronicle();
// Reference any of your application's projects the same way -
// builder.AddProject<Projects.MyApi>("api") when Projects.MyApi is generated from your solution
builder.AddContainer("api", "my-org/my-api")
.WithReference(chronicle);
builder.Build().Run();
}
}

View C# snippet source on GitHub

To choose a database, pass a configure callback. Aspire keeps the development image in run mode and uses the production image when publishing, regardless of the callback. The With* method you pick sets the kernel’s storage type and connection string from the resource you hand it — the same two environment variables you saw in the Compose files, now derived from your app model instead of hand-written:

using Aspire.Hosting;
using Aspire.Hosting.ApplicationModel;
using Cratis.Chronicle.Aspire;
public static class GetStartedHostingMongoDatabase
{
public static IResourceBuilder<ChronicleResource> ConfigureAppHost(IDistributedApplicationBuilder builder)
{
var mongo = builder.AddConnectionString("chronicle-mongo");
return builder.AddCratisChronicle("chronicle", c => c.WithMongoDB(mongo));
}
}

View C# snippet source on GitHub

mongo can be any resource with a connection string — a MongoDB Atlas connection string as shown, or a container added directly in the AppHost with builder.AddMongoDB("mongo").

WithReference(chronicle) hands your application projects a chronicle://host:port connection string pointing at the kernel’s gRPC endpoint — no hardcoded ports. The Aspire integration guide covers the rest: exposed endpoints, compliance key storage with HashiCorp Vault or Azure Key Vault, and the full AppHost walkthrough.

With the local Docker setup, connect to chronicle://localhost:35000. With Aspire, use the endpoint supplied by the resource reference. Choose the guide for your application:

  • Console: create the client explicitly and record your first book event.
  • Worker Service: append from background work and keep a process running for reactors.
  • ASP.NET Core: record a borrowing event from an HTTP endpoint.

If you want to understand the event flow before choosing a host, Get started introduces appending events, projecting state, and reacting to events across the available clients.

If you are… Start with Then move to
Learning Chronicle from scratch Get started, then Console Tutorial
Adding events to an existing web API Run Chronicle locally, then ASP.NET Core Production hosting
Building background event processors Worker Service Reactors and Reducers
Building a full-stack Cratis app Arc + Chronicle Build a full-stack feature
Preparing a team environment Docker Compose or Aspire Production hosting and Data Protection Key Encryption

If you are still unsure, start with the console guide. It lets you check an append and a read model before adding HTTP request handling or background-service lifetime.