Chuyển tới nội dung chính

Todo app

The docs use one running example: a todo service. The Quick start builds it in a single crate, and the Tutorial grows it into a domain crate and a service crate with updates, a report, custom routes, authentication, and permissions. The framework repository ships only the library crates, so the complete code lives in those pages.

Files and where they are explained​

FileContainsExplained in
domain/src/domain.rsdomain! with command and query slots, spawnScaffold and domain
domain/src/command.rscommand_engine!: create-todo, update-todo, clear-done, typed helpersCommands
domain/src/aggregate.rsTodoAggregate and its #[domain_action] methodsCommands
domain/src/query.rsquery_resource!, report_resource!, query_engine!Queries
domain/src/postgres/Diesel table, row, entity, migrations, DomainStoreSpecDatastore
domain/migrations/The todo_items table with the shared domain columnsQuick start
service/src/main.rsRiverbaseApp, DomainRuntime, mounting, auth routesRun and verify
service/riverbase.tomlDatabase, bind address, bus, audit, auth, and Casbin settingsConfiguration

The domain at a glance​

What it demonstrates​

FeaturePage
Collection (:post) and object (:exec) commands with typed payloadsCommands
State changes only inside #[domain_action], with one audited event eachAggregates
Read models with filters, sorting, paging, and metadataQueries
A parameterized report with its own handlerQueries
A custom health route and app-level routersCustom endpoints
MockAuth and Keycloak/OIDC sign-inAuth and users
Casbin activity rules and row policyPermissions
Coupled and split deployment of the same domainDeployment

Notes​

  • The todo resource declares policy: public(…) because it has no tenants. A real product would use policy: required with a scope_policy.
  • Audit activity names such as todo.create are not route activities. HTTP enforcement uses create-todo.execute and todo.query.