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
| File | Contains | Explained in |
|---|---|---|
domain/src/domain.rs | domain! with command and query slots, spawn | Scaffold and domain |
domain/src/command.rs | command_engine!: create-todo, update-todo, clear-done, typed helpers | Commands |
domain/src/aggregate.rs | TodoAggregate and its #[domain_action] methods | Commands |
domain/src/query.rs | query_resource!, report_resource!, query_engine! | Queries |
domain/src/postgres/ | Diesel table, row, entity, migrations, DomainStoreSpec | Datastore |
domain/migrations/ | The todo_items table with the shared domain columns | Quick start |
service/src/main.rs | RiverbaseApp, DomainRuntime, mounting, auth routes | Run and verify |
service/riverbase.toml | Database, bind address, bus, audit, auth, and Casbin settings | Configuration |
The domain at a glance
What it demonstrates
| Feature | Page |
|---|---|
Collection (:post) and object (:exec) commands with typed payloads | Commands |
State changes only inside #[domain_action], with one audited event each | Aggregates |
| Read models with filters, sorting, paging, and metadata | Queries |
| A parameterized report with its own handler | Queries |
| A custom health route and app-level routers | Custom endpoints |
| MockAuth and Keycloak/OIDC sign-in | Auth and users |
| Casbin activity rules and row policy | Permissions |
| Coupled and split deployment of the same domain | Deployment |
Notes
- The todo resource declares
policy: public(…)because it has no tenants. A real product would usepolicy: requiredwith ascope_policy. - Audit activity names such as
todo.createare not route activities. HTTP enforcement usescreate-todo.executeandtodo.query.