SPMS (Super Property Management System) — local-first property management with a shared backend and a web frontend:
Web UI: FastAPI + HTMX server ( ui.web.server:app , launcher.py , main.py ) for browser access on desktop/mobile, LAN, or behind a reverse proxy.
Architecture: all business logic lives in src/app_core/ (DB, services, paths, assistant, integrity/doctor, updater, barcode/batch logic, support/reporting) and is used by ui/web/ . SQLite is the datastore.
Front desk & reservations: guests (including 360° portfolio views), rooms/rate plans, availability, create/check-in/checkout flows, folio/balances, payments/refunds where applicable, invoices/receipts.
POS & inventory: catalog, walk-in and reservation-linked sales, recipes/meals/ingredients with auto-deduction, expenses, and traceable barcodes/SKUs/lots .
Batch/lot traceability & FEFO: inventory supports batch/lot tracking with received date/time, expiry date, remaining/received quantity, unit cost, supplier/reference/notes, status/expiry state, and movements. Supports FEFO-aware (First Expired, First Out) workflows, expiring/expired batch review, batch/lot lists, and barcode/SKU/lot trace (resolved item or lot with received/expiry/remaining and recent movements when available).
Activities/trips: register/book activities/excursions, track bookings/stats, and post charges to folios/invoices.
Accounting, reports & analytics: ledger, operational/financial reports and analytics/exports (as available in the app).
Grounded assistant (read-only): Web assistant answers from real app data/tools (ops, reports, guests/portfolios, reservations/balances, inventory including expiring batches, batch lists, barcode/lot trace, activities/bookings, integrity/health, and app version/update status). Assistant follows configured unlock/allowlist policy and remains read-only.
Integrity & health: read-only ledger/data integrity checks in-app, CLI doctor ( python -m app_core.doctor ), safe backup/verify helpers, and web liveness/readiness probes GET /health , GET /healthz , GET /readyz .
Issue reporting (privacy-first): Web Report issue ( /support/report ) and CLI python -m app_core.support generate sanitized diagnostics (no passwords/secrets/tokens/CSRF/session/recovery codes or DB/guest/payment records), let you review/edit details, download/copy Markdown or JSON reports (including device/OS info and recent in-app steps), open a prefilled GitHub issue, or upload the downloaded JSON report via the landing page (if configured) so it can be delivered to maintainers. Unhandled web errors show a friendly “Report this issue” page with prefilled context.
In-app updates (git installs): Settings → App updates supports Check for updates , changelog/commit details, and Apply/Update via git fast-forward . Local source changes must be committed/stashed/discarded before apply.
Backups & data safety: create verified DB backups from Settings ( Backup now , subject to unlock/CSRF as applicable) or CLI/scripts. Runtime data is preserved across source updates; restore is manual and offline .
Operational requirements (important)
SQLite / single worker: always run the web server with --workers 1 . Do not increase worker count.
Web secret key: set PM_WEB_SECRET_KEY to a strong random value for any non-local/shared/LAN/remote deployment.
HTTPS / transport security: bind to 127.0.0.1 for local-only use. For LAN/remote/browser access, use HTTPS (reverse proxy that terminates TLS) or a private network (VPN/Tailscale/SSH tunnel). Do not expose plain HTTP publicly.
Data directory & permissions: runtime data lives in PM_DATA_DIR or app defaults/legacy locations (DB, exports, invoices). Ensure the process user can read/write the data directory and keep a single writer.
Data preserved across updates: source/app updates (in-app fast-forward or git pull --ff-only ) do not modify runtime data (DB, exports, invoices, configured data dir). DB migrations run on startup and are additive where applicable.
Restart after apply: after applying an in-app update, restart the app/server to load the new version.
Local source changes: in-app apply requires a clean working tree for fast-forward; commit, stash, or discard local changes first.
Backups before risky operations: take and verify backups before upgrades/migrations, restores, or major operational changes.
No destructive one-click restore: restore is deliberate/manual/offline (stop app, verify backup, replace files, start, verify integrity).
Security model: web state-changing requests are CSRF-protected; sensitive/destructive/admin mutations require super-password unlock (and CSRF) per policy, while some routine operational/front-desk flows remain usable with CSRF only. See docs/web_authz_matrix.md .
Quick decision: how to run
One-line install / update (all supported OS families)
These commands are intended for first-time install and later re-runs on git-based installs: they bootstrap prerequisites where possible, clone/update (fast-forward), refresh dependencies, preserve runtime data, and launch/run per selected mode. Always keep web on --workers 1 . For shared/non-local/LAN/remote web access, set a strong PM_WEB_SECRET_KEY and use HTTPS via reverse proxy/VPN/private networking (do not expose plain HTTP publicly). Built-in recovery: if an install/update gets stuck due to dirty tree, stale .git/index.lock , stuck merge/rebase, or ff-only/checkout errors (e.g. Reset branch 'main' ), rerun with REPAIR=1 (Unix/Termux) or -Repair / $env:REPAIR='1' (Windows) to auto-recover by resetting local source to the target branch (runtime data in PM_DATA_DIR /external data dirs is not removed by git).
Common env vars / parameters (Unix installer/setup): INSTALL_DIR , REPO_URL , BRANCH , GIT_REF / TAG / COMMIT (pinned ref), MODE ( web ; legacy values map to web), ACTION ( auto|setup|run|deploy ), SKIP_WEB ( auto|0|1 ), HOST , PORT , PYTHON , INSTALL_DEV , RUN_TESTS , PM_DATA_DIR , PM_WEB_SECRET_KEY . Windows: pass -GitRef / -Action / -Mode / -BindHost / -Port or set corresponding env vars ( GIT_REF / TAG / COMMIT , etc.).
ACTION=auto (default): full install+launch if missing, else update deps/code and launch.
ACTION=setup : install/update/prepare only. ACTION=run : run existing install. ACTION=deploy : setup + run.
Runtime data (DB/exports/invoices/ PM_DATA_DIR ) is preserved by scripts/updates.
Pinned/reproducible installs
Install/update to a specific tag/commit/branch: GIT_REF= sh (Unix) or -GitRef / $env:GIT_REF= (Windows). Aliases: TAG , COMMIT .
Pinned bootstrap script URL: use the raw script at the same ref to ensure installer logic is reproducible, e.g. /scripts/install.sh (Unix) or .../ /scripts/install_windows.ps1 (Windows).
Existing checkouts: GIT_REF= ACTION=setup sh scripts/setup.sh (or Windows setup script) checks out the requested ref; when on a branch, scripts may fast-forward as applicable. Runtime data is preserved.
For immutable production-like deployments, prefer pinning to a release tag/commit and recording the resolved commit ( git -C rev-parse HEAD ) alongside backups/change records.
Dependency/install robustness (constrained environments)
Web dependency/toolchain issues: if web dependency installation/build fails (e.g. pydantic-core /Rust wheel issues on constrained environments), install/upgrade Python/build tools or a compatible prebuilt wheel, or run the web app on a fuller host.
pydantic-core / Rust wheel issues: on iSH/Termux/older CPU architectures or limited toolchains, some web deps may require Rust/cargo/build tools or a prebuilt wheel matching your Python version/architecture. If unavailable, upgrade Python/toolchain, install build deps, or run the Web UI on a supported host.
SQLite web safety: always run the web server with --workers 1 . Use PM_WEB_SECRET_KEY and HTTPS reverse proxy/VPN for non-local/shared access. Runtime data ( PM_DATA_DIR , DB, exports, invoices) is preserved across setup/update runs.
Platform-specific setup
Linux / macOS / WSL / Unix-like
Use scripts/install.sh (bootstrap) or scripts/setup.sh from a checkout.
Examples: sh scripts/setup.sh (setup), MODE=web ACTION=deploy sh scripts/setup.sh , MODE=web HOST=127.0.0.1 PORT=8000 ACTION=deploy sh scripts/setup.sh .
WSL: treat as Linux; bind carefully for LAN access and account for Windows firewall/port forwarding.
If web dependencies cannot be built on-device, run the Web UI on a supported host and access it from the browser.
iOS/iPadOS as web client
Run the server on a capable host (Mac/Linux/Windows/Termux/RPi/VPS) and open from Safari ( http:// :8000 on LAN or via reverse proxy/Tailscale/VPN). Add to Screen for app-like use.
Windows (10/11, Server)
Bootstrap (recommended): PowerShell (Admin recommended for winget): irm https: // raw.githubusercontent.com / Michaelhehelmy / spms / main / scripts / install_windows.ps1 | iex Customize: $env:ACTION='deploy'; $env:MODE='web'; $env:HOST='127.0.0.1'; $env:PORT='8000'; $env:PM_WEB_SECRET_KEY='...'; irm ... | iex
From existing checkout: powershell - ExecutionPolicy Bypass - File scripts\install_windows.ps1 - Action deploy - Mode web powershell - ExecutionPolicy Bypass - File scripts\setup_windows.ps1 - Action deploy - Mode web - BindHost 127.0 . 0.1 - Port 8000 scripts\ install_windows.cmd - Action deploy - Mode auto
If winget is unavailable, install Python 3.10+ (PATH) and Git, then re-run. Scripts attempt to refresh PATH/bootstrap prerequisites.
Manual install (any OS with Python)
pyproject.toml also defines extras/scripts ( .[web] , .[dev] , property-manager , pm , etc.) for packaging workflows.
Web deployment essentials
Workers: --workers 1 only (SQLite/shared state). Never increase workers.
Bind: 127.0.0.1 local-only; 0.0.0.0 reachable on interfaces (LAN). Manage firewall exposure explicitly.
Secret: set PM_WEB_SECRET_KEY to a strong random value for any non-local/shared deployment (required for non-loopback use unless an explicit local/dev insecure override is set).
TLS/remote access: use reverse proxy with HTTPS or a private network (VPN/Tailscale/SSH tunnel). Do not expose plain HTTP publicly.
Data directory & permissions: set PM_DATA_DIR if needed; ensure the service user can read/write the data directory and run with a single writer.
Health probes: GET /health and GET /healthz (liveness/basic health with readiness summary), GET /readyz (readiness/runtime checks including data-dir writability). Keep probes and app on --workers 1 .
Service/autostart: use systemd/launchd/NSSM/Task Scheduler/supervisor/Docker restart policy to run venv Python/uvicorn with --workers 1 .
Reverse proxy: proxy to 127.0.0.1:8000 , terminate TLS, and forward standard proxy headers as needed.
Backups, restore, updates: take and verify backups before upgrades/migrations; restore is manual/offline (with restore drill validation recommended); restart the app/server after applying updates.
App icon / launcher: no native installer icons are bundled. For browser/mobile install use "Add to Screen" (add PWA assets like manifest.webmanifest and icons under ui/web/static/ and link from ui/web/templates/base.html if needed); for Windows/Linux create OS shortcuts ( .lnk / .desktop ) pointing to the venv launcher with a custom icon.
See docs/DEPLOYMENT.md and docs/SECURITY.md for examples and hardening.
Security model (Web) — summary
CSRF: all state-changing web requests (POST/PUT/PATCH/DELETE) are CSRF-protected (form tokens and/or header/middleware enforcement per request type).
Super-password unlock: sensitive/destructive/admin mutations require active unlock (super password) in addition to CSRF (financial/accounting operations, inventory/stock/batch/recipe/meal/activity changes, voids/refunds/cancels/deletes/modifications, exports/backups/seed/demo/settings changes, labels, protected downloads where applicable, etc.).
Routine operational flows: some front-desk/POS operations may remain usable with CSRF where appropriate, but policy-sensitive overrides/destructive actions remain gated by unlock.
Assistant: follows configured unlock/allowlist policy while remaining read-only and grounded.
Secrets & transport: strong PM_WEB_SECRET_KEY , HTTPS/private networking for shared/remote access.
Reference: docs/web_authz_matrix.md is the authoritative route-group matrix for ui/web . See docs/SECURITY.md for hardening checklist.
In-app (recommended for git installs): Settings → Updates & Health → App updates → Check for updates → Update now / Apply appears only when an update is available (git fast-forward for clean checkouts).
Automated: check/fetch metadata, show changelog/commits, apply ff-only when eligible.
Requirements/limits: clean working tree required; non-fast-forward/diverged histories need manual git resolution.
Data preserved: DB, exports, invoices, and configured data directory ( PM_DATA_DIR /defaults) are not modified by source updates.
After apply: restart the app/server to load the new version. If dependencies changed, refresh the venv via setup scripts.
Update notifications (auto-check): built-in polling-based checks run when online (cached/rate-limited, configurable via auto_check_updates / auto_update_check_interval_hours ) and notify in the web UI when updates/releases are available. Git installs can be applied in-app (ff-only) then restarted; native/packaged installs require downloading/installing the new release artifact. No push infrastructure; auto-apply is not enabled by default.
First-time update / platform guides: Windows: rerun scripts/install_windows.ps1 (or git pull --ff-only + scripts\setup_windows.ps1 -Action setup ) then restart. Termux: rerun scripts/install.sh with MODE=web ... --workers 1 (or manual ff-only + setup) then restart. Details in docs/UPDATES.md .
Manual CLI: git pull --ff-only then re-run setup to refresh deps if needed (Unix/Termux: MODE= ACTION=setup sh scripts/setup.sh , Windows: scripts\setup_windows.ps1 -Action setup ).
See docs/UPDATES.md for release/update/rollback guidance.
Integrity, health checks & doctor
In-app (read-only): ledger/data integrity checks available in Web UI and via grounded assistant queries.
CLI doctor: PYTHONPATH=src python -m app_core.doctor (or scripts/backup_runtime.* --doctor ) for operational health checks. Supports --json , --check-updates , --strict , and safe backup/verify helpers: --backup [--backup-to ] , --verify-backup / --verify .
Web probes: GET /health , GET /healthz , GET /readyz for liveness/readiness (and detailed readiness checks).
Create backups (automated/helpers): Web UI: Settings → Backup now (subject to unlock/CSRF as applicable). CLI: python3 scripts/backup_runtime.py --backup [--to ] , python3 scripts/backup_runtime.py --verify , python3 scripts/backup_runtime.py --doctor [--json] [--check-updates] , or PYTHONPATH=src python -m app_core.doctor --backup/--verify-backup . Wrappers: scripts/backup_runtime.sh , scripts/backup_runtime.cmd , scripts/backup_runtime.ps1 .
Web UI: Settings → Backup now (subject to unlock/CSRF as applicable).
CLI: python3 scripts/backup_runtime.py --backup [--to ] , python3 scripts/backup_runtime.py --verify , python3 scripts/backup_runtime.py --doctor [--json] [--check-updates] , or PYTHONPATH=src python -m app_core.doctor --backup/--verify-backup .
Wrappers: scripts/backup_runtime.sh , scripts/backup_runtime.cmd , scripts/backup_runtime.ps1 .
Preserve: DB, exports, invoices, and data dir ( PM_DATA_DIR or defaults). Take backups regularly and before upgrades/migrations.
Restore (manual, offline): no destructive one-click in-app restore. Stop app/server. Verify candidate backup ( --verify / --verify-backup ). Copy current DB/files as safety backup. Replace active DB (and related exports/invoices if needed) with verified backup in the correct data directory. Start app/server ( --workers 1 for web); migrations run on startup. Verify with doctor/integrity checks and app smoke tests.
Verify candidate backup ( --verify / --verify-backup ).
Copy current DB/files as safety backup.
Replace active DB (and related exports/invoices if needed) with verified backup in the correct data directory.
Start app/server ( --workers 1 for web); migrations run on startup.
Verify with doctor/integrity checks and app smoke tests.
See docs/BACKUP_RESTORE.md for DR guidance.
E2E: browser-driven Playwright suite — see docs/E2E_TESTS.md (run locally with .venv-build/bin/python -m pytest tests/e2e -q ).
Troubleshooting (quick)
Web deps/build issues (iSH/limited toolchains): use SKIP_WEB=0 MODE=web .
venv missing: install distro Python venv package (e.g. python3-venv ) or re-run setup scripts.
Port in use / unreachable: change PORT , bind correct HOST , allow firewall, verify LAN IP/proxy.
DB/permission issues: ensure writable data dir ( PM_DATA_DIR /defaults), single writer, --workers 1 for web.
Update apply blocked: commit/stash/discard local changes or resolve non-fast-forward state manually.
Linux AppImage won’t open: ensure chmod +x ./spms-linux-x64.AppImage . If FUSE is unavailable, run ./spms-linux-x64.AppImage --appimage-extract-and-run , or extract with ./spms-linux-x64.AppImage --appimage-extract and run ./squashfs-root/AppRun . By default AppRun starts the Web UI and prints the live URL/server status. Plain spms-linux-x64 / .tar.gz also works.
See docs/TROUBLESHOOTING.md .
Packaging & install formats
Python package (wheel/sdist): pyproject.toml builds distributable packages including web UI assets ( ui/web/templates , ui/web/static , PWA manifest/icons/service worker). CI workflow: .github/workflows/release-python-package.yml (artifacts on tags/dispatch; optional PyPI publish via PYPI_API_TOKEN ).
Container image (GHCR): multi-arch image published by .github/workflows/release-container.yml to ghcr.io/michaelhehelmy/spms (run with --workers 1 , persistent PM_DATA_DIR ).
Native binaries: Nuitka builds via .github/workflows/release-native.yml (Windows .exe , Linux binary/AppImage/tar.gz, macOS .dmg ). See docs/NATIVE_BUILDS.md .
PWA / installable web app: manifest, icons, and a minimal service worker are served from ui/web/static/ for “Add to Screen / Install app” (best over HTTPS for non-localhost).
Kubernetes/Helm: chart skeleton in deploy/helm/spms (single-replica, SQLite-safe --workers 1 , persistent data volume, probes).
Linux packages scaffolds: Debian/Ubuntu .deb ( deploy/packaging/deb/build-deb.sh ) and RPM ( deploy/packaging/rpm/build-rpm.sh , SPECS/spms.spec ) with spms-web systemd service and /etc/spms/spms.env .
Android WebView wrapper scaffold: deploy/mobile/android-webview/ (configurable SPMS URL; reuse web UI/PWA).
Planned/optional (external/signing/hardening): Windows/macOS installers (signed/notarized), TWA/store packaging. Details and roadmap: docs/PACKAGING.md .
assistant.md — assistant capabilities, grounded/read-only behavior, evolution and plan.
docs/PACKAGING.md — packaging/distribution formats, modularization boundaries, and implementation roadmap/status.
docs/NATIVE_BUILDS.md — Nuitka/native standalone build and release packaging guidance (GitHub Releases assets auto-detected by landing page). Landing page can also accept uploaded JSON issue reports via Cloudflare Pages Function ( functions/api/report.js ) when configured with secrets (e.g. REPORT_GITHUB_TOKEN , optional REPORT_GITHUB_REPO / REPORT_GITHUB_LABELS ) to create GitHub issues for maintainers.
docs/PRODUCTION_ROADMAP.md — phased P0–P3 production hardening/operations roadmap and checklist.
docs/DEPLOYMENT.md — local/LAN/remote deployment, reverse proxy + HTTPS, systemd/Docker guidance.
docs/SECURITY.md — hardening checklist, secrets/cookies, authz/unlock/CSRF, printer/file/data handling.
docs/BACKUP_RESTORE.md — backup, verify, restore, DR, data preservation.
docs/UPDATES.md — release/update/rollback guidance.
docs/TROUBLESHOOTING.md — common issues and diagnostics.
docs/GO_LIVE_CHECKLIST.md — operational go-live steps (monitoring, domain/TLS, backups, pilot, etc.).
docs/web_authz_matrix.md — web route-group authz/CSRF/unlock reference (authoritative for ui/web ).
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
