Skip to content

The Moving Parts

NPM looks like one program — a web page with forms. It is five parts wearing a trench coat, and nearly every puzzle in later chapters is one of these parts behaving exactly as designed while the others wait on it. This chapter names them, says where each one lives, and gives you the check that tells them apart. By the end you can answer the only diagnostic question that matters first: which part is unhappy?

The backend is the brain: a Node.js program that serves an API (a machine-readable interface) for everything the product does. It owns the database, checks passwords, writes configuration files, runs the tests and reloads, and drives the certificate tool on its timers. In the Docker image it listens on port 3000 inside the container, where only the container's own nginx talks to it. The lab ran this exact backend from the official v2.16.0 source and it answered its health check like this (transcript t05):

{"status":"OK","setup":true,"version":{"major":2,"minor":0,"revision":0}}

That one line is the backend's signature: status says it is alive, setup says whether an administrator exists yet, and version is the API version (2.0.0 — the release is v2.16.0; the two numbers count different things).

The admin interface is the face: a web application (React, for the curious) that your browser downloads and runs. It contains no state of its own — every list it shows and every change it saves travels through the backend's API, at addresses under /api/ on the same origin. In the Docker image, nginx serves the interface's files on port 81 and passes /api/ calls through to the backend. The lab built this interface from source — a 4.2 MB folder of files — and reproduced that wiring with a standalone nginx (transcript t21).

The database is the memory. Every host, user, certificate record and setting lives in it. By default it is a single SQLite file, /data/database.sqlite — one of NPM's best decisions for home use, because backing up NPM is mostly copying one folder. MySQL/MariaDB and PostgreSQL are supported for larger installs through environment variables, and chapter 3 mentions when that trade is worth making. Alongside the database, /data/keys.json holds the keys that sign login tokens; lose it and every existing login is forgotten.

nginx is the muscle: the real web server, running beside the backend inside the same container. Its main configuration includes everything under /data/nginx/ — proxy_host/, redirection_host/, dead_host/ and stream/ — so a host exists precisely when its generated file exists there. NPM asks this nginx to test (nginx -t) and reload after every change, and records the result on the host as nginx_online. When you read that a host is "offline" in the interface, this is the part speaking: the record is fine, the configuration or its reload was not.

Certbot is the certificate clerk: the standard Let's Encrypt client, which NPM runs for you when you request or renew a certificate. Certificates it wins live under /etc/letsencrypt/ inside the container, and the records that describe them live in the database. Chapter 8 walks its two proofs of ownership.

The check for this chapter: on a running install, open http://<your-npm-machine>:81 (the face) and, from the machine itself, ask the backend for its health line — in Docker, the backend is not published to the network, so use the interface's own evidence instead: the login page loading means nginx and the interface files are fine; a login that spins or errors points at the backend. Knowing which layer you are looking at is the whole skill, and the lab transcripts (t05 for the backend alone, t21 for the wired-together stack) show both views of the same system.