feat(terminal): terminal app shell, pos-terminal image, LAN-only proxy port 8082 (platform-v2 3.1b)
- terminal/: new workspace app (Vite + React 19 + Router 7, Tailwind on the shared preset, @xenia/i18n namespace `terminal`, @xenia/api client sending X-Xenia-Device, @xenia/access bootstrap). Apps are lazy chunks by app_key (kds, pos_counter, customer_display placeholders); start screen; "unknown app" screen; dev-only /ui-gallery and /i18n-sample. Device + session tokens in a storage wrapper. - Image pos-terminal (terminal/Dockerfile, context client-services/); every frontend Dockerfile copies terminal/package.json for npm ci. - docker-compose(.dev).yml: service terminal; proxy publishes 8082. - Proxy (nginx-proxy/nginx.conf == install.sh heredoc, CS-5): server :8082, LAN-only allow/deny, WebSocket upgrade; the terminal upstream is resolved per request so the proxy still starts on a stack without the terminal container. - install.sh prints the screens address. - Tests: terminal unit tests + lint in run-all; new tests/e2e/stack.mjs (release images on one compose stack: :8082 serves the app, /api + WebSocket through both hops, 403 from a non-LAN docker network on 8082 and 8081, proxy up without terminal). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+9
-5
@@ -15,7 +15,8 @@ This folder is its **own git repo**, nested inside the `xenia-pos` parent repo.
|
||||
| `local_backend` | FastAPI + SQLAlchemy + SQLite (`/app/data/pos.db`) | 8000 | only through proxy / inner nginx | `pos-backend` |
|
||||
| `waiter_pwa` | React + Vite + vite-plugin-pwa, axios, zustand, react-query, Dexie (IndexedDB) | 5173 | **`http://<LAN IP>`** (80, LAN only) · `https://waiter.<domain>` / `https://<IP>` (443) | `pos-waiter` |
|
||||
| `manager_dashboard` | React + Vite | 5174 | **`http://<LAN IP>:8081`** (LAN only; `http://<IP>/manager` redirects there) · `https://manager.<domain>` (443) · `https://<IP>:4443` | `pos-manager` |
|
||||
| `proxy` | nginx:alpine | — | 80, 443, 4443, 8081, 8443. See the header of `nginx-proxy/nginx.conf` for the full routing map. Waits for the backend to be healthy | stock |
|
||||
| `terminal` | React + Vite (platform v2, phase 3): one app for every paired screen (KDS, counter POS, customer display), apps as lazy chunks by the device's `app_key` | 5175 | **`http://<LAN IP>:8082`** (LAN only) | `pos-terminal` |
|
||||
| `proxy` | nginx:alpine | — | 80, 443, 4443, 8081, 8082, 8443. See the header of `nginx-proxy/nginx.conf` for the full routing map. Waits for the backend to be healthy; `terminal` is resolved per request, so the proxy also starts without it | stock |
|
||||
|
||||
### Request path in production
|
||||
Phones normally use **plain HTTP by LAN IP** (`http://<HOST_IP>` → proxy:80 default_server). Only private source IPs are allowed; everything else gets 403.
|
||||
@@ -48,7 +49,8 @@ The manager calls the API **same-origin, with relative paths**. The waiter app r
|
||||
| `nginx-proxy/nginx.conf` | Proxy config used in dev / by hand |
|
||||
| `install.sh` | Site installer. **Writes its own copy of the proxy config.** |
|
||||
| `docker-compose.yml` / `docker-compose.dev.yml` | Prod (pull images) / dev override (build + expose ports) |
|
||||
| `package.json`, `package-lock.json`, `packages/` | **npm workspace** for the frontends (D-15): `waiter_pwa`, `manager_dashboard` and the shared `packages/{ui,i18n,api,access}` (imported from source, no build step). One lockfile at this root; the apps have none of their own. |
|
||||
| `package.json`, `package-lock.json`, `packages/` | **npm workspace** for the frontends (D-15): `waiter_pwa`, `manager_dashboard`, `terminal` and the shared `packages/{ui,i18n,api,access}` (imported from source, no build step). One lockfile at this root; the apps have none of their own. |
|
||||
| `terminal/` | The terminal app (phase 3): `src/apps/registry.js` (which apps a screen runs, lazy chunks), `src/device/storage.js` (device + session tokens), `src/api/client.js` (`X-Xenia-Device` on every request). Lint covers all of `src` |
|
||||
| `packages/ui/` | Shared design tokens, Tailwind preset and base components (CS-16). Visual check: `npm run dev:manager` → `/ui-gallery` |
|
||||
| `packages/api/` | Shared HTTP client (`createApiClient`: session/device headers, `err.xenia` codes, the manager-approval retry) and the live WebSocket client with cursor replay (`createLiveClient`, used by the waiter's `useWebSocket`) (CS-18) |
|
||||
| `packages/access/` | `<AccessProvider>` (bootstrap → modules, permission keys, venue, language; mounts the approval dialog), `useCan`, `useModule`, `<Can>`, `<RequireModule>` (CS-18) |
|
||||
@@ -82,7 +84,8 @@ Prices, costs and discounts are copied onto order items and logs when the action
|
||||
**CS-5. The proxy config lives in two places and must stay byte-identical.**
|
||||
`install.sh` writes the heredoc on client sites, and `nginx-proxy/nginx.conf` is the repo copy. Edit both together (global Rule 9) and check with:
|
||||
`sed -n "/<< 'EOF'/,/^EOF/p" install.sh | sed '1d;$d' | diff - nginx-proxy/nginx.conf`
|
||||
The plain-HTTP servers (80 default_server, 8081) must keep their LAN-only `allow`/`deny` block.
|
||||
The plain-HTTP servers (80 default_server, 8081, 8082) must keep their LAN-only `allow`/`deny` block (`tests/e2e/stack.mjs` checks 8081 and 8082 from a non-LAN network).
|
||||
A frontend image's Dockerfile copies **every** workspace's `package.json` before `npm ci` (the lockfile covers them all): a new workspace app adds its line to all of them.
|
||||
|
||||
**CS-6. Permissions are checked on the backend.**
|
||||
Hiding a button in the UI is not access control. Every new endpoint declares its access with a marker from `core/access/deps.py` (see CS-14).
|
||||
@@ -109,11 +112,12 @@ cd local_backend; uvicorn main:app --reload --port 8000
|
||||
# Dev: frontends (Vite proxies /api and /api/ws to :8000)
|
||||
cd waiter_pwa; npm run dev # :5173
|
||||
cd manager_dashboard; npm run dev # :5174
|
||||
cd terminal; npm run dev # :5175 (paired screens; pairing from 3.1c)
|
||||
cd waiter_pwa; npm run lint
|
||||
|
||||
# Build release images (VERSION comes from .env). See the parent's DEPLOYMENT_GUIDE.md.
|
||||
docker compose -f docker-compose.yml -f docker-compose.dev.yml build
|
||||
docker push registry.bonamin.net/pos-backend:<ver> # + pos-waiter, pos-manager
|
||||
docker push registry.bonamin.net/pos-backend:<ver> # + pos-waiter, pos-manager, pos-terminal
|
||||
```
|
||||
|
||||
## Native Android app (waiter_pwa)
|
||||
@@ -151,7 +155,7 @@ The native plugins (`@capacitor/*`, `@capgo/*`) are pinned to **exact** versions
|
||||
## Testing
|
||||
Automated tests cover the native-app/LAN work and licensing. See **[tests/e2e/README.md](../tests/e2e/README.md)**.
|
||||
- **Unit (seconds):** `python -m pytest tests -q` in `local_backend/`, `npm test` in `waiter_pwa/`, and `npm test -w <@xenia/ui|@xenia/i18n|@xenia/api|@xenia/access|manager-dashboard>` at the workspace root.
|
||||
- **End-to-end:** `node run-all.mjs` in `tests/e2e/`. That covers install.sh, licensing with a real cloud, browser modes, and the Android emulator suites. `--no-android` skips the emulator.
|
||||
- **End-to-end:** `node run-all.mjs` in `tests/e2e/`. That covers install.sh, licensing with a real cloud, browser modes, a compose stack of the release images (`stack.mjs`), and the Android emulator suites. `--no-android` skips the emulator.
|
||||
|
||||
**CS-11. Tests follow the code.** When you change something a test covers (licensing, LAN IP, TLS, pairing, rediscovery, bundles, install.sh, the proxy config), run its suite and update the test in the same commit. Run `node run-all.mjs` before every release.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user