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.
Pick a client
Section titled “Pick a client”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 |
Start Chronicle
Section titled “Start Chronicle”-
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-developmentThe
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. -
The kernel listens on
chronicle://localhost:35000, and the workbench runs onhttps://localhost:35000, the same TLS-secured port. The bundled MongoDB on port27017stores the materialized read models; the guides below query it directly. Wait for startup to complete. This command retries the health check and printsHealthywhen the kernel reports itself ready:Wait for readiness curl --insecure --fail --retry 30 --retry-all-errors --retry-delay 1 https://localhost:35000/health--insecureis 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.
The Chronicle loop
Section titled “The Chronicle loop”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.
In event modeling notation, the tiny example below is:
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:
using var client = new ChronicleClient();var eventStore = await client.GetEventStore("ChronicleConsole");
await eventStore.EventLog.Append("some-event-source", new TestEvent("Hello world!"));val client = ChronicleClient(ChronicleOptions.development())val eventStore = client.getEventStore("ChronicleConsole")
eventStore.eventLog.append("some-event-source", TestEvent("Hello world!"))import io.cratis.chronicle.ChronicleOptions;import io.cratis.chronicle.java.BlockingChronicleClient;
class Main { void run() { var client = BlockingChronicleClient.connect(ChronicleOptions.development()); var eventStore = client.getEventStore("ChronicleConsole");
eventStore.getEventLog().append("some-event-source", new TestEvent("Hello world!")); }}children = [ {Chronicle.Client, connection_string: Chronicle.Connections.ConnectionString.development(), event_store: "chronicle-console", otp_app: :my_app}]
Supervisor.start_link(children, strategy: :one_for_one)alias Chronicle.Connections.Lifecycle
# The client registers in the background; appends return {:error, :not_connected} until then.:ok = Lifecycle.wait_until(Lifecycle.name_for(Chronicle.Client), :registered)
:ok = Chronicle.append("some-event-source", %MyApp.Events.TestEvent{ message: "Hello world!" })import 'reflect-metadata';import { ChronicleClient, ChronicleOptions } from '@cratis/chronicle';
const client = new ChronicleClient(ChronicleOptions.development());const eventStore = await client.getEventStore('ChronicleConsole');
await eventStore.eventLog.append('some-event-source', new TestEvent('Hello world!'));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:
[EventType]public record TestEvent(string Message);import io.cratis.chronicle.events.EventType
@EventTypedata class TestEvent(val message: String)import io.cratis.chronicle.events.EventType;
@EventTyperecord TestEvent(String message) {}defmodule MyApp.Events.TestEvent do use Chronicle.Events.EventType, id: "test-event-v1"
defstruct [:message]endimport { eventType } from '@cratis/chronicle';import { field } from '@cratis/fundamentals';
@eventType()class TestEvent { @field(String) message: string; constructor(message: string) { this.message = message; }}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:
[FromEvent<TestEvent>]public record TestProjection( string Message, [SetFromContext<TestEvent>(nameof(EventContext.EventSourceId))] string EventSource);import io.cratis.chronicle.projections.FromEventimport io.cratis.chronicle.readModels.ReadModel
@ReadModel@FromEvent(TestEvent::class)data class TestProjection( val message: String = "")import io.cratis.chronicle.projections.FromEvent;import io.cratis.chronicle.readModels.ReadModel;
@ReadModel@FromEvent(eventType = TestEvent.class)record TestProjection(String message) { TestProjection() { this(""); }}defmodule MyApp.ReadModels.TestProjection do use Chronicle.ReadModels.ReadModel
alias MyApp.Events.TestEvent
defstruct [:id, :message]
from TestEvent, set: [ id: :event_source_id, message: :message ]endimport { fromEvent } from '@cratis/chronicle';import { field } from '@cratis/fundamentals';
@fromEvent(TestEvent)export class TestProjection { // @field lets the client read the property back when you query the read model. @field(String) message = '';}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:
public class TestReactor : IReactor{ public Task React(TestEvent @event) { Console.WriteLine($"Received event with message: {@event.Message}"); return Task.CompletedTask; }}import io.cratis.chronicle.observation.Reactor
@Reactorclass TestReactor { fun react(event: TestEvent) { println("Received event with message: ${event.message}") }}import io.cratis.chronicle.observation.Reactor;
@Reactorclass TestReactor { void react(TestEvent event) { System.out.println("Received event with message: " + event.message()); }}defmodule MyApp.Reactors.TestReactor do use Chronicle.Reactors.Reactor
alias MyApp.Events.TestEvent
@handles TestEvent
@impl true def handle(%TestEvent{} = event, _context) do IO.puts("Received event with message: #{event.message}") :ok endendimport { onceOnly, reactor } from '@cratis/chronicle';
@reactor()class TestReactor { @onceOnly() async testEvent(event: TestEvent): Promise<void> { console.log(`Received event with message: ${event.message}`); }}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.
Inspect it in the workbench
Section titled “Inspect it in the workbench”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.
Where to go next
Section titled “Where to go next”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.