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 — 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

These templates scaffold a Chronicle client — pass --Database (MongoDB by default, or PostgreSQL, MsSql, SQLite) to choose which database the Chronicle kernel in docker-compose.yml persists to.

A Program.cs with the Cratis middleware wired and two minimal API endpoints:

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>());
app.RunAsync();

Start the infrastructure, run the app, and hit the two endpoints:

Terminal window
docker-compose up -d
dotnet run
curl http://localhost:5000/ # appends a TestEvent to the log
curl http://localhost:5000/projection # reads the projected read model

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, that is the Cratis Web Application template.

The scaffolded project includes a .cratis/ai.json with the Cratis AI profiles, languages, and coding agent harnesses for this template — the Chronicle-on-.NET selection. 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 coding agents you selected — AGENTS.md instructions plus .claude/, .cursor/, .github/, .opencode/, and .pi/ integration — and records what it installed in .cratis/ai.manifest.json. dotnet new prints this reminder after scaffolding, and re-running the command only refreshes Cratis-managed files, never yours. See the CLI AI documentation for the full command reference.