FastAPI backend (Python 3.11, httpx for SignalR/GraphQL — no MSSQL ODBC), shares kitchen_db directly. React/TS/Vite fullscreen board frontend. Backend: auth.py (APP_SLUG=kds, SimpleNamespace), main.py (4 KDS migrations, SignalR start/stop), kds.py router, models (kds/settings/resos — read from kitchen_db), signalr_listener.py (backoff pre-existing), kds_graphql.py, database.py. Requirements stripped to ~9 packages; image ~400 MB lighter than kitchen (no MSSQL ODBC layer). Frontend: AuthGate (app=kds), single fullscreen route, dark board theme. KDS.tsx URL prefix patched (/api/kds/ → /kds/api/kds/), recipe images cross-app (/kitchen/api/recipes/). nginx: 5 blocks with SSE proxy headers on /kds/api/ block. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
59 lines
3 KiB
Bash
59 lines
3 KiB
Bash
#!/usr/bin/env bash
|
|
# Phase 2 setup — copy KDS-specific archive files into kds/
|
|
# Run once from the repo root: bash kds/_copy_from_archive.sh
|
|
set -euo pipefail
|
|
|
|
ARCHIVE=/home/jtr/laptop-archive/kitchen-invoice-flash-docker
|
|
DEST=/home/jtr/dev/HNF-PROXMOX/kds
|
|
|
|
echo "==> Copying KDS backend from archive..."
|
|
|
|
# KDS API router
|
|
cp "$ARCHIVE/backend/api/kds.py" "$DEST/backend/api/"
|
|
|
|
# KDS models
|
|
cp "$ARCHIVE/backend/models/kds.py" "$DEST/backend/models/"
|
|
cp "$ARCHIVE/backend/models/settings.py" "$DEST/backend/models/"
|
|
cp "$ARCHIVE/backend/models/resos.py" "$DEST/backend/models/"
|
|
|
|
# KDS migrations (4 files — add kds_tables, course_flow, order_tracking, bookings_refresh)
|
|
cp "$ARCHIVE/backend/migrations/add_kds_tables.py" "$DEST/backend/migrations/"
|
|
cp "$ARCHIVE/backend/migrations/add_kds_course_flow.py" "$DEST/backend/migrations/"
|
|
cp "$ARCHIVE/backend/migrations/add_kds_order_tracking.py" "$DEST/backend/migrations/"
|
|
cp "$ARCHIVE/backend/migrations/add_kds_bookings_refresh.py" "$DEST/backend/migrations/"
|
|
|
|
# SignalR listener (already has exponential-backoff reconnect — log A12 satisfied)
|
|
cp "$ARCHIVE/backend/services/signalr_listener.py" "$DEST/backend/services/"
|
|
|
|
# SambaPOS GraphQL client (httpx-based — no MSSQL/ODBC needed in KDS)
|
|
cp "$ARCHIVE/backend/services/kds_graphql.py" "$DEST/backend/services/"
|
|
|
|
# database.py — same asyncpg/SQLAlchemy setup as kitchen
|
|
cp "$ARCHIVE/backend/database.py" "$DEST/backend/"
|
|
|
|
echo "==> Patching auth import in api/kds.py..."
|
|
# Replace old local JWT import with new central-auth import
|
|
sed -i 's/from auth\.jwt import get_current_user/from auth import get_current_user/g' \
|
|
"$DEST/backend/api/kds.py"
|
|
# Remove old User model import from kds.py — now uses auth stub (auth.py returns SimpleNamespace)
|
|
sed -i 's/^from models\.user import User$/from models.user import User # type stub — actual user is SimpleNamespace from auth.py/g' \
|
|
"$DEST/backend/api/kds.py"
|
|
|
|
echo "==> Copying KDS frontend page..."
|
|
# KDS.tsx: full board UI — patch URL prefix from /api/kds/ to /kds/api/kds/
|
|
cp "$ARCHIVE/frontend/src/pages/KDS.tsx" "$DEST/frontend/src/pages/"
|
|
sed -i "s|fetch('/api/kds/|fetch('/kds/api/kds/|g" "$DEST/frontend/src/pages/KDS.tsx"
|
|
sed -i "s|new EventSource('/api/kds/|new EventSource('/kds/api/kds/|g" \
|
|
"$DEST/frontend/src/pages/KDS.tsx"
|
|
# Recipe images cross-app: KDS fetches recipe images from kitchen backend
|
|
sed -i "s|src={\`/api/recipes/|src={\`/kitchen/api/recipes/|g" \
|
|
"$DEST/frontend/src/pages/KDS.tsx"
|
|
# Also handle token-based Authorization headers in KDS fetch calls:
|
|
# KDS.tsx uses { headers: { Authorization: ... } } from useAuth().token.
|
|
# token = '__session__' (truthy sentinel) — header is sent but ignored by backend;
|
|
# cookie auth (hnf_session) is used instead. No change needed: same-origin fetches
|
|
# send cookies automatically. B5b tracking not required for KDS (only ~8 endpoints).
|
|
|
|
echo ""
|
|
echo "Done. Verify build: cd kds && docker compose build && cd frontend && npm install && npm run build"
|
|
echo "Deploy order: commit → push to Forgejo → then pct exec 125 ..."
|