Architecture
Ward is a four-workspace npm monorepo: three deployed artifacts and one library that each app copies into its own repo.
| Workspace | Ships as | What it is |
|---|---|---|
api/ | a container behind Caddy at /ward-api | Fastify + better-sqlite3. The whole service, including the OpenID Connect provider. |
ui/ | static files at /ward | Vite + React. The login page, self-service, and the console. |
shared-library/ | a built bundle each app vendors into vendor/ward/ | Local accounts, sessions and lockout for an app, plus "Sign in with Ward". See below. |
docs/ | static files at /ward/docs | This site. |
The process and storage model
- Process
- One Fastify instance, bound to
127.0.0.1:8791— by configuration, not by firewall rule - Database
- One SQLite file in WAL mode, opened synchronously with
better-sqlite3 - Migrations
- Statically imported, and run to completion before the listener binds
- Signing key
- One Ed25519 private key on disk, read at boot; the service refuses to start without it
- Pluggable transport — SMTP in production, a file drop for local work
There is no cache, no queue, no second process, and no network hop inside the service. A request is a handful of prepared statements against a local file.
That is a decision rather than an omission. The estate's entire load is a handful of apps asking about sessions for one household of users, and every piece of infrastructure that would make Ward "scalable" would also make it a thing that can be down — while being the one service whose being down signs everybody out of everything.
Where responsibility stops
The line Ward draws is between who someone is and what they have done.
Ward owns identity: credentials, the account, and the grants saying which apps a person may use. It hands every app a stable, opaque subject, and that is the entire interface. An app keys its own rows on the subject and owns them completely — atrium's reading progress, prm's favorites, newspapper's drafts. Ward has never heard of any of them.
The practical consequence is worth stating: Ward can be restored from backup without consulting any app, and any app can be restored without consulting Ward. The only shared value is an opaque string that neither side derives from the other.
The five request shapes
- A browser signing in.
POST /login→ password check → session row → two cookies, both under/ward-api. See Sessions and tokens. - An app signing someone in. The OpenID Connect code flow under
/oidc/*, whose login step (/refresh/oidc/:uid) reads Ward's refresh cookie, and the app's token request authenticated by a client assertion. See Sign in with Ward. - An app checking a session.
POST /session-status, at most every 30 seconds per Ward session, authenticated by the same client assertion and answered from the database with no caching on Ward's side.POST /notifytakes the same credential. - A browser doing self-service.
GET /account, password change, revoke other sessions — authenticated by the access cookie, which only Ward's own pages receive. - The superuser in the console. Everything under
/console/*, gated by a separate cookie scoped to/ward-api/consoleand a separate credential. See the admin decisions.
Anything else — /health, /.well-known/jwks.json, GET /apps — is a static
answer with no session involved.
The shared library
Every app signs people in through shared-library/: local accounts, opaque
server-side sessions, lockout, and the client side of "Sign in with Ward" (the
code flow, the ID token check, and the 30-second /session-status cache). It
ships as a built bundle that each app copies into its own vendor/ward/, so no
app installs anything from a registry and nothing is shared at runtime. Its
README in the repo is the adoption guide an app follows.
That replaced the earlier arrangement, in which each app hand-wrote its own
client against a shared cookie, /introspect and an app key, with a reference
package (client/) that nothing installed. Five hand-written copies of
security code were the estate's largest standing risk; one vendored bundle,
upgraded by copying a newer build over the old one, is the answer to it. The
old contract was retired on 2026-10-13.
What is deliberately absent
| Not present | Because |
|---|---|
| A JWT denylist | /session-status already answers "is this live?" for apps, and Ward's own pages check the session row. A denylist would be a second, redundant revocation path — see decisions-tokens. |
| Knex, or any query builder | Raw better-sqlite3 with prepared statements — see decisions-implementation. |
| argon2id | scrypt, from Node's standard library, so there is no native build in the deploy path. |
| A published npm package | The shared library is vendored as a built bundle instead — see above. |
| Subdomains, CORS | One origin makes both unnecessary — see The one-origin estate. |