ADR 0016: Two front ends, served from the API's own origin - the console at `/`, the floor PWA at `/m/`
Status: Accepted; superseded in part by ADR 0031 (the console add-on gate and floor role gates) and ADR 0037 (the browser client is standards-based OIDC and managed Keycloak is optional).
Context
Karyo has two audiences with little in common at the screen. Office staff - planners, supervisors, administrators - work at desks with large screens: configuring the warehouse, managing orders, reading reports. Floor operators work on phones and enterprise scanners, usually one-handed while holding goods, driven by scans rather than typing, over wireless coverage that drops out between racks.
Both call the same REST API (ADR 0017). Floor devices need updates without an app-store cycle, and the enterprise scanners in use run Chrome-based browsers that accept a hardware scan as keyboard input.
Decision
- Two separate single-page applications, both React and TypeScript, built with Vite: the desktop
console in
frontend/weband the floor progressive web app infrontend/mobile. They have separate source trees, route tables and test projects; they are not one responsive build. - One nginx container serves both applications and the API from a single origin: the console at
/, the floor app at/m/(built withbase: '/m/'), each with its own fallback;/api/is proxied to the application and/api/internal/is refused. The optional managed-Keycloak profile also proxies/auth/; an external OIDC issuer need not live in this stack. - Both use the same configured public OIDC client with authorization code and PKCE. Managed
Keycloak names it
karyo-web; external providers may use another configured client id. - The floor app queues selected operations offline. Pick confirmation, transport start and completion, count submission, "location empty" and release are queued in IndexedDB when the device is offline and replayed in order when it reconnects; a sync-issues screen shows any that failed. Every other floor operation needs the network.
- The console gates only administration by role.
/admin/*is guarded byuser-admin, with integrations separately underintegration-admin; everything else requires only authentication, and operational authority is enforced by the API. Engine pages are ordinary routes. The console does not read the compatibility licence endpoint or carry add-on metadata.
Consequences
- There is no cross-origin request in the shipped topology, so no CORS configuration exists and none is needed, and there is one place to terminate TLS.
- One language and one framework across both applications and the browser tests.
- Deploying a new image updates every floor device on its next load.
- A browser client served from any other origin cannot call the API: no CORS headers are sent.
- Two applications have to be kept in step: dependency versions, the Keycloak adapter, the API client.
- Offline working is partial by design. Only the queued operations survive a dropout.
- The floor app has no licence awareness and needs none: Sort and Pack-out, which belong to the wave capability, are on the menu of every installation and work on every installation (ADR 0030).
- Neither browser application has licence awareness. The compatibility licence endpoint remains available to integrations, but browser navigation and pages do not call it.
Alternatives considered
- Native floor applications, or React Native or Flutter. Rejected. Native apps mean two codebases and an app-store release cycle; React Native or Flutter mean a second rendering framework or a third language beside Kotlin and TypeScript. The floor interface is forms, lists and scanning, which do not need native performance, and keyboard-wedge scanners work in a browser.
- Vue, Angular or Svelte for the console. Rejected for React's larger component ecosystem and contributor pool; Angular additionally for its weight and learning curve for developers who mostly work in Kotlin.
- Server-side rendering (Next.js). Rejected. An authenticated internal application gains nothing from server rendering and would need a Node server in the stack.
- An API gateway product or a mobile backend-for-frontend in front of the application. Rejected.
Their purpose is routing to many services and aggregating their responses; with one application
behind nginx, both clients call the same
/api/v1routes directly. - One responsive application for both audiences. Not recorded as considered.
Evidence
infrastructure/docker/nginx/nginx.conf,location /api/internal/, location /api/, location /auth/, location /m/, location /-/api/internal/refused,/api/and/auth/proxied,/m/and/served with their fallbacksinfrastructure/docker/Dockerfile.nginx,COPY --from=builder, COPY --from=mobile-builder- both builds copied into one image, the floor app underm/frontend/mobile/vite.config.ts,base- the floor app's/m/basefrontend/web/package.json,dependencies, devDependenciesandfrontend/mobile/package.json,dependencies, devDependencies- React, React Router and the PWA pluginfrontend/mobile/src/lib/offline/op-queue.ts,QueuedOp, DB, STORE- the operations that may be queued, and the IndexedDB storefrontend/mobile/src/lib/work-api.ts,workApi- an operation queued when offline instead of failingfrontend/mobile/src/routes/router.tsx,router- the floor app's routes, including/sync-issuesfrontend/web/src/routes/router.tsx,router- every console route under one authentication guardfrontend/web/src/pages/__tests__/engine-pages.test.tsx,every engine page renders through its normal path test suite- engine pages do not call the compatibility licence endpointfrontend/mobile/src/menu/registry.ts,MENU- Sort and Pack-out on the floor menu, shown with the Waves capability since ADR 0052
Related
- ADR 0013 - the shared public client
- ADR 0017 - the API both front ends call
- ADR 0030 - why no capability is withheld, and what the console does when the licence request fails
- ADR 0022 - the nginx container in the stack
- Frontend - routing and authentication guards in detail
- User guide - both applications from the user's side