Skip to content

The Chronicle Console template

The cratis-chronicle-console template is the smallest complete Chronicle application: a console project that connects to a running Chronicle, appends an event, and shows the event flowing through a projection and a reactor.

Terminal window
dotnet new cratis-chronicle-console -n MyConsole

You need the .NET 10 SDK and Docker with the Compose plugin.

OptionValuesDefault
--DatabaseMongoDB, PostgreSQL, MsSql, SQLiteMongoDB
--Frameworknet10.0net10.0
--SkipAiUpdateInstructionstrue, falsefalse

The template scaffolds a Chronicle client. --Database changes only where the Chronicle kernel in docker-compose.yml stores its data; the console code is the same for every choice.

A single Program.cs holds the whole story:

  • A ChronicleClient created without arguments, which connects to the local development kernel (chronicle://localhost:35000 with the development client credentials), and an event store named after your project.
  • A [EventType] record, TestEvent: the fact your application produces.
  • A model-bound [FromEvent<TestEvent>] read model, TestProjection, kept in sync by Chronicle.
  • An IReactor, TestReactor, that prints each TestEvent it observes.

Start the infrastructure, then run the app from an interactive terminal:

Terminal window
docker compose up -d
dotnet run

The app appends one TestEvent and prints:

Received event with message: Hello world!

It then waits for a key press so the reactor has time to run; press any key to exit. Because it reads a key, run it in a terminal rather than with redirected input. Each run appends another event to the same event source, some-event-source.

When you are done, docker compose down removes the containers. With the default MongoDB setup, the events are stored inside the Chronicle container and are removed with it.

This template is the fastest way to check that your machine, your container, and your client packages agree, and the cleanest place to experiment with events, projections, and reactors without an HTTP layer in the way. When you are ready for commands, queries, and a frontend, move to the Cratis Web Application template.

The scaffolded project includes a .cratis/ai.json selecting the cratis/application/chronicle-dotnet profile with the C# language. Make sure the Cratis CLI is installed, then run:

Terminal window
cratis ai update

That installs the AI rules, skills, and harness integration for the selected coding agents (AGENTS.md plus .claude/, .cursor/, .github/, .opencode/, and .pi/) and records what it installed in .cratis/ai.manifest.json. dotnet new prints this reminder after scaffolding; cratis new runs the update for you. Running it again refreshes only Cratis-managed files. See the CLI AI documentation for the full command reference.