Cratis Arc C# backend: build commands and queries
Cratis Arc exposes C# commands and queries as HTTP endpoints and generates TypeScript proxies for the frontend. Commands change state; queries read it. Keeping those responsibilities separate is Command Query Responsibility Segregation (CQRS). You can express each as a model-bound record, with its behavior beside its inputs, rather than maintaining a controller and a separate API model.
You still write the business behavior and configure validation, authorization, and proxy generation. With Chronicle, commands can append events and queries can read the models built from them. A slice that only needs current state can instead write through MongoDB or Entity Framework Core; Arc does not require event sourcing.
Start here
Section titled “Start here”Follow Getting started to build your first command and query. If you already use MediatR or MVC, start with the adoption guide to see which responsibilities move into Arc and which stay in your code.
For the implementation details, choose the part you are working on:
- Commands explains state changes through
Handle(). - Queries covers reads, including observable queries that send updates to connected clients.
- Proxy generation shows how to configure the post-build tool that turns backend contracts into TypeScript. The tool reads compiled assemblies and their PDBs; it does not generate proxies at runtime.
Integrations
Section titled “Integrations”Choose storage and hosting to match the slice you are building:
| Topic | What it covers |
|---|---|
| MongoDB | Document storage for read models and other data. |
| Entity Framework | EF Core integration for relational read models. |
| Chronicle | Event sourcing integration — append events from commands, build read models, feed state back into business rules. |
| ASP.NET Core | How Arc plugs into the ASP.NET Core pipeline. |
Cross-cutting
Section titled “Cross-cutting”Once an endpoint works, decide who may call it and how it is exposed. Authorization applies access rules to commands and queries. Endpoint groups separates endpoint sets by port and route prefix; it does not replace authorization.
For date-sensitive behavior, use the application calendar to resolve business dates in the right time zone. To inspect the event model represented by your source, generate a Screenplay or embed the event-model explorer in the application.
| Topic | What it covers |
|---|---|
| Core | Commands, queries, and dependency injection at the lower level. |
| Identity | Who the user is — authentication and identity details. |
| Tenancy | Tenant selection and provider-specific storage routing; membership authorization is separate. |
| Open API | OpenAPI/Swagger generation. |
| Code Analysis | Analyzers and fixers that catch mistakes at compile time. |
When your backend contracts are ready, continue with the frontend to call commands and queries through their generated proxies.