Files
Cosmically Creative 1230030e39 style: 14px text floor and one shared status wording
- app.css: add --hope-text-small (14px) and --hope-text-fine (13px, footer
  fine print). Every font size below 14px now uses them. The help-tip circle,
  event badge and date stamp grow to fit the larger text.
- schedule.ts: shared filledCount(), spotsSentence() and fillLabel().
  Public pages say "4 of 6 spots filled"; coordinator pills say
  "Full · 6 of 6" or "2 open · 4 of 6" (needs tone when under half full).
- admin-pages.tsx: drop needCopy(); dashboard, event page and shift lines
  all use fillLabel().
- tests: update wording expectations; add design-rules.test.ts to guard the
  14px floor and the wording.
- README: update example wording.
2026-11-20 13:24:23 -06:00

296 lines
39 KiB
Markdown

# Hope Volunteer
Volunteer shift signup for Hope Food Pantry in Sioux Center, Iowa.
Copyright (C) 2026 Hope Food Pantry
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
**This is deployed but not publicly launched.** It runs at `https://volunteer.hopefoodpantrysc.org` behind Caddy, and the whole site is behind a shared password until launch. Phase 1A has public browsing, signup for one or more people on one or more dates, cancellation, queued email, and coordinator sign-in for events, one-off shifts, rosters, and cancellation. A coordinator can add a walk-in and move a signup from a shift roster. A volunteer can switch shifts from their private link. An active weekly template fills shifts for the next three months. A coordinator can add, change, or end a weekly template, and can remove a cancelled person, a finished empty shift, an ended template, or an event that is off the public list and already empty. A confirmed signup can receive a reminder 48 hours before the shift and again 2 hours before, and can turn reminders off without cancelling. A coordinator can download a roster for one shift, one event, or a local date range. A coordinator can import a contact list, download it, open a person to see current and past shifts, use a saved contact when adding a walk-in, and add a saved contact to an open shift. A coordinator can set when reminder emails go out, where replies go, and how long signup details stay in the app. A signed-in administrator can add another administrator. Removing someone takes away their sign-in access. The last administrator cannot be removed. After 1:00 AM Central Time, signups older than that many months lose their name and contact details in this app. After 2:30 AM Central Time, the app saves a database backup on this computer. The container listens on `127.0.0.1:3020` only, and Caddy serves it over HTTPS. Around 1:00 AM in each event's time zone, the app adds any missing weekly shifts for the next eight weeks, once that local day. Development prints mail in the server log and does not send real email. Production sends through SMTP2GO.
## Current step
| Step | State |
| --- | --- |
| Configuration, database, time zones, fallback brand, fake seed | Done |
| Public event and shift pages | Done |
| Signup with capacity and duplicate checks | Done |
| Bring more than one person on a signup (up to 20) | Done |
| Sign up for several dates in one form (up to 24) | Done |
| Email coordinators when a volunteer signs up, cancels, switches, or changes party size | Done |
| Cancel your own signup from its private link | Done |
| Confirmation and cancellation email | Done |
| Coordinator sign-in, events, one-off shifts, roster, and cancellation | Done |
| Add a walk-in from a shift roster | Done |
| Move a signup to another shift | Done |
| Switch your own signup to another shift | Done |
| Manage other signups from one private link | Disabled; requires a separate verified identity flow |
| Saving a template updates the next three months | Done |
| Add, change, or end a weekly template | Done |
| Remove a cancelled person, a finished shift, an ended template, or an empty hidden event | Done |
| Reminder emails, 48 hours and 2 hours, with a way to stop them | Done |
| Download a roster for a shift, an event, or a date range | Done |
| Import and download a contact list | Done |
| Set reminder times, where replies go, and how long signup details are kept | Done |
| Refill weekly shifts around 1:00 AM in each event time zone | Done |
| Remove personal details after the saved retention period | Done |
| Save a database backup after 2:30 AM Central Time | Done |
| Run the app in Docker and check that a restart keeps the database | Done |
| Deploy behind Caddy with a shared password before launch | Done |
| Public launch (remove the shared password) | Not started |
The schema starts in `migrations/001_init.sql` and each later change is its own numbered file. The production database has applied every migration in this folder. The app refuses to start if an applied file is edited, so never change one. Add a new numbered file instead.
## Decisions still open
Do not treat this repository as an approved operating setup.
- [ ] **D1.** SMTP2GO is the email provider. The pantry verifies the sender and the reply-to. Production already sends through SMTP2GO; the pantry's sign-off on the sender and reply-to is still open.
- [x] **D2.** Group signup is built as a party size. One signup can hold 1 to 20 people. Only the person who signs up is named, and only they receive mail. The extra people take spots but are not stored by name. The count can be changed from the private link while spots are open. A shared email can also sign up other people separately, and each of them gets their own confirmation and private link. The same person, matched by name and email, cannot take a second signup on that shift.
- [ ] **D3.** The pantry approves how long signup details are kept, including copies and exports.
- [ ] **D4.** The pantry confirms the coordinator list, who owns the administrator account, and the recovery contact.
- [ ] **D5.** Configure production Turnstile keys and the allowed hostname. Production keys are set; the hostname and action checks have not been tested on the live site.
- [ ] **D6.** The host owner confirms the offsite backup destination, who owns it, the recovery target, and a restore test.
## TODO(Phase 2)
SignUpGenius shift import. The people export is a contact list, and that list can be imported. A shift import still needs an export that includes the slot, date, and time, plus a rule for someone who is already signed up for that shift.
Password login, waitlists, volunteer accounts, SMS, analytics, and payments are out of scope.
## Local setup
Requires Node 22.
```bash
cp .env.example .env
npm install
npm test
npm run seed
```
`npm run dev` serves the site on `127.0.0.1` at `BASE_URL` (from `.env`, `http://127.0.0.1:3000`). It is loopback only. Stop it with Ctrl+C.
Open `/` for the weekly pantry sign-up page. **View** starts on **List**: a card for each day with a shift in the next three months, split into that day's shifts. Each shift lists the names of the people who are signed up. A shift that has already ended stays on that day's card, grayed out, until midnight in the event's time zone. At midnight the day leaves the list. Emails, phone numbers, and notes stay off the page. **Calendar** is the other choice in that menu, at `/?view=calendar`, and it stops at that same three-month date. A shift later than that date is left off both views, and the signup form does not take a reservation for it. `/e/weekly-pantry` is the same seeded event. `/healthz` returns `{"ok":true,"database":"ok"}` and nothing else. A shift shows how many spots are filled, such as 3 of 5 spots filled. A shift with space left uses a soft green label. A full shift uses a soft red label. Coordinator lists use the same count with the state first, such as 2 open · 3 of 5 or Full · 5 of 5.
An open shift has a signup form. It asks for a first name, last name, email, and phone, with optional notes. **How many people** offers 1 to 20, and never more than the spots left. A signup for 3 people fills 3 spots, and only the person signing up is named. The form also lists every other open shift on the public list, from any published event, and up to 24 can be ticked in one submit. Full, ended, cancelled, and not-yet-open shifts are left out. Each date is its own signup, with its own confirmation email and private link. If any date cannot be saved, none are, and the form says which date to leave unchecked. Another person can use the same email and takes their own signup. The same person cannot sign up twice for one shift. The form needs JavaScript because of the Turnstile check. Wait a few seconds after the page loads before submitting. The confirmation page shows a private link and says a confirmation email is on the way. That page works without JavaScript. Cancel this signup there to open the spot again. A cancellation email is queued, and a confirmation that has not been sent yet is dropped. That person can sign up again once the cancellation is saved. Someone else can use the email while the first signup is still confirmed. A cancelled signup stays on that private page until the link expires. A private link controls only that signup. Use the separate link for each signup. On that page, **How many people** changes the party size. A larger number needs that many spots open. A smaller number gives spots back. Coordinators get an email when the count changes.
With `MAIL_DRIVER=console`, the development server tries to send queued mail every 30 seconds and prints each accepted message in its terminal. That is not delivery to a real inbox. `sent` means the driver accepted the message. A lost result is marked uncertain and is not sent again. SMTP2GO is the mail provider. Set `MAIL_DRIVER=smtp2go` and `SMTP2GO_API_KEY` to send through it. Postmark and SES remain available.
Each active coordinator gets an email when a volunteer signs up, cancels, switches shifts, or changes how many people are coming. A walk-in, a roster move, a cancellation a coordinator records, and a change to the time, role, or place do not email coordinators. The message names the person, the email address, the phone number, and the shift, and it links to that shift. It does not include the private signup link. The same signup does not send a second copy of the same notice. A coordinator who has been removed, or whose sign-in address was replaced, does not receive a notice that is still waiting. Mail already accepted cannot be recalled.
Coordinator sign-in is at `/login`. The first time the app starts with an empty coordinators table, it creates one administrator from `BOOTSTRAP_ADMIN_EMAIL`. The name on that account is Administrator. It does not create another account on later starts, and it does not change an account that is already there. More administrators are added from **Administrators** after someone is signed in. Sign-in emails a link that expires in 15 minutes and works once. Opening the link does not sign you in. Use the button on that page. The link is printed in the development server log with the rest of the mail. There is no password.
After sign-in, `/admin` lists events, including events that are off the public list. A coordinator can add and edit an event, show or hide it, add and edit a one-off shift, read that shift's roster, cancel one signup, or cancel the shift. Cancelling a shift marks each confirmed signup cancelled, queues a cancellation email, and takes that shift off the upcoming list. The shift stays stored, so a template does not add that date again. **Cancel selected**, on the event page, does this for each open shift that is checked. A shift that has already ended is left out of that batch. A time or role change emails the people who are signed up and replaces their private links. The old link stops working when that email is queued. A location change emails each person once, covering every shift of theirs that has not ended, and leaves those signup links in place. Saving shows how many people that email will reach before it is sent.
On an open shift, **Add a walk-in** records a person who is here, and can include how many people came with them. It takes that many spots, uses the same person rule as the public form, and queues a confirmation email. The name is listed on the public sign-up page when that shift is posted there. Email and notes stay off that page. A full, cancelled, or ended shift does not take a walk-in.
**Move to** puts that person on another open shift in the same event. The first shift gets its spots back and keeps the signup as cancelled. The other shift takes as many spots as the signup holds, so a party needs that much room. A change email is queued, and a reminder that is still waiting is dropped. The old private link stops working. The new link is in the change email. A full, cancelled, or ended shift cannot receive the person. A shift that already has that person cannot receive them again. Someone else at the same email can. A failed move leaves them on the original shift.
On the private signup page, **Switch to** does the same thing for the volunteer. The next page has the new link. A full, cancelled, ended, or unpublished shift is not offered. A switch is rejected if that name and email already occupy the destination shift. The destination list does not reveal which other shifts match those details. If the switch cannot be saved, the original signup stays.
Public switching permits 10 validated attempts per IP per 10-minute window and 5 per recipient per local calendar day (`DEFAULT_TZ`). These HMAC-keyed counters live in SQLite and survive link changes, new signup IDs, and restarts. A blocked request returns HTTP 429 with `Retry-After`, leaves the signup unchanged, and queues no email. Invalid origins, invalid proofs, and completed replays do not spend recipient allowances. Valid attempts that fail because a destination is full or unavailable still count. Viewing or cancelling a signup remains available when switching is limited. Coordinator roster moves use their authenticated workflow and are not subject to these public switch limits.
**Management link scope:** names and email addresses entered in a public form are unverified. Each private link authorizes only its own signup, including links from confirmation cookies and email. Cross-signup listing, cancellation, and switching are disabled, and the old `/m/:token/also/...` routes return 404. This also applies to existing links. A future multi-signup view must verify identity separately.
Saving a weekly template updates shifts from that template that have not ended, and adds any missing dates for the next three months. Starting the app does the same fill for every event. A shift that already ended stays as it was. A shift a coordinator edited on its own stays as they saved it. A cancelled shift stays cancelled, so the template does not add that date again. Changing the role or time emails the people who are signed up. A date that is no longer part of the template is cancelled when someone is signed up, and removed when nobody is. A 9:00 shift stays 9:00 when daylight saving time changes. A local time that does not exist, or that happens twice, is skipped.
**Add a weekly template** saves a repeating role, day, and time and adds those shifts. On the event page these are listed under **Templates**. **Edit this template** updates shifts from it that have not ended, and adds any missing dates. **End this template** stops later weeks from being added. Shifts from it that have not ended are cancelled and leave the upcoming list, and a cancellation email is queued for each person signed up. Shifts from it that have already ended are deleted, including the names and emails on those rosters. That part does not send email.
**Remove from roster** deletes a cancelled signup, including the name, email, and notes. A confirmed signup has to be cancelled first. **Remove this shift** deletes a cancelled or ended shift after the roster is empty. If that date came from a weekly template that is still active, saving that template can add the date again. **Remove this template** deletes an ended template. Any shifts left are no longer tied to that weekly pattern. Cancelled shifts stay off the upcoming list. **Remove this event** asks for confirmation, then deletes that event and the shifts, weekly templates, and signups on it, including names and emails. An event on the public list comes off that list. It does not send email. Other events stay.
A reminder is queued at each saved time before a confirmed signup, while the shift has not started. The defaults are 48 hours before and 2 hours before. The check runs every five minutes. If the app was off and more than one reminder is already due, only the closest one is sent. A person who signs up after an earlier reminder was due does not get that missed reminder. The same applies after a shift change or a move: a reminder that was already due is not sent. A reminder is not sent after the shift starts. Changing the shift, moving the signup, or cancelling it drops a reminder that has not been sent yet. Mail that was already accepted cannot be recalled. **Stop reminder emails**, on the private signup page or in the reminder itself, turns reminders off for that signup. The signup stays. Confirmation, change, and cancellation emails still arrive. The reminder asks the person to use the link in the confirmation email to cancel. Mail sent to the reply-to address is read by the pantry.
**Download this roster**, on a shift, and **Download this event**, on an event, save a spreadsheet of the signups. **Download this date range**, on the coordinator page, uses each event's local shift date. The file includes cancelled signups. A cell that would be a spreadsheet formula is saved as text. The download is not cached. A copy on a coordinator's computer is outside this app, and the app does not delete it later.
**Contacts**, on the coordinator page, keeps a list of people. A confirmed signup is saved on this list. The name is split at the last space. A signup name with no space is saved with a hyphen as the last name. A different name is a separate contact, even when the email matches. The same name and email updates that contact. Cancelling the signup does not remove the contact. Saving someone here does not sign them up for a shift. The list is at the top of this page. **Add a contact**, **Import**, and **Download** stay closed until one is opened. **Import** reads a spreadsheet with First Name, Last Name, Email, and Phone, including the SignUpGenius people export. An Address column is ignored. The same name and email updates that person. A different name stays a separate person, even when the email matches. A different email stays a separate person, even when the name matches. A row without a phone is skipped. Names are capitalized. A word that already mixes upper and lower case stays as written. A phone number with ten digits is saved with dashes, like 712-555-0100. A leading 1 is left off. Email addresses are stored in lowercase. Importing does not take a spot and does not send email. **Download** saves that list. A cell that would be a spreadsheet formula is saved as text. A downloaded copy stays on the coordinator's computer. The signup retention job does not clear this list. The list is the contacts table in `app.db`. The list shows 20 people. **See more** shows the next 20 on this page, without returning to the top, and keeps a search. **Choose a name** to see the shifts they are signed up for and every past shift they signed up for. The signup has to use the same name and email. A signup name with no space matches the contact saved with a hyphen for the last name. A confirmed signup on a shift that has not ended is listed under Signed up for. A shift that has ended is listed under Past shifts, including a cancelled signup, which is marked cancelled. Choosing the shift opens it. Signup details cleared by retention drop off this page. **Edit contact** and **Add to a shift** stay closed until opened. **Add to a shift** uses their saved name, email, and phone. That takes one spot and queues a confirmation email. A full, cancelled, or ended shift is not in that list, and a shift they are already on is not in that list. A shift that is not on the public list can still be chosen. **Edit contact**, on that page, saves a corrected name, email, or phone on the same person. A phone typo can be replaced. A hyphen saved as the last name can be replaced with the real last name. Changing the name does not create a second person, even when the email stays the same. Phone is required. It does not change a signup, take a spot, or send email. **Remove** deletes that person from the list only. On an open shift, **Saved contact** fills a walk-in. The walk-in still takes one spot and queues a confirmation email. **Add a contact** saves one person who has not signed up. It does not take a spot and does not send email. The same name and email updates that person. A different name is saved separately, even with the same email. Typing a walk-in who is not on the list saves them here too.
**Settings**, on the coordinator page, is three choices: when the two reminder emails go out, which inbox receives replies, and how long a signup keeps a person's name, email, and phone. The usual reminders are 2 days before the shift, then 2 hours before. The lists also offer 1 week, 3 days, and 1 day for the first email, and 1 day, 12 hours, 4 hours, and 1 hour for the second. The two times have to be different. A time already saved that is not on the list still appears, when it is a whole number of hours from 1 to 336. The usual keep time is 2 years. The list also offers 6 months, 1 year, 3 years, 5 years, and 10 years. A count already saved that is not on the list still appears, from 1 to 120 months. The reply address starts as the one in the server configuration. New mail uses the saved reply address. Mail already queued keeps the address it was given. The sending address stays in the server configuration. There is no privacy page.
**Administrators**, on the coordinator page, lists who can sign in. **Add an administrator** saves a name and email. It does not send email. That person requests a sign-in link at `/login`. Saving an address that was removed earlier gives that person access again and updates the name. **Remove** takes away access, signs that person out, and stops unused sign-in links. It does not send email. A roster notice that has not been sent yet is not sent to that address. The last administrator cannot be removed. Any administrator can add or remove the others, including themselves when someone else still has access.
Around 1:00 AM in an event's time zone, the app adds any missing shifts from that event's active weekly templates. It does this once for that local date. If 1:00 happens twice when the clocks change, the second hour does not add them again. If 1:00 does not exist that day, the fill runs once the local clock is past 1:00. A restart later that day still fills the date if it was missed. A date that already has a shift, including a cancelled one, stays as it is. Starting the app, and saving a template, still fill the schedule as well.
After 1:00 AM Central Time, once that local date, the app removes the name, email, phone, notes, and private link from each signup whose shift ended more than the saved number of months ago. The default is 24. The shift and the signup status stay, so the count remains. Legacy guardian columns, when present, are cleared too. A spreadsheet downloaded from an old shift leaves those personal cells blank. This changes the live database. It does not change a spreadsheet already on a coordinator's computer, a message already in someone's inbox, or an older database backup. Clearing a value does not promise that the old bytes are immediately gone from the disk. The contact list is separate. Clearing an old signup does not remove that person from the contact list.
Finished mail loses its recipient, subject, and body 30 days after it was sent, cancelled, or given up on. Mail that is still waiting after 30 days is cancelled and cleared, so it is not sent late. Mail for a signup is cleared in the same cleanup that removes that signup's details. A sign-in message is cleared once its link is used or expired. Every hour, the app clears those sign-in messages, finished mail past 30 days, expired sign-in sessions, used or expired sign-in links, and rate-limit counters older than about two days. Audit notes older than 24 months are deleted. Those notes are counts and ids. Starting the app runs this cleanup before it accepts requests. If 1:00 AM happens twice when the clocks change, the second hour does not run it again. A restart after 1:00 AM still runs it when that date was missed.
After 2:30 AM Central Time, once that local date, the app saves a copy of the database in the backups folder next to the live database. The copy is made with SQLite's backup tool, then stored as one ordinary database file, so it stays consistent even while the app is running. Copying `app.db` by itself is not a substitute. The app keeps 14 daily copies and 8 Sunday copies. A copy made before a signup is cleared still has the old details until that copy is old enough to be removed. These files stay on this computer. The app does not encrypt them and does not send them anywhere else. Offsite storage is still decision D6.
If 2:30 AM does not exist when the clocks spring forward, the backup runs once the local clock is past 2:30. A second check the same day does not save another copy. A failed backup leaves the older copies in place and tries again on the next check. A backup taken before a migration in production is a separate file and is not removed by this schedule. The coordinator page says when the newest daily copy was saved, or that it is behind.
`npm run seed` refuses to run when `NODE_ENV=production`. The people in the seed are fake and use `@example.invalid` addresses. The weekly template is stored. The seed command itself does not add those weekly shifts; starting the app does. Seeding again refuses until you delete the development database file.
`npm run sync-brand` copies `BRAND_SRC/tokens.css` and `fonts/` into `public/brand/`. The sibling website does not have that brand directory yet. A missing source keeps the bundled tokens and prints a warning. Font files are copied unchanged. No fonts are downloaded from Google.
## Configuration
`.env.example` lists every variable. The app reads them only through `src/config.ts`.
`BASE_URL` is the public origin, such as `http://127.0.0.1:3000` or `https://example.org`. `BASE_PATH` is an optional mount prefix, empty by default or `/volunteer` later. A path on `BASE_URL` is rejected so the prefix lives in one place. Trailing slashes are removed. Routes, assets, cookie paths, and future mail links all go through `src/url.ts`.
Production startup rejects:
- missing configuration
- `http://` or a local hostname in `BASE_URL`
- Cloudflare's documented Turnstile test keys
- `MAIL_DRIVER=console`
- missing credentials for SMTP2GO, Postmark, or SES when that driver is selected
- a session secret shorter than 32 characters, a placeholder, or a secret that does not look random
Development may use the console driver and the always-pass Turnstile test keys in `.env.example`. Those keys are not a launch setting. The console driver prints mail in the development server log and does not contact a provider. SMTP2GO is the provider for real mail. This copy of the app must not send real mail until `SMTP2GO_API_KEY` and a verified sender are configured on purpose.
`DATA_DIR` defaults to `/data`. Local development uses `./data`. The database file is `app.db` inside that directory.
`BOOTSTRAP_ADMIN_EMAIL` is the address used to create the first administrator, and only when no coordinator exists yet. The app does not overwrite an existing account. Later administrators are added from the Administrators page. Password login is not built. `password_hash` stays empty.
## Time
`src/time.ts` uses `@js-temporal/polyfill`. Node 22 does not provide a stable Temporal API. The polyfill rejects a local time that falls in a daylight-saving gap or overlap instead of moving it.
Stored instants look like `2026-01-15T15:00:00.000Z`. Local dates stay `YYYY-MM-DD`. Local times stay `HH:MM`. Weekday `0` is Sunday. A 9:00 shift in `America/Chicago` stays 9:00 local in January and in July. The default zone is `America/Chicago`.
Shifts in this version must start and end on the same day. Overnight templates are later work. A coordinator can add, change, or end a weekly template. Ending it cancels shifts from that template that have not ended, and deletes shifts from it that have already ended. The three-month fill also runs around 1:00 AM in each event's time zone, once that local date. It still runs when the app starts and when a coordinator saves a template.
## Database
SQLite runs in WAL mode with foreign keys on. Migrations in `migrations/` are applied once, in order, at startup. Each applied file is stored with a SHA-256 checksum. A failed migration stops startup and rolls back that file. In production, a database that already has migrations is backed up with SQLite's backup API before a new migration runs. Copying the live `app.db` file by itself is not a consistent backup while WAL mode is on.
There is no cascade delete. **Remove this shift** still refuses a shift that has anyone on the roster. A coordinator cancels a signup, or cancels or ends the shift, before that removal. Ending a template deletes each shift from it that has already ended, including the signups on it. A shift from that template that has not ended is cancelled instead, so the cancellation email can still be sent. Removing an ended template detaches any shifts that are still stored. An event can be removed when it is taken off the public list; that removal deletes the shifts, templates, and signups on it.
Confirmed signups have a partial unique index on shift, normalized email, and name, without regard to case. Normalization of the email is trim, Unicode normalize, and lowercase. Dots and plus-tags stay. A different person can use that email and takes their own spot. Anonymized rows clear the name and email, so they do not collide with that index. New signups always store `is_minor` as 0 with null guardian fields; legacy columns remain for older rows. `group_size` is the party size, from 1 to 20, and capacity counts the sum of `group_size` on confirmed signups.
`reminders_sent.queued_at` means the reminder was queued. `sent_at` means a provider accepted it. Queueing mail is not delivery. A closer reminder that replaces an older overdue one is stored as not sent.
## Client IP and a future Caddy proxy
`TRUST_PROXY` defaults to `false`. Forwarding headers from the public internet are ignored, and the client address is the TCP peer.
Do not set `TRUST_PROXY=true`. Name the proxy:
- `loopback` when Caddy on the same machine connects to a non-Docker process on `127.0.0.1`
- the Compose subnet, `172.30.0.0/24`, when the app is in a container. The peer is the bridge gateway under Docker, or the container's own address under rootless Podman, and never `127.0.0.1` inside the container
With `TRUST_PROXY=false` behind a proxy, every visitor arrives from the proxy's address and shares one set of rate limits. Eleven sign-in requests in an hour would then lock out every coordinator. Production startup prints a warning when `TRUST_PROXY` is false and the app listens on `0.0.0.0`.
The app reads `X-Forwarded-For` only from that peer, and only when the header is a single IP. Caddy has to replace any client-supplied forwarding header. A list of addresses is ignored, because the left-most address can be forged if the proxy appends instead of replacing. `BASE_URL` decides https links. A client cannot turn on secure cookies by sending `X-Forwarded-Proto`.
## Docker
The image is built from this repository with `docker build -t hope-volunteer .`. It uses Node 22, compiles the app, keeps production packages, and runs as the image's `node` user, which is uid 1000. The database and backups live in `/data`. The image does not contain `.env`.
`compose.yaml` publishes `127.0.0.1:3020` to port 3000 inside the container. It sets production mode, `DATA_DIR=/data`, and `BIND_HOST=0.0.0.0` so the published port can connect. `npm run dev` stays on `127.0.0.1`. Compose reads the other settings from `.env`. The development `.env` in this project will not start the container, because production refuses the console mail driver, the Turnstile test keys, and an `http://` address.
Create the data directory before the first start and give it to uid 1000. Do not make it writable by everyone:
```bash
mkdir -p data
sudo chown 1000:1000 data
sudo chmod 700 data
```
Copy `.env.production.example` to `.env` on the server and fill in the SMTP2GO API key, Turnstile keys, public `https` address, and session secret. Protect the filled `.env` with `chmod 600 .env`. Then:
```bash
docker compose up -d
```
`http://127.0.0.1:3020/healthz` should return `{"ok":true,"database":"ok"}`. A restart keeps `./data`. Backups are written under `./data/backups` by that same user. Copying only `app.db` while the app is running is not a consistent backup. Restoring a saved copy is described in `scripts/restore-backup.md`. Sending those copies off this computer is still decision D6.
When Caddy is on the host and the app is in a container, `TRUST_PROXY` is the Compose subnet, not `loopback`. `compose.yaml` pins the network to `172.30.0.0/24` and sets `TRUST_PROXY=172.30.0.0/24`. Under Docker the peer is the gateway, `172.30.0.1`. Under rootless Podman 5 with pasta, the port forwarder connects from the container's own address on that network, such as `172.30.0.2`. Trusting the subnet covers both. Only this service is on that network, and the port is published on `127.0.0.1` only. Do not attach other containers to it. If that subnet is already used on the host, change the subnet, gateway, and `TRUST_PROXY` together. Check it once on the real host: send requests through Caddy from two clients and confirm one is not limited by the other's attempts. The Caddy snippets below stay on the host. They are not started by Compose. HTTPS ends at Caddy. The container does not obtain a certificate.
Gmail is not a mail driver. Production expects SMTP2GO.
```caddy
volunteer.example.org {
request_body {
max_size 65536
}
@private_links path /m/* /u/* /login/link/*
log_skip @private_links
reverse_proxy 127.0.0.1:3020 {
header_up X-Forwarded-For {remote_host}
header_up X-Forwarded-Proto {scheme}
header_up -X-Forwarded-Host
}
}
```
For a `/volunteer` prefix, forward the path through to the app. Do not strip it if `BASE_PATH=/volunteer`.
```caddy
example.org {
@private_links path /volunteer/m/* /volunteer/u/* /volunteer/login/link/*
log_skip @private_links
@volunteer path /volunteer /volunteer/*
handle @volunteer {
request_body {
max_size 65536
}
reverse_proxy 127.0.0.1:3020 {
header_up X-Forwarded-For {remote_host}
header_up X-Forwarded-Proto {scheme}
}
}
}
```
## Security and deployment checks
Every response has a Content Security Policy, `Referrer-Policy: no-referrer`, `X-Content-Type-Options: nosniff`, and a `Permissions-Policy` that turns off camera, microphone, location, payment, and USB. When `BASE_URL` is https, responses also send `Strict-Transport-Security: max-age=31536000` for this host only. It does not use `includeSubDomains`, so other pantry subdomains are not affected.
The app limits request bodies to 64 KiB before parsing. Caddy examples apply the same limit. Rejected origins and rate-limited signup/login requests do not parse and redisplay submitted fields. Turnstile has a 10-second deadline; SMTP2GO, Postmark, and SES have 15-second deadlines. A mail timeout is an uncertain delivery, not an automatic resend. SES automatic retries are disabled to avoid duplicate sends after ambiguous failures.
Compose uses a read-only root filesystem, drops all capabilities, prevents privilege escalation, and limits the container to 512 MiB memory, one CPU, and 100 processes. `/data` remains writable and `/tmp` is a bounded temporary filesystem. Adjust resource limits using measured usage. The app runs as uid 1000. Local snapshots remain on the same disk and are not an offsite backup.
Before deployment, verify these on the actual host:
- Set `TRUST_PROXY` to the observed Docker bridge peer, then verify different clients have independent limits and forged forwarding headers cannot change their identity.
- Confirm the public HTTPS origin, real Turnstile hostname/action checks, and coordinator/volunteer mail delivery.
- Validate the Caddyfile before reloading it. The examples use [request_body](https://caddyserver.com/docs/caddyfile/directives/request_body) and [log_skip](https://caddyserver.com/docs/caddyfile/directives/log_skip). Do not enable debug logging or record bearer URLs in upstream/CDN logs. The skip rules protect matched access logs, not every possible diagnostic log.
- Restrict access to `.env`, `/data`, and backup copies. The app runs with umask `077`, so the database, its WAL files, and new backups are readable only by uid 1000. At startup it also sets `0600` on an existing database and backup files it owns. Select an offsite destination, protect its credentials, and restore a snapshot into a separate temporary database before relying on it.
## Brand
`public/brand/tokens.css` is the bundled fallback from the October 14, 2026 specification. `public/css/app.css` uses those variables. Lexend and Charm are named in the font stack and fall back to `system-ui` and `cursive` until OFL files are synced into `public/brand/fonts/`. Ink `#222` on yellow `#f9e194` is about 15.7:1.
## Host recovery
There is no web page that resets a coordinator. On the machine that holds the database, this revokes that person's sessions and unused sign-in links:
```bash
node --env-file=.env --import tsx scripts/recover-coordinator.mjs coordinator@example.invalid
```
If they cannot reach the old mailbox, replace the address and revoke the old sessions in the same step:
```bash
node --env-file=.env --import tsx scripts/recover-coordinator.mjs old@example.invalid --replace new@example.invalid
```
In the container, run the built copy. It uses the container's configuration and database, and the running app sees the change at once:
```bash
docker compose exec hope-volunteer node dist/recover-coordinator.js old@example.invalid --replace new@example.invalid
```
The address set in `BOOTSTRAP_ADMIN_EMAIL` at the first production start becomes the first administrator. Changing `.env` later does not add or replace anyone. More administrators are added from **Administrators** after sign-in. Use `--replace` to move one account to another address. Before a mailbox becomes a sign-in address, turn on 2-Step Verification for it: anyone who can read that inbox can sign in.
The command prints the coordinator id, not the address. It does not deactivate anyone. Removing access in the browser is on the Administrators page. That page cannot remove the last administrator. Do not delete the last administrator from the database without another one ready. The person then requests a new sign-in link at `/login`.
## What is still unverified
The app is deployed with Docker behind Caddy, and the whole site is behind a shared password until the public launch. Production uses SMTP2GO, real Turnstile keys, and the Compose `TRUST_PROXY` subnet. The nightly backup runs there.
Still not checked:
- Inbox delivery beyond the provider accepting the message. `sent` means SMTP2GO accepted it, not that it reached an inbox or stayed out of spam.
- The Turnstile hostname and action checks on the live hostname (D5).
- The two-client rate-limit check through Caddy described under Docker.
- An offsite copy of the backups and a restore test (D6). Today the backups stay on the same server as the database.
- A public launch. Removing the shared password is a separate step.