NsquareBooks - on-premise installation (Windows)
================================================

REQUIREMENTS
  - Windows 10 / 11 or Windows Server 2016+ (64-bit), 4 GB RAM, 2 GB free disk
  - Administrator rights for installing
  - Free ports: 3000 (web, opened on the office network) and 4000 (API, local only)
  - PostgreSQL 15 or newer. If none is installed, the bundled installer
    (prereq folder) is installed silently.

INSTALL (first time)
  1. Extract the zip to any folder (for example the Desktop).
  2. Double-click Install.cmd and allow administrator rights.
  3. Enter a password for the PostgreSQL superuser 'postgres'
     (a new one if PostgreSQL is installed now; the existing one otherwise).
     Write it down. Upgrades and backups use it from
     C:\NsquareBooks\config\admin.env (readable by administrators only).
  4. The browser opens http://localhost:3000. Create your organisation,
     company and admin user on the first-run page.
  5. Other PCs on the office network: http://<this-computer's-IP>:3000
     (the installer prints the address).

  Options (run from a command prompt in the extracted folder):
     Install.cmd -InstallDir D:\NsquareBooks -WebPort 8080
     Install.cmd -PgPassword "secret" -Unattended
     Install.cmd -NoFirewall

LICENCE
  The first start runs a 30-day trial. Settings > License > Download licence
  request, send the file to NsquareBooks, then upload the licence file you get.

UPGRADE
  Extract the new package and double-click its Install.cmd. Settings and data
  are kept; the database is migrated. Take a backup first.

WHAT IS INSTALLED (default C:\NsquareBooks)
  app\        the application (compiled)
  runtime\    Node.js
  config\     settings and database passwords (Administrators only)
  logs\       api.log, web.log
  backups\    database backups
  scripts\    control.ps1, backup.ps1, uninstall.ps1
  Two background tasks in Task Scheduler > NsquareBooks (API and Web) start
  with Windows, run as SYSTEM and restart automatically on failure.

DAILY USE (PowerShell as administrator)
  Status / restart:
     powershell -ExecutionPolicy Bypass -File C:\NsquareBooks\scripts\control.ps1 status
     powershell -ExecutionPolicy Bypass -File C:\NsquareBooks\scripts\control.ps1 restart
  Backup (keep the latest 14):
     powershell -ExecutionPolicy Bypass -File C:\NsquareBooks\scripts\backup.ps1
  Restore a backup into an empty database:
     "C:\Program Files\PostgreSQL\<ver>\bin\pg_restore.exe" -U postgres -d nsquarebooks --clean C:\NsquareBooks\backups\<file>.dump

UNINSTALL
  Double-click C:\NsquareBooks\Uninstall.cmd. The database, settings and
  backups are kept. Uninstall.cmd -RemoveDatabase also drops the database.

TROUBLESHOOTING
  - Page does not open: run control.ps1 status and read logs\api.log / web.log.
  - Port in use: install with -WebPort 8080 (the API port stays 4000).
  - Other PCs cannot connect: the network must be Private or Domain in Windows;
    check the firewall rule "NsquareBooks (web)".
