# Simple installation and school hosting

**classguard.org stays on ChatGPT Sites.** It is the public website and installation starting point. The existing classroom app is a Node.js service with SQLite accounts and a private student roster; deploy that service separately. An optional address such as `app.classguard.org` can point to the classroom host after it is deployed. Do not change the root domain’s Sites records.

## Start on one computer

Get the current private school package from your administrator. Install Node.js 22.14 or newer, open a terminal in the package folder, and run:

```sh
npm run install:school
npm start
```

The installer checks Node, installs the server dependencies, creates a private configuration file, and walks you through the first administrator account. Password entry is hidden. Running setup again preserves existing accounts and configuration. Open `http://127.0.0.1:8787/login.html` on that computer. Localhost is for testing on one computer; school devices need an HTTPS school address.

## Managed hosting: Render

The repository includes `render.yaml` and a production Dockerfile. Connect your private GitHub repository to Render, create a Blueprint from that repository, and review the service and disk cost before creating it. The template uses one paid service and a 1 GB persistent disk; it does not use an ephemeral free service. See [Render’s persistent disk documentation](https://render.com/docs/disks).

1. Enter the stable deployed Chrome extension ID in `CLASSGUARD_EXTENSION_IDS` when prompted. Find it at `chrome://extensions`. A stable school deployment is needed; unpacked extension IDs can differ between machines.
2. Deploy the Blueprint. The app uses Render’s assigned `PORT` and HTTPS service URL automatically. Accounts, classrooms, reusable lessons, and the student roster live under `/var/lib/classguard` on the attached disk.
3. In the running service’s **Shell**, run `node classguard-server/manage-accounts.mjs create-admin`. Choose the first administrator’s name, email, and password privately. There is no default account or public signup.
4. Open the HTTPS service URL, sign in, add student groups, add staff, and assign classrooms.
5. To use `app.classguard.org`, add that custom domain to the classroom service and follow the provider’s exact DNS instructions. Set `CLASSGUARD_PUBLIC_URL=https://app.classguard.org` and redeploy. Keep classguard.org on Sites. Add the working school address to your managed Chrome policy.

Render checks `/ready` and restarts an unresponsive service. Its HTTPS proxy fronts the app; production cookies remain Secure. See [Render health checks](https://render.com/docs/health-checks) and [web service HTTPS](https://render.com/docs/web-services).

**Updates are manual** in this Blueprint. Deploy outside lesson time after checks pass. A disk-backed service has deployment downtime and supports a single instance; live lessons end during a restart or deploy. Saved school data remains. This configuration is process recovery with persistent storage, not high availability or a guarantee of uninterrupted lessons. See [disk deployment limits](https://render.com/docs/disks#disk-limitations-and-considerations).

Google Workspace and YouTube keys are optional and remain server-side environment settings. Store a Google service account file privately on the persistent disk and configure its path; never commit it or place it in the public website package. See the existing Google and YouTube guides.

## School-controlled Linux host: Docker Compose

Install Docker Engine with Compose from [Docker’s official instructions](https://docs.docker.com/engine/install/). Keep the package folders together. Point a separate classroom hostname to the host and make inbound TCP 80/443 available. The app’s HTTP port is not published outside the Docker network.

```sh
npm run configure:hosting
docker compose build
docker compose run --rm --no-deps app node classguard-server/manage-accounts.mjs create-admin
docker compose up -d --wait
```

The configuration wizard asks for the classroom HTTPS address, deployed extension ID, and certificate contact email. It preserves an existing root `.env` by refusing to overwrite it. Caddy obtains and renews HTTPS certificates; its certificate files and school data are named Docker volumes. The app process runs as the unprivileged `node` user after the entrypoint initializes volume ownership. Containers restart after process failure or host reboot when Docker starts. A Compose health check reports readiness; Docker’s restart policy does not by itself restart a merely unhealthy container. Use external uptime monitoring and investigate unhealthy services.

Check service status and logs:

```sh
docker compose ps
docker compose logs --tail=100 app web
```

For an update, take a backup, obtain the current source, then run `docker compose up -d --build --wait` outside lesson time. Do not remove the named volumes: `docker compose down` keeps them, whereas `docker compose down --volumes` deletes school data and certificates.

## Backups and recovery

Administrators choose **District overview → School connection → Download school backup**. The server captures a consistent account database and roster while queuing roster writes. The download includes staff password hashes, classroom assignments, reusable lessons, and student records. It excludes existing staff sign-ins, live previews, and live lessons. Only administrators can export it, with CSRF checks and a rate limit.

Keep an encrypted copy outside the classroom host and test recovery on a separate installation. Host disk snapshots are useful in addition to this application backup. Configuration secrets and managed Chrome policy must be backed up separately under your school’s controls.

For a stopped local installation, an additional offline backup is available:

```sh
npm run backup:school -- --server-stopped
```

To restore a downloaded JSON backup, stop ClassGuard first, then run:

```sh
npm run restore:school -- --file /private/classguard-school-backup.json --server-stopped --confirm-restore
npm start
```

Restore validates the database and roster before replacing files, makes a safety copy of existing school data, and signs everyone out. It replaces current accounts and roster data with the backup’s recovery point. Do not run it against a running school server.

For Docker, stop `app`, then use the same persistent volume and mount the private backup read-only:

```sh
docker compose stop app
docker compose run --rm --no-deps -v /absolute/private/backup.json:/restore/backup.json:ro app node scripts/restore-school.mjs --file /restore/backup.json --server-stopped --confirm-restore
docker compose up -d --wait
```

For managed hosting, have IT restore the backup into a stopped/replacement service’s persistent storage before starting the app. Do not overwrite the live database from an active service shell.

## Configuration and checks

Local setup reads `classguard-server/.env`; environment variables supplied by the host take precedence. `CLASSGUARD_DATA_DIR` sets the default accounts and roster directory. Existing `CLASSGUARD_ACCOUNTS_FILE` and `CLASSGUARD_ROSTER_FILE` overrides still work. `CLASSGUARD_PUBLIC_URL` and `CLASSGUARD_EXTENSION_IDS` add exact trusted origins without wildcard access. HTTPS/proxy checks remain enforced; incomplete or invalid network configuration fails at startup.

- `/health`: process liveness, with no school details.
- `/ready`: readable/writable persistent storage and an accessible account database; returns 503 on failure.
- `SIGTERM`/`SIGINT`: notify active classes, stop accepting requests, close database connections, and bound shutdown time.
- GitHub Actions: tests on Node 22 and 24, school-package build, container health and persistence smoke checks, and Compose/Caddy validation. No school secrets are required for these checks.

The extension is still installed through a supported managed Chrome distribution method. This setup does not create a Chrome Web Store listing or install extensions onto school devices automatically. Test one class on actual school devices before expanding.
