Application Flows
For developers and designers extending this template. Each flow shows the screens as a wireframe; the “Why” beneath it — rendered as normal, readable prose — explains the framework decision, the seam you’d extend, or the guarantee it gives you. The end-user flows are intentionally tight, so this page is for builders, not users. For the full detail behind each journey, follow the per-flow links to Email & verification, Onboarding, Project tools, Workspaces, and Clientside.
The model behind every flow
Five concepts the flows plug into — knowing these is usually enough to avoid fighting the template.
| Concept | What it is | Why it’s shaped this way |
|---|---|---|
User |
One identity / login | Reused across workspaces — one person, many memberships. |
Workspace |
The tenant | Top-level boundary; Current.workspace scopes data via the Tenanted concern. |
Membership + Role |
owner · admin · member · viewer | Role is per-workspace, not global (JSON permissions); Pundit authorizes. |
Project + tools |
Belongs to a workspace | Enabled tools are a registry (enabled_tools JSON) — extend in an initializer, no view edits. |
ClientAccess |
External client ↔ project | A separate access axis, not a membership: no seat, never in workspace policies. |
1 · Sign up & sign in
Why it's shaped this way
- Sign in or sign up — One email-first door (
sessions#new→lookup) for both. A new email gets a magic-link registration; an existing one gets a magic-link sign-in. There is no password at signup — passwords are off unless the instance setsAUTH_PASSWORDS=enabled, and even then a user opts in from Settings. A returning user with a passkey can tap Sign in with a passkey (usernameless/discoverable); any failure falls back to the magic link, so no one is stranded. - Check your email — The magic link proves email ownership: clicking it verifies the address and signs the user in in one step. With passwords enabled, “Forgot your password?” reuses this same link (a
set_password-intent magic link) — there is no separate reset flow. - Set up a passkey? — A one-time, dismissible prompt after the first sign-in (only when the user has no passkey yet and the browser supports WebAuthn). Adding one makes the next sign-in a single tap; magic link remains the universal fallback. Manage passkeys anytime in Settings.
2 · First-run onboarding
Why it's shaped this way
- Name your workspace — Onboarding only runs under
WORKSPACE_ON_SIGNUP=none; theRequiresOnboardingguard is posture-gated and html-only, returning early in every other posture. - Create your first project — Derive-from-data:
onboarded_atis the only marker, and the current step is computed from what already exists — so the wizard is resumable with no per-step flags to keep in sync. - Pick your tools — Self-hides unless more than one tool is registered (never a one-option screen). It’s a forward-only interstitial, not a resume step. Register tools in
config/initializers/project_tools.rb. - Invite people — Optional: skipping still lands a fully working project; finishing stamps
onboarded_at. The project home’s tabs follow the project’senabled_tools.
3 · Project home & tools
Why it's shaped this way
- Project home — The tab bar is driven by the project’s
enabled_tools(JSON), not a hardcoded list — so a fork can add a tool without touching this view. - Project tools (settings) — Toggling writes
enabled_tools. Register tools inconfig/initializers/project_tools.rb; gate a tool’s controller with theEnforcesProjectToolconcern. The base template ships only Docs & Files.
4 · Invite teammates
Why it's shaped this way
- Invite members — Role is set at invite time and is per-workspace (JSON permissions); only
manage_membersusers can invite (Pundit). A shareable magic link is the alternative for open joining. - Invitation email — The invite carries the recipient’s email, so the bearer link isn’t a free-for-all.
- Accept / set up login — Consume-before-verify with an
EmailMismatchguard: a leaked link can’t be claimed by a different address. Existing users join in one click; a new email finishes a passwordless signup (name only — magic link already proved the email). OneUser, reused everywhere after.
5 · Clientside
Why it's shaped this way
- Client access — Per-project opt-in (
clientside_enabled), off by default. Nothing is exposed until a team explicitly turns it on. - Share a resource —
Project#client_visible_resources= not deleted,shared_with_clientandpublished. Publishing is the readiness gate, so a shared draft never leaks. - Invite a client — Reuses the hardened invitation path (
accept!/consume!with theEmailMismatchguard) but creates aClientAccess, not aMembership. - Client area —
ClientAccessis a separate axis: clients consume no seat, never enter Pundit workspace policies, and the area never setsCurrent.workspace. They see only shared-and-published items.
The signup & join contract, precisely
Flows 1 and 4 above show the screens; this section is the behavioral contract behind them — what commits together, which failures are silent, and which exceptions mean what. The code lives in Signupable (app/controllers/concerns/signupable.rb), Authenticatable, and Authentication.
One transaction, typed outcomes
Signupable#commit_signup_atomically runs user creation, invitation acceptance, and open-link join in a single transaction. The caller’s block receives the saved user and performs any in-transaction work (creating authentications, generating verification tokens). The method returns true on commit and false on every handled failure — so a failed signup never leaves an orphaned user, a half-claimed invitation, or a membership without its user.
The exception matrix:
| Exception | Meaning | Handling |
|---|---|---|
Invitation::NotAcceptable |
Invitation raced to consumed/expired | Roll back; clear the parked session token; flash.now[:alert]; return false |
ActiveRecord::RecordInvalid |
Model validation failure | Roll back; return false — caller reads @user.errors |
Workspace::AdmissionError |
Any outcome of Workspace#admit — NotAdmittableError (workspace went archived/suspended/deleted mid-flight), AlreadyMember, AtCapacity |
Roll back; return false |
| Anything else | A real bug | Propagates — never masked |
Three details are load-bearing:
- The rescue names the base class, not the three subclasses. Every admission outcome is handled identically here, so a fourth outcome added to
#admitis covered without editing this method. Sites that branch on which outcome occurred keep naming the subclasses —Workspace::HomeWorkspaceProtectedErroris deliberately not a subclass, because it is a lifecycle guard raised fromarchive!/discard!, not an admission outcome. flash.now[:alert]is set only onInvitation::NotAcceptable, so callers can rely on@user.errorsfor model-validation failures without a competing generic alert.NotAdmittableErroris the TOCTOU backstop for a parked open-link join whose workspace goes non-admittable between the pre-check andadmit’s locked re-check. Rescuing it the same asRecordInvalidmeans the whole signup rolls back cleanly instead of a raw exception aborting registration. Normal stale-workspace parked joins never reach it — the pre-check drops them first.
On NotAcceptable, the parked token is cleared outside the rollback on purpose: session writes aren’t transactional, so the delete persists even though the database rolls back. Without it, a retry would hit the same non-admittable state and reject forever. The invitation itself stays pending (accept! guards before marking it consumed), so it remains reclaimable via the emailed link.
Invitation claims and EmailMismatch
The invitation claim inside PendingClaims#claim! (run by Signupable#commit_signup_atomically) consumes the session’s parked invitation token; it’s idempotent when no token is present. If the invitation was addressed to a different email than the one being registered (Invitation::EmailMismatch), the signup is not aborted — the claim is skipped, the token is dropped so it can’t loop on retry, and a persistent flash (flash[:alert], not flash.now — these callers redirect) tells the user why they weren’t added to the invited workspace.
Join-link claims and the consent guard
The join-link claim inside PendingClaims#claim! consumes the session’s parked open-link token for a freshly signed-up, email-verified user. Its failure semantics are asymmetric by design:
- Stale-link conditions are silent no-ops — revoked link, join policy reverted, workspace archived/suspended/deleted. A visitor who was never a member must not learn that a workspace is locked.
Workspace::AlreadyMemberis swallowed as benign.Workspace::AtCapacitypropagates tocommit_signup_atomically, which rolls the whole signup back — consistent with the invitation path.
The consent guard: a brand-new account’s signup is its own consent to join the link it followed. A pre-existing user, though, may be authenticating for an unrelated reason (e.g. linking a new verified OAuth provider) with a lured-in token riding their session — they are never silently force-joined. A still-valid token is left parked so the pending-join banner can offer an explicit Join / Dismiss; stale or consumed tokens are cleared.
Deferred claims on the unverified-OAuth path
When an OAuth provider reports the email as unverified, the app refuses to auto-link or auto-verify; it creates a fresh user and parks both pending claims (invitation token, join-link digest) on the pending Authentication row, to be claimed when the user proves email ownership via the verification link. Authentication#claim_pending! then applies join-link semantics matching the signup path: stale-link conditions are silent no-ops (clear the digest and continue, so email verification is never blocked by a workspace whose join policy changed mid-flight, and a non-member learns nothing about its state). Unlike signup, nothing here rolls back: already-member is benign, and a full workspace is recorded as a problem (:join_link_at_capacity) on the returned claims, which the verification controller shows as a flash, so a stale claim never blocks verification.
The token is a one-shot claim: verification never retries, so once admission is attempted the digest is spent regardless of outcome. Clearing it lives in an ensure — deliberately not inside admit’s transaction — so a terminal failure like capacity rolls back the membership but does not resurrect the token.
Note the guard this path deliberately lacks: unlike the signup-time claim (PendingClaims#claim! with newly_registered: true), there is no newly-registered check. None is needed — the digest is parked only by the unverified-email OAuth handler, which always creates a fresh user and refuses to link an existing one (an account-takeover refusal). The claimer here is therefore never a pre-existing account at risk of a drive-by join.
Best-effort side work at sign-in
New-device detection (Authenticatable#detect_and_record_new_device) runs once per Session.create! — exactly the moment recognized as “successful sign-in” — not on every authenticated request. It is best-effort: a database or queue hiccup must never break sign-in. All three writes it makes (the user.signed_in_new_device audit row, the notifier’s bulk insert, and the browser-fingerprint update_column) go through ActiveRecord, and on this SQLite + Solid Queue stack even a “queue down” condition surfaces as an ActiveRecord error — so ActiveRecord::ActiveRecordError is the only class swallowed (and logged). A non-AR failure such as a NoMethodError is a real bug and propagates rather than being silently masked (#305). The config flag gates the alert only; both the audit row and the fingerprint recording always run, so detection history survives a fork toggling notifications off and on. The fingerprint is written before anything that can raise, so a failed audit write costs one row rather than re-detecting the same browser as new on every subsequent sign-in.
Extending these flows
Each “Why” points at the seam to build on. For the how-to, see Extending the template and Forking; per-area depth lives in the feature docs linked at the top.