Skip to content

The Chronicle Web template

The cratis-chronicle-web template is a minimal ASP.NET Core application connected to Chronicle. It is deliberately small: two endpoints, one event, one projection. You get the server-side skeleton without Arc, without a frontend, and without anything else in the way.

Terminal window
dotnet new cratis-chronicle-web -n MyApi

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.

Program.cs wires Chronicle into ASP.NET Core and maps two minimal API endpoints. This is the top of the file; the TestEvent, TestProjection, and TestReactor types follow below it:

var builder = WebApplication.CreateBuilder(args)
.AddCratisChronicle();
var app = builder.Build();
app.UseCratisChronicle();
app.MapGet("/", (IEventLog log) => log.Append(Guid.NewGuid().ToString(), new TestEvent("Hello, Chronicle!")));
app.MapGet("/projection", (IReadModels readModels) => readModels.GetInstances<TestProjection>());
await app.RunAsync();

appsettings.json names the event store after your project and connects to the local development kernel with the development client credentials.

Start the infrastructure and the app:

Terminal window
docker compose up -d
dotnet run

The app listens on http://localhost:5000. In another terminal, call the two endpoints:

Terminal window
curl http://localhost:5000/ # appends a TestEvent to the log
curl http://localhost:5000/projection # reads the projected read model

The first call returns the append result with "isSuccess":true, and the app logs Received event with message: Hello, Chronicle! from the reactor. The second returns every projected instance, for example [{"message":"Hello, Chronicle!","eventSource":"…"}].

The sample appends on a GET to keep the demo to one curl. Use POST for anything that changes state in your own endpoints.

Use this template when you know you want Chronicle inside an ASP.NET Core service and you would rather grow the application yourself. When you want model-bound commands and queries with routes and TypeScript proxies handled for you, use 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.