Tutorials
Learn by building
Follow Maya and Ken through a writing app. Start with the foundations, then choose the topics your application needs. Every lesson teaches with small snippets first and ends with its complete runnable project, including setup and dependencies.
Each project has a focused schema. A later lesson shows the fields it adds. You do not have to keep every advanced feature enabled in one growing database.
For a short first success, use Your first app. The final Axum capstone brings the patterns into an HTTP API.
Foundations
- Define the schema in RSL — Create a small application model and generate a Rust client explicitly.
- Your first entity — Connect to SQLite and learn the generated CRUD vocabulary.
- User, Post, and Comment — Declare foreign-key relationships, traverse them, and eager-load a discussion.
- Many-to-many tags — Connect posts and tags, model membership records, and traverse a group hierarchy.
- Querying collections — Filter, order, paginate, project, count, aggregate, group, and write raw SQL.
Modeling and storage
- Rich values — Round-trip portable scalar, document, binary, time, UUID, enum, and nullable values.
- Reuse model fields — Start with shared timestamps, then combine shared fields with a reusable access policy.
- Upserts and custom IDs — Use generated clients with custom IDs and compound conflict targets.
- Constraints and cascades — Let foreign keys reject invalid relationships and clean up dependent data.
- Views, generated columns, and triggers — Use database-computed structures alongside generated entities.
- Production schema options — Add compound foreign keys, custom join storage, SQL defaults, and advanced indexes.
- Transparent field encryption — Encrypt bytes at the driver boundary without changing generated CRUD.
- External blob storage — Keep attachments in object storage and load their bytes when needed.
Transactions and tenants
- Transactions and rollback — Commit a unit of work or automatically roll it all back.
- Savepoints — Roll back one optional portion without discarding the outer transaction.
- Optimistic concurrency — Detect stale writes automatically with a version field.
- Pessimistic row locking — Serialize contested workflows with explicit PostgreSQL locks.
- Migration lifecycle — Change a schema, preserve existing rows, and apply reviewed SQL.
- Multi-tenant applications — Put tenant identity in request context and enforce isolation centrally.
- Policies, interceptors, and hooks — Add shared read and write behavior without repeating it in every handler.
- Bulk writes and performance — Insert collections efficiently and roll back the whole batch if a row fails.
Permissions and sharing
- Relationship permissions — Create a private post, share it with a reader, and invite someone to help edit it.
- Permission badges on rows — Show the actions available on each record, such as whether to display an Edit button.
- Build tenant-safe sharing — Combine tenant isolation, private posts, direct sharing, and inherited comment permissions.
- Reuse permission policies — Give posts, notes, and other resources the same private-by-default sharing policy.
- Show people with access — Build a sharing dialog that lists the stored users who can read a resource.
- Explain a permission decision — Answer “why can Ken read this post?” using the rules in your schema.
- Recursive permission reads — Share a parent post and let the posts beneath it inherit access.
- Explain inherited permissions — See when a parent relationship is the reason someone can read a resource.
- Share inherited access — Show people whose access comes from a parent as well as those with direct access.
- Authorize individual update fields — Let people make narrow self-service changes while keeping administrative fields protected.
- Reference private platform records — Let people connect to a registered application without exposing its private configuration.
Production and integrations
- Production runtime — Configure the connection pool and connect Rent spans to your tracing subscriber.
- Production access patterns — Small projections, batched counts, scoped pagination and short transactions through the existing client.
- Inspect permissions from the terminal — Run real guarded permission explanations with typed keys and trusted viewer claims.
- Test permission expectations — Seed users, posts and comments and execute permission fixtures through the CLI.
- Browse as a viewer in Studio — Open your local database as a particular person to see the rows their permissions allow.
- Cache explicit permission checks — Reuse repeated permission checks when a short delay in noticing access changes is acceptable.
- Inspect local data with Studio — Browse the tutorial database and deliberately enable safe cell editing.
- PostgreSQL superpowers — Move from portable application data into first-class PostgreSQL extensions.
- Build a leaderboard — Combine data-carrying enums, case-insensitive uniques, grouping, raw SQL, and a relation without a foreign key.
- Teams, sharing and delegated agents — Give teammates and agents the access they need without making every action an ownership decision.
- Private data and delegated helpers — Let Scout help Maya with a private draft while denying standalone and wrong-owner requests.
- Enterprise permissions and ordinary CRUD — Give an organization shared resources and private workspaces without repeating access rules in every handler.
Capstone
- Build a writing API with Axum — Bring the lessons together in a small HTTP API with scoped CRUD, sharing, and application tests.
