---
title: The Chronicle Web template
editUrl: https://github.com/Cratis/Templates/edit/main/Documentation/chronicle-web/index.mdx
description: Scaffold a minimal C# ASP.NET Core service with the Chronicle Web template, append events over HTTP, read projections and run a logging reactor.
lastUpdated: 2026-11-05T00:00:00.000Z
---


The `cratis-chronicle-web` template lets you try Chronicle through two ASP.NET Core endpoints: one appends an event and the other reads its projected model. A reactor logs the event's message. Choose this starting point when you want to own the HTTP surface without Arc or a frontend.

You need the .NET 10 SDK and Docker with the Compose plugin. If the template package is not installed, [Install the templates](/templates/getting-started/#install-the-templates) before creating the project.

```bash
dotnet new cratis-chronicle-web -n MyApi
cd MyApi
```

The example creates a MyApi directory. Keep the infrastructure and application commands in that directory, alongside the generated compose file and project.

## Options

| Option | Values | Default |
| --- | --- | --- |
| `--Database` | `MongoDB`, `PostgreSQL`, `MsSql`, `SQLite` | `MongoDB` |
| `--Framework` | `net10.0` | `net10.0` |
| `--SkipAiUpdateInstructions` | `true`, `false` | `false` |

The template scaffolds a Chronicle **client**. `--Database` changes only where the Chronicle kernel in `docker-compose.yml` stores its data.

## What you get

In `Program.cs`, the root endpoint appends `TestEvent`, while the projection endpoint reads `TestProjection`. `TestReactor` logs the event's message; its log line is a different observation from the projection response. This setup is the top of the file, with those types defined below it:

```csharp
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.

## Run it

Use this development configuration only on a trusted development machine; its Chronicle client uses development credentials. From the MyApi directory, start the infrastructure and then the app. Compose starts the containers in the background, while the web app stays in this terminal so you can read its reactor output:

```bash
docker compose up -d
dotnet run
```

The app listens on `http://localhost:5000`. The sample appends on a `GET` to keep the demo to one `curl`. Use `POST` for anything that changes state in your own endpoints.

In another terminal, call the two endpoints and compare the HTTP responses with the first terminal's reactor output:

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

A successful first call returns the append result with `"isSuccess":true`. The reactor logs `Received event with message: Hello, Chronicle!` in the app terminal. The projection endpoint reads the projected instances, for example `[{"message":"Hello, Chronicle!","eventSource":"…"}]`. Use that read endpoint, not the reactor line, to inspect the read model's contents. If the read is empty, repeat the projection request when checking again; calling the root endpoint again appends another event.

Stop the foreground web app before stopping or removing its containers. With the default MongoDB setup, removing the Chronicle container deletes its stored events and read models. To pause the containers and keep that data, use `docker compose stop`. Use `docker compose down` only when you want to remove the containers and their default MongoDB data.

## What it is for

Grow this sample when you want to write the HTTP endpoints around Chronicle yourself. Start by changing the sample event and checking both the reactor output and the projection response. When you want model-bound commands and queries with generated routes and TypeScript proxies, use the [Cratis Web Application](/templates/cratis-web/) template.

## AI assistance

AI assistance is optional; the HTTP sample runs without installing agent guidance. The scaffolded project includes a `.cratis/ai.json` selecting the `cratis/application/chronicle-dotnet` profile with the C# language. If you want that guidance, install the [Cratis CLI](/cli/) and run this from the MyApi project root:

```bash
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](/cli/ai/) for the full command reference.
