Skip to content

Build a library app with Cratis Arc and React

Build a library back office with Cratis Arc and React: register authors, catalog their books, and connect commands and queries to screens through generated TypeScript clients. By the last chapter, you’ll have forms with validation, live catalog queries, and role-based authorization.

Start from a configured backend and database using the prerequisites below, then connect the first screen. The tutorial includes C# and JVM paths plus a TypeScript backend, published on npm, with no claim of full parity. Follow the setup for your chosen backend; the examples are not interchangeable.

Arc for Go has a separate running application guide and TypeScript generation guide. This tutorial does not yet have a Go path; check its parity reference before carrying a chapter’s behavior across.

Work through one vertical slice at a time: a command requests a change, a read model holds the data a screen needs, and a query reads it for React. A generated proxy is the TypeScript class the frontend uses to call that command or query. Regenerate proxies after backend changes, then type-check the frontend to catch structural mismatches.

The tutorial writes directly to a database: MongoDB or EF Core on C#, Spring Data on the JVM, or MongoDB on TypeScript. This lets you learn CQRS, the separation of writes from reads, without setting up an event store. Cratis Chronicle is an optional event-sourcing integration.

The event model below describes the author-registration feature before choosing storage. Read it left to right: the librarian submits an author, RegisterAuthor requests the change, AuthorRegistered names the resulting business fact, and the Author read model supplies the list screen.

UI/A: AuthorsUI/A: AuthorsC/RM: AuthorsC/RM: AuthorsStream: Authors
AddAuthor
RegisterAuthor

id: uuid, name: string
AuthorRegistered

name: string
Author
Authors

AuthorRegistered describes what happened; this tutorial does not store it as an event. The command writes the Author read model directly to the database. Later, adding and listing books gives you another slice of the same shape.

The next diagram follows the running C# version. React calls generated command and query proxies; the backend writes and reads the database. You declare those contracts on the backend instead of maintaining a separate API client:

Arc (C#)

React (TypeScript)

generated command proxy

writes

generated query proxy, live

Library screen

commands — RegisterAuthor · AddBook

read models — Author · BookOnShelf

queries

MongoDB / EF Core

Use the event model to plan the behavior and the flowchart to trace a request through the C# implementation. Understanding the proxy boundary explains which contract changes generation and frontend type-checking can catch.

By the last chapter, a librarian can register authors, add their books, and browse the catalog. An observable query keeps the author list updated without a refresh. Blank or duplicate author names are rejected with a reason on the form, and role-based authorization restricts catalog changes to librarians.

There is one tutorial with C#, JVM, and TypeScript backend examples. The TypeScript backend is published on npm and does not claim full parity. Use its own setup and capability reference before following a chapter’s tab. The React examples consume the shared frontend runtime rather than three different browser libraries. The ideas are the same across these paths — a slice from command to read model to query to screen, validation, relating slices, live queries, authorization.

Keep your chosen backend’s setup throughout the tutorial. The SDK, generation command, database integration, and development sign-in differ. Each chapter names setup and behavior differences beside the step they affect.

For C#, start with standalone ASP.NET Core setup, then complete its backend checkpoint. It specifies a released package set, SDK, imports, the default EF Core/SQLite schema bootstrap or alternative MongoDB replica-set settings, Debug proxy generation, and a curl write/read test.

Choose one database branch and keep it throughout the tutorial. Chapter 1 continues in the same project with a Vite app and a Components dialog; do not recreate the backend types it recaps. If you already have a Vite app, frontend getting started offers an inline form and a no-Components alternative.

  1. Your first full-stack slice — register an author from the backend all the way to a live React screen, fully typed.
  2. Make it trustworthy — reject bad input with a validator and a uniqueness rule, and show the reason in the form.
  3. Relate your slices — add books that belong to an author, and read them back.
  4. Make it live — observable queries that update the screen the moment the data changes.
  5. Decide who can do what — lock the catalog down with role-based authorization.

Once your backend passes its write/read checkpoint, connect the first author screen →. Keep that project for the remaining chapters; each adds behavior to the same library app.