todo-ui
Generated TanStack Start SSR application with Paraglide URL localization, Tailwind CSS v4, Vitest, and Nitro's standalone Node server output.
- Locales: en, de (base: en)
- Design system: design-system
Routes
| Path | Page |
|---|---|
/ | Public landing page. Signed out it links to /login and /login?mode=sign-up; signed in it links to /dashboard. |
/login | Sign in and sign-up (?mode=sign-up). ?redirect= is honoured only for same-origin paths (src/lib/safe-redirect.ts). |
/design | Design tokens and a Sidebar sample. |
/dashboard | Protected layout route (signed-out visitors go to /login?redirect=…, in the same locale): shadcn Sidebar, header with the theme toggle, and an <Outlet />. Its index redirects to /dashboard/todos. |
/dashboard/todos | The todos of the active workspace, each with who added it (the owner id resolved to a name from the workspace members; "you" for the caller, "a former member" when the member is gone) (src/features/todos/todo-list.tsx). |
/dashboard/settings | Settings, in parts chosen with tabs. Account (everyone, /account): five sections with SectionNav (?section=): profile (name, email, image), security (password, two-factor with an authenticator app, passkeys), sessions (list and revoke), linked accounts (GitHub, Discord) and delete account (src/features/account/). Workspace (/workspace, shown only to a workspace owner or admin, or to someone with no workspace yet): a Create workspace button, then Members (role and remove), Invites (create a copy-paste link, shown once, and revoke) and General (rename, transfer ownership, delete), each control shown by the caller's role through isRoleAllowed (src/features/workspace-settings/). Reached from the profile menu. The workspace switcher is at the top of the sidebar (src/features/workspaces/), under the app name, which links to the landing page. Invitations addressed to the signed-in email show as a banner at the top of the dashboard with a Join button (invitations.listMine, acceptMine), and as Pending rows in Members for people who can invite. /dashboard/account and /dashboard/workspace redirect here. |
/dashboard/admin | Admins only: a users table (search by email, role or banned filter, sort, paging) with create user and a per-row menu for role, ban or unban, a user's sessions, set password and remove (src/features/admin/). Not offered for your own row: ban, remove and role change. |
/dashboard/invite/$token | Accepts a workspace invite: a Join button calls invitations.accept, then makes that workspace active. A signed-out visitor is sent to login and back by the dashboard guard. |
Every path also exists under /de/.
Login
The browser talks to iam-service through Better Auth's client (src/lib/auth-client.ts). The session is an httpOnly cookie set by IAM, so it never appears in document.cookie; requests use credentials: "include".
The cookie reaches IAM only when both are on the same site (same registrable domain, or one reverse proxy; localhost ports count as one site). IAM must list this app's origin in IAM_SERVICE_TRUSTED_ORIGINS, which also drives its CORS allow-list. Todo calls still send the dev bearer until tenants arrive.
The guard is beforeLoad on src/routes/dashboard.tsx: it calls the getSession server function (src/lib/session.ts), which forwards the request's Cookie header to iam-service's GET /api/auth/get-session and treats any error as signed out. Every sub-route inherits it, on SSR and on client navigation. It is UX only; it protects nothing on the server.
Admin-only pages. set roles: ["admin"] in staticData.nav to hide the sidebar entry from other roles, and add a beforeLoad that redirects when context.user.role !== "admin" (see src/routes/dashboard/admin.tsx). Both are UX only: iam-service's admin endpoints refuse a non-admin, and refuse self-ban, self-remove and changing your own role (services/iam-service/README.md). A ban, a revoked session or a role change reaches a browser that still holds its cookie only after IAM_SERVICE_SESSION_COOKIE_CACHE_SECONDS.
Add a dashboard page. create one route file src/routes/dashboard/<name>.tsx with staticData: { nav: { icon, label: () => m.<key>(), order } }. The sidebar builds its menu from the routes that carry staticData.nav (see src/features/dashboard/dashboard-nav.ts), so nothing else changes. Add the label to messages/en.json and messages/de.json.
Configuration
The browser reads VITE_IAM_SERVICE_URL; the server-side guard reads IAM_SERVICE_URL.
| Variable | Default | Purpose |
|---|---|---|
VITE_IAM_SERVICE_URL | http://localhost:33001 | Origin of iam-service. |
IAM_SERVICE_URL | http://localhost:33001 | Server-side origin of iam-service that getSession asks (see The guard). |
Tests
The test target runs the Vitest suite under src/ (jsdom, no services).
The e2e target runs the Playwright specs in e2e/ (chromium only) against real services. It runs locally
only: the repo has no CI pipeline. It is not cached and is not part of test or pnpm verify.
- Once per machine:
pnpm exec playwright install chromium. - Set
E2E_PASSWORD(at least 8 characters) in the root.env(gitignored) or the shell. Never commit it. - Start Mongo with
pnpm infra:up. Runningiam-service(port 33001) andtodo-ui(port 4200) servers are reused; missing ones are started by Playwright.
e2e/global-setup.ts signs up a throwaway e2e-<timestamp>@example.com user through IAM's /api/auth/sign-up/email and
saves its session cookies to e2e/.auth/ (gitignored). The account password spec signs up its own user, so no shared
login is ever changed. Traces, videos and the HTML report are off because they record typed password values. IAM allows
5 sign-ups and 5 sign-ins per minute per IP and a run uses 2 of each, so wait a minute between back-to-back runs.
Commands
pnpm nx run todo-ui:typecheck # type-check the app and the e2e specs
pnpm nx run todo-ui:test # run the Vitest suite
pnpm nx run todo-ui:dev # run locally
pnpm nx run todo-ui:build # build the Nitro output
pnpm nx run todo-ui:e2e # run the Playwright end-to-end tests (see Tests)
pnpm nx run todo-ui:generate-i18n # compile the Paraglide messages
pnpm nx run todo-ui:docker:build # build the runtime image
pnpm nx run todo-ui:docker:run # run the runtime image