Skip to content

Get started with Cratis Chronicle

To start with Cratis Chronicle, run its kernel locally, connect a client, and append an event: a fact your application records. Chronicle can turn that history into read models you query and deliver events to application code for actions such as notifications. This guide starts the kernel and explains how those pieces fit together.

You need Docker for the local server and the language tools required by your chosen client. After the health check succeeds, follow that client’s setup guide to create an application. The shared examples below explain the model; they do not form a runnable application on their own.

Choose the client that matches your application and keep its guide open while you start the kernel. For a new C# project, the host quickstarts include project creation and package installation; the .NET client guide covers connection and configuration details. The clients share a server protocol, not identical APIs or capabilities.

Client Setup guide
.NET Console app, ASP.NET Core app, or Worker Service; .NET client configuration
Kotlin Kotlin client
Java Kotlin/JVM client
Elixir Elixir client
TypeScript TypeScript client
  1. Chronicle application code connects to a running Chronicle kernel. For local development, use the development image. It bundles MongoDB, so Docker is the only prerequisite:

    Start Chronicle
    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. The development image’s workbench accepts well-known credentials and its MongoDB has no authentication, so keep both off shared networks.

  2. The kernel listens on chronicle://localhost:35000, and the workbench runs on https://localhost:35000, the same TLS-secured port. The bundled MongoDB on port 27017 stores the materialized read models; the guides below query it directly. Wait for startup to complete. This command retries the health check and prints Healthy when the kernel reports itself ready:

    Wait for readiness
    curl --insecure --fail --retry 30 --retry-all-errors --retry-delay 1 https://localhost:35000/health

    --insecure is there because the development image serves a self-signed certificate.

If you need Docker Compose, Aspire, a separate database, or production-style hosting, use Choose an application host model.

After setup, follow one fact through the system: append it to the event log, derive a view with a projection, and handle it with a reactor. The projection and reactor consume the event independently; a reactor does not wait for the projection to finish.

Append a fact

Event log

Projection

Read model

Reactor

Side effect

In event modeling notation, the tiny example below is:

UI/A: DemoC/RM: DemoStream: Demo
TestEvent

message: string
TestProjection
TestReactor

First, connect a client and choose an event store, the named home for your application’s events. An append adds a fact to its event log. The client-flow example records a TestEvent carrying a message:

Program.cs
using var client = new ChronicleClient();
var eventStore = await client.GetEventStore("ChronicleConsole");
await eventStore.EventLog.Append("some-event-source", new TestEvent("Hello world!"));

View C# snippet source on GitHub

The append records the fact before projections or reactors consume it. To use the example in your application, you also need the event declaration and the registration described in your client’s setup guide.

The event declaration defines the data you record. Here, TestEvent carries a message; each client expresses that same fact in its own syntax:

The event - an immutable fact
[EventType]
public record TestEvent(string Message);

View C# snippet source on GitHub

Next, a projection maps that event onto a read model, state shaped for a query. This example copies the message into TestProjection. Chronicle writes materialized read models to a sink, its configured read-model storage:

The projection - builds queryable state
[FromEvent<TestEvent>]
public record TestProjection(
string Message,
[SetFromContext<TestEvent>(nameof(EventContext.EventSourceId))] string EventSource);

View C# snippet source on GitHub

A reactor runs application code when the event arrives. TestReactor handles the same TestEvent; use this pattern when a recorded fact should trigger a notification or another action:

The reactor - does something when it happens
public class TestReactor : IReactor
{
public Task React(TestEvent @event)
{
Console.WriteLine($"Received event with message: {@event.Message}");
return Task.CompletedTask;
}
}

View C# snippet source on GitHub

The C# handler prints Received event with message: Hello world! when it receives the event from the client-flow example. That output confirms the reaction ran; it does not tell you whether the projection has caught up.

Follow your client’s registration instructions before running the example. Some hosts discover annotated types; others require you to register modules, classes, or functions explicitly. Declaring a projection or reactor alone is not enough in every host.

The development image includes the Chronicle workbench — a web UI for inspecting event stores. Open https://localhost:35000 and log in with the development credentials: username admin, password ChangeMeNow!. In development the port uses a self-signed certificate, so accept your browser’s certificate warning the first time.

After you complete a client or host quickstart, choose the event store that guide uses and open Sequences to inspect its events. Append more events and watch the sequence grow. That log is the source of truth your projections and reactors read from.

If you have only started the kernel, continue with the console, ASP.NET Core, or Worker Service quickstart to create a C# application. For another language, use the Kotlin/JVM, Elixir, or TypeScript setup guide.

Once your application connects, the library tutorial walks through defining events, deriving a catalog, and reacting to a returned book. If you need a different deployment setup first, choose an application host model. For terminology or design decisions, return to Concepts or Why Event Sourcing.