Skip to main content
The client half of the kit — Vue 3 + Ionic + Capacitor (iOS/Android) + Tauri (desktop), one codebase across web, mobile and desktop.

What you’re starting from

Every exported composable, component, api function and type is ready to use — pull it in as you need it. The account screens are built and working (profile, sessions, account settings with data export and account deletion — see Account screens); your product’s own screens go on top, and the kit supplies the plumbing behind them.

Layout

Layering rule: pages/composables call the api layer; they never build request URLs or reimplement requests. (Reimplementing a request is what once let the chunk upload drift onto a stale prefix.)

Shell & navigation

The app shell is three coordinated pieces — reskin them, don’t recreate them:
  • Side menu (views/core/SideMenu.vue) — the drawer: your nav items plus Settings and Log out (views/pages/_base/Logout.vue ends the session on the server first, then wipes the device). Documentation, Privacy and Terms live on the About page. On desktop (≥1105px) it docks permanently via ion-split-pane.
  • Bottom tab bar (views/core/BottomTabBar.vue) — a per-page <ion-footer>: add <BottomTabBar /> inside each main/section page. It is intentionally NOT a global fixed element — placing it per page lets Ionic manage safe-area, keyboard and the drawer backdrop natively, and it rides page transitions correctly. It hides itself on desktop (the docked side menu replaces it).
  • Back button (views/components/BackButton.vue) — put it in the header of every sub-page (<ion-buttons slot="start"><BackButton /></ion-buttons>) instead of ion-back-button. It routes through composables/useGoBack.ts: a cached native pop when there is history, an instant root/replace swap when there is not — so the target page never slide-animates in or re-creates. Without history (a cold start, a deep link) it goes to the page the browser came from, else the section root (/account/sessions → /account), else HOME_PATH (exported from router/paths.ts — set it to your app’s home): never back into sign-in, never “back” to the page itself. Main-section pages (bottom-bar destinations) carry no back button.
Desktop content width: padded pages (<ion-content class="ion-padding">) cap their inner content to a centered column above 768px so it doesn’t stretch edge-to-edge; drop .ion-padding (or override the rule in styles/core/app.scss) to go full-width.
System bars follow the app theme (helpers/systemBars.ts, run on every theme apply): status/navigation bar icons match the app’s theme on iOS and Android — not the OS one, since Settings can force Light/Dark. On Android the status bar is painted with the header colour (Ionic’s --ion-toolbar-background, laid over the page if translucent — set --sw-header-background if your header is painted some other way) and the navigation bar with the tab bar’s surface, --sw-tab-bar-background (defaults to --sw-ffffff; override it to reskin both); on the web the theme-color meta follows too.
Android edge-to-edge is owned by @capawesome/capacitor-android-edge-to-edge-support, which requires SystemBars.insetsHandling: "disable" in capacitor.config.ts. Keep it — otherwise Capacitor pads the web view itself and the bars fall back to the OS window colour.
Keyboard on Android. With edge-to-edge (enforced from Android 15) the system no longer shrinks the window for the on-screen keyboard. helpers/keyboardInset.ts (started in main.ts) mirrors the keyboard height into --keyboard-inset and scrolls the focused field into view. The :root ion-app rule in styles/core/app.scss takes that as its bottom offset, so pages, footers and overlays stay above the keyboard. iOS and the web resize on their own, so the variable stays 0 there. Keep both pieces when you restyle the shell.

Sign-in flow

Passwordless only — sign-in and sign-up are the same act. views/pages/_base/Login.vue is the single entry point:
  1. The user enters an email and gets a six-digit code (or picks Google / Apple).
  2. A valid code signs them in; an unknown address gets an account on the spot. The code field opens the number pad, takes six digits and submits on Enter; a shorter code is turned back on the device without a request (and isn’t counted as a wrong code).
  3. A sign-in — code, Google or Apple — that lands on an account pending deletion (deletion_pending) makes the screen offer to restore it, then signs in. One handler in accountStore reads every sign-in answer, so a reply without a session is a failed sign-in, never a signed-in screen without tokens.
  4. With VITE_ENABLE_ONBOARDING='true', a fresh sign-in goes through onboarding, where the user picks a username (live availability check; the API enforces a 30-day cooldown between changes). Without it, the auto-generated username from the email stays.
Five wrong codes for one address lock it out on that device for five minutes (composables/useBruteForceProtection.ts, keyed by the trimmed, lower-cased address). Only a code the server rejects counts — a lost connection, a rate limit or a server error never locks anyone out, and neither does asking for a code. A mistyped code keeps the code step (the field clears and the same emailed code can still be entered); an expired or burned code goes back to the email step for a new one. A failed sign-in names the server’s code when there is a message for it (login.error.<code>), else says “too many requests”, “server error” or “no connection” by what happened. Under the form, a line says that continuing accepts the Terms of Service and the Privacy Policy, each a link to VITE_LEGAL_TERMS_URL / VITE_LEGAL_PRIVACY_URL. Errors arrive as { code, message } — switch on the code with extractApiErrorCode(), never show message. It lives in the import-free services/networkRequests/api/core/apiErrorCode.ts, so session code can read a code without importing the error handler (which re-exports it). Every request follows the shared wire contract (/v1, camelCase, ISO-8601, UUIDv7) and carries the access token — DPoP-bound (see DPoP below); a 401 refreshes the token pair (with rotation) and retries. The backend side is in Backend.

Support screen

views/pages/support/Support.vue (route /support, signed-in only) is the in-app help desk: the user’s tickets with their status, a new ticket form (subject, topic, message) and each thread with replies. Link it from the side menu or your settings wherever your users should find it. How tickets flow to the admin inbox and back: Support & tickets.

Account screens

Three signed-in screens, reached from the side menu’s Account entry:
  • Profile — views/pages/account/Account.vue (/account): the avatar and display name. It edits the display name, the username (live availability: taken / reserved / invalid) and the avatar. A picked image is centre-cropped to a square JPEG on the device and sent to POST /v1/account/avatar; it can also be removed. It links to sessions, account settings and app settings.
  • Sessions — views/pages/account/SessionManagement.vue (/account/sessions): every signed-in device, with “this device” marked and when each was last active. It can rename a device, sign one out, or sign out all the others. A new sign-in names its session from app.name and the device — “My App · iPhone15,2 · iOS 18.1”, “My App Web · macOS” (sessionLabel in helpers/clientMeta.ts).
  • Account settings — views/pages/_settings/AccountSettings.vue (/account/settings):
    • email change by code
    • username and member-since
    • Export my data: GET /v1/account/export, saved as a JSON file — a download on the web, the share sheet on mobile
    • Delete account behind a confirmation, which signs the device out. Signing in again within the server’s PURGE_AFTER_DAYS window offers to restore the account.
An in-app delete-account path and a data export are what the App Store (guideline 5.1.1(v)) and Google Play’s account-deletion policy expect from any app with sign-up, so keep both reachable when you reskin these screens. Their copy lives in src/i18n/locales/*/account.json.

Account time zone + language — kept in sync

accountStore.syncDeviceProfile() keeps the account’s timezone on the device’s IANA zone (getDeviceTimezone() in helpers/ui/dateFormatter.ts) and its locale on the app’s UI language: one PATCH /v1/account/me with only what changed, a no-op when both match. It runs after sign-in, on every start / resume (a trip may have moved the device) and after a language change; a failure just retries on the next one. Every date the app renders uses that zone, and anything you build server-side (scheduled emails, reminders) can read both from the account. The API accepts IANA names (plus the fixed UTC ±HH:MM offset older builds sent).

Session storage — encrypted, non-exportable key

services/localStorage/core/secure_storage.ts is a transparent AES-GCM over IndexedDB layer:
  • The key is a random, non-exportable CryptoKey — never derived from a device fingerprint, never stored as raw bytes. WebCrypto (authenticated); no crypto-js.
  • A canary detects a key/data mismatch and resets the store once, cleanly (a reset = a sign-out, since only the session lives here).
  • Works in the web build and in the Capacitor / Tauri WebViews.
It keeps tokens out of plaintext at rest. It is not an XSS defence, and it does not bind anything to the device — a copy of the storage files plus the key’s IndexedDB would open it. Device binding for the session is DPoP (below). An app that keeps long-lived secrets here can hand the store a key from the platform keystore (Keychain / Android Keystore) via setStorageKeyProvider — a small native plugin of your own; the provider must reject, never return nothing, while the keystore is locked, or the store would reset.

How the API reaches the session

The API core (services/networkRequests/api/core/) imports neither the stores nor the session code: the account store calls the API, so either import would close a loop. It talks to the session through a small port, apiSession.ts — the access token, a refresh ahead of expiry, recovery after a 401 — which installApiSession() (helpers/security/tokenManagement.ts) plugs in first thing in main.ts. Until then the port answers as signed out. The server choice it needs lives apart in helpers/apiServer.ts, which reads only the system store. The same rule keeps forceSignOut() off the router: router/index.ts hands itself over (provideSignOutRouter) when it is created. src/test/http.ts plugs the real session in the same way for every test that runs the real client. build keeps the app free of import cycles: ESLint’s import-x/no-cycle fails on any import that leads back to the file it is in — a lazy import() included, since it hides the same dependency (only type-only imports don’t count). When a lower layer needs something above it, hand it in as above instead of importing it. main.ts does the same for the offline layer (provideEntityLoader), and the home path lives in router/paths.ts rather than the route table, which lazy-loads every page.

Token refresh across tabs

The API treats a refresh token as single-use: presented a second time (past a 2-minute grace window meant only for lost responses), it revokes the whole session. The web build can have several tabs on one stored session, so refreshing goes through helpers/security/refreshCoordinator.ts (wired to the account store in tokenManagement.ts):
  • One refresh at a time — per tab and across tabs (a Web Lock). A tab that finds the stored pair already rotated by another tab adopts it instead of spending its own stale token; a BroadcastChannel tells the other tabs straight away.
  • Ahead of expiry, and once after a 401 — the access token is refreshed when it has under five minutes left by the server’s clock (helpers/security/serverClock.ts learns the offset from every response’s Date header, so a device clock that is minutes off changes nothing; at most half the token’s lifetime, for short-lived tokens); a 401 brings the pair up to date and replays the request once. The chunked file upload, which sends its chunks past the API client, does the same for every chunk.
  • Bounded — a refresh call gives up after 15 s, and a tab waits at most 45 s for another tab’s refresh, so one stuck tab never blocks the others.
  • Only a refusal ends the session (400/401/403 → /login), and only once, however many requests were waiting on it. Offline, 5xx or 429 keep it.
  • A refused tab never clears a newer session another tab signed in with — saving the stores included: critical state (the session, the offline-cache owner, the lock, screenshot and crash-report flags) is written from a tab’s memory only when that tab just changed it, so a tab left behind can’t overwrite what another tab wrote (stores/plugins/persistPlugin.ts).
Native builds have one WebView, so the cross-tab part simply has nothing to coordinate there. Refusals that should never happen in normal use (a reused refresh token, an unknown one, a DPoP key mismatch) are reported to Sentry by code — a spike means stolen tokens or a client bug.

DPoP — tokens bound to the device

helpers/security/dpop.ts keeps one ECDSA P-256 key per app, created on first use with WebCrypto as non-exportable and stored in its own IndexedDB database. Every request the app authorizes — the API client, the sign-in calls, every upload chunk — gets a fresh proof (method, URL, random id, server time and the access token’s hash), so a session signed in on this device works only from it. Sign-out (and a forced sign-out) forgets the key the session was bound to, so the next sign-in starts with a new one. The key is shared by every tab of the web build, so a tab left open never undoes another tab’s sign-in: it forgets only its own session’s key, signs a sign-in or refresh with the key stored now, and picks up the new key for a session another tab signed in with. A device that can’t keep a key (no IndexedDB) simply stays on Bearer. Use dpop.authorize(method, url, token) for any request you send past the API client.

Cancelling stale requests

helpers/requestScope.ts is the one way to drop work nobody waits for any more:
  • useRequestScope() in a component — signal aborts when the page leaves the stack; latest() starts a “latest wins” chain: each next() cancels the previous request (open ticket B while A still loads, a new username check while the old one runs). After awaiting, check signal.aborted before using the result — a cancelled request resolves with nothing.
  • timeoutSignal(ms) / anySignal([...]) instead of AbortSignal.timeout / AbortSignal.any, which iOS 15 lacks.
  • isCancelled(error) — a cancellation is never an error to show or report.
  • Never pass these signals to a token refresh, a sync or a write queue: those are shared, and cut short mid-flight their outcome is unknown.

Dialogs and best-effort work

Two small helpers keep every screen asking and failing the same way:
  • helpers/ui/alertDialogs.ts — openConfirmAlert({ header, message, confirmText, destructive }) resolves true only when the action is tapped (destructive styles it as dangerous, for a delete or a sign-out); openPromptAlert({ header, confirmText, value, placeholder, type, attributes }) gives back the trimmed text, or null when dismissed. Both offer the shared “Cancel” unless you pass cancelText. Build your own alertController alert only for something richer: three or more choices, several fields, a checkbox, or a button that keeps the alert open.
  • helpers/bestEffort.ts — bestEffort(promise, context, { fallback, report }) for work whose failure must not stop the caller (a cache write, a prefetch, a cleanup). Instead of a silent .catch(() => {}) it resolves to fallback and leaves a trace: the console in development, a Sentry breadcrumb in production (no event of its own, so an offline burst costs no quota). report: true sends a full Sentry event — for a failure that matters on its own. For a try around several steps, call traceFailure(error, context, { report }) from the catch instead: the same trace, and the caller keeps its own fallback. An empty catch {} is left only where nothing failed — a capability check, a parse with a fallback, closing what may already be closed. ESLint holds the line: a silent .catch(() => …) in src/ (tests aside) fails build; a deliberate one carries // eslint-disable-next-line no-restricted-syntax -- <why>.
A failed API request is logged once, by logError() in services/networkRequests/api/core/errorHandler.ts, as an Error named APIError:<type> with the status and endpoint in its message, so production failures show up in Sentry (a cancelled request is not logged).

After a deploy — open tabs catch up

A tab still running the previous web build asks for chunks whose hashed names are gone once you deploy. helpers/staleBuildRecovery.ts (installed in main.ts) reloads the page for the fresh build:
  • It listens to Vite’s vite:preloadError, fired for every failed lazy import, even one the caller swallows (a RouterLink click, back / forward), and to unhandledrejection for anything else.
  • Only a module or stylesheet that could not be fetched counts (the Chromium, Firefox and Safari wordings); an error thrown inside a module that did load is left alone.
  • At most one reload a minute per tab: a chunk still missing right after the reload is a broken deploy and never loops, while a tab left open across several deploys recovers from each one.
  • It reports through log(), so each reload leaves a trace in Sentry. Native builds carry every chunk inside the app, so it only ever fires on the web.

Privacy & security: app lock, screenshots, crash reports

Settings → Privacy & security. The lock and screenshot switches appear only in the native builds (iOS / Android); the crash-report switch appears wherever Sentry is configured:
  • Lock with Face ID / fingerprint — helpers/security/biometricLock.ts + views/core/AppLock.vue (@capgo/capacitor-native-biometric). A signed-in app with the lock on starts behind a full-screen lock and locks again after 5 minutes in the background (APP_LOCK_AFTER_MS). Turning it on or off needs a successful check. iOS falls back to the device passcode; Android accepts enrolled biometrics only. Log out on the lock screen is the way out when the check can’t pass. It is a gate, not a vault — nothing is stored with the biometric APIs. verifyBiometric(reason) is exported for your own confirmations (e.g. before a sensitive action).
  • Block screenshots — helpers/security/privacyProtection.ts (@capacitor-community/privacy-screen): screenshots and screen recordings come out blank and the app-switcher preview is hidden. Keep PrivacyScreen.preventScreenshots: true in capacitor.config.ts — without it iOS hides only the preview, not screenshots.
  • Send crash reports — shown only when VITE_SENTRY_DSN is set, web included. Off closes the running Sentry client at once and keeps it from starting on later launches (beforeSend drops anything in between); on takes effect after a restart. Reports carry only the account’s opaque id and time zone — never the username or email (composables/useSentry.ts) — and Session Replay masks all text and inputs and blocks media.
All three are settingsStore flags written through at once (fingerprintFaceIdProtection, preventScreenshots, collectReports). The lock and screenshot flags reset on logout; the crash-report choice belongs to the device and survives it (views/pages/_base/Logout.vue). Native config is in place: NSFaceIDUsageDescription in Info.plist (reword it for your app) and USE_BIOMETRIC in AndroidManifest.xml.

Push notifications

Push is wired end-to-end: on sign-in the app logs the device into OneSignal under the account’s id (user.id, the OneSignal External ID) and out again on sign-out — all from views/core/OneSignalInitializer.vue — and the server targets that alias, so a push reaches every device the user is signed in on. The OS permission prompt is asked once per install (the persisted onesignalPermissionRequested), never again on later launches. See Push & VoIP. Settings → Notifications controls this device:
  • Notifications on this device — opts this device in or out of OneSignal (useOneSignal().setPushSubscribed); the switch follows only once OneSignal accepted the change, otherwise it snaps back with a message. The choice is the settingsStore.pushNotifications flag: a device switched off stays opted out after every sign-in and is never prompted.
  • Permission — whether the OS lets the app show notifications, with Allow while it doesn’t (on iOS / Android a refused permission leads to the system settings).
  • Send test notification — a push to the account’s devices, which reports whether any was reached.
The desktop app and a build without VITE_ONESIGNAL_APP_ID show a one-line explanation instead of the switch.

Offline-first data & self-hosted instances

  • Offline-first data — services/offline/ keeps a local SQLite database as the UI’s source of truth and syncs it with the API in the background. The Notes tab is the worked example. See Offline-first data.
  • Self-hosted instance mode — a user can point the app at another deployment of your backend at runtime, with a URL + access token (sign-in screen → Connect an instance, or Settings). See Self-hosted instances.

Quick start

npm run switch_to_dev copies env/env.dev → .env, which points VITE_BACKEND_URL at the local backend (http://localhost:3001). Add any new var to src/vite-env.d.ts too — vite/client has an index signature, so a typo is not a type error, it just reads undefined.
WebView debugging follows the build type — Capacitor’s default, so capacitor.config.ts deliberately leaves webContentsDebuggingEnabled unset: debug builds (Run from Android Studio / Xcode) are inspectable via chrome://inspect / Safari Web Inspector, release builds (signed bundle / Archive) are not.

Environment

The VITE_REVENUECAT_* billing variables are covered in Billing. That’s the complete list — anything else is unused. The optional integrations — Google, Sentry, OneSignal, the legal, docs, developer and store links, and the RevenueCat keys — are read through envSetting() (src/helpers/env.ts): a value that is still the env.prod template’s REPLACE_ME_* placeholder counts as unset, so the integration stays off (no Google button, no push, default legal links) instead of running with a bogus key.

Native builds (Capacitor 8 / Tauri)

One npm run build serves every target: the web/PWA deploy gets pre-compressed .gz/.br assets for the HTTP server, and the last step (cap sync --inline) copies the bundle into ios/ and android/ — open Android Studio / Xcode right after it. Android drops the .gz/.br copies at packaging (ignoreAssetsPattern in android/app/build.gradle; AGP would otherwise fail on app.js + app.js.gz as duplicate assets), iOS carries them unused, and the Tauri desktop build (beforeBuildCommand) only compiles and skips them (Vite sees Tauri’s TAURI_ENV_PLATFORM). The ios/ and android/ native projects are committed (regenerate with npx cap add <platform> only for a clean slate); the desktop app lives in src-tauri/. isTauri in helpers/platform.ts tells the desktop shell apart (Capacitor reports it as web). External links go through openExternalUrl() (helpers/appLinks.ts), which opens them in the system browser everywhere — on desktop through tauri-plugin-opener (registered in src-tauri/src/lib.rs, allowed in src-tauri/capabilities/default.json), since the Tauri WebView would swallow window.open. Scripts: serve (dev server on :8100) · serve:desktop (Tauri dev) · fix (auto-fix by hand: Prettier + eslint --fix) · build (the full gate: Prettier + ESLint + vue-tsc + tests + web build + cap sync) · license-check (production-dependency licences) · bump (version, across package.json and every native project) — plus switch_to_dev / switch_to_prod, setup-https (HTTPS in dev) and re-install-deps (clean reinstall). Tests: *.test.ts next to the code — unit tests for the API client, token refresh, encrypted storage, the offline layer (its real SQL runs on an in-memory SQLite), stores, composables and routing, and component tests that mount every screen with the network and native plugins mocked (Vitest + @vue/test-utils in happy-dom, fake-indexeddb; shared helpers in src/test/ — after render(), reach stores through the returned store(useXStore), the screen’s own Pinia). build measures coverage and fails below 80% overall, 90% for composables, helpers, i18n, router, services, stores and the TypeScript in src/features/, or 80% for any single file. One file on its own: npx vitest run <file> --coverage.enabled=false. Keep the tests when you build on the kit: they are the quickest way to see that a change broke a shared mechanic.