Add transactional emails (SMTP) and planner features (no-go areas, notes, crash recovery)

Transactional emails:
- Add nodemailer SMTP email module with dev-mode console logging
- Magic link template and welcome template with HTML + plain text
- Wire sendMagicLink into login flow, sendWelcome into registration
- Update privacy page and deploy docs for SMTP configuration

Planner features:
- No-go areas: draw polygons on map (leaflet-geoman), synced via Yjs,
  passed to BRouter as nogos parameter, route recomputes on change
- Session notes: collaborative Y.Text textarea in sidebar tab
- Crash recovery: periodic localStorage save of Yjs state, restore on reconnect
- Rate limit session creation (10/IP/hour) in /new route

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-03-26 01:00:42 +01:00
parent 05b5f6febf
commit 0a8dd0b766
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9
27 changed files with 1030 additions and 69 deletions

View file

@ -22,16 +22,15 @@ to console — users never receive it. No email infrastructure exists.
## Decisions
### D1: Resend as email provider
### D1: SMTP via nodemailer
Use [Resend](https://resend.com) — simple API, generous free tier (3k
emails/month), good developer experience. Single dependency: `resend` npm
package.
Use [nodemailer](https://nodemailer.com) with SMTP — standard, provider-agnostic,
works with any SMTP server. Single dependency: `nodemailer` npm package.
Configured via `SMTP_URL` env var (e.g., `smtp://user:pass@mail.example.com:587`).
**Alternative considered**: Nodemailer + SMTP. More complex setup, requires
SMTP server. Resend is simpler for a small project.
**Alternative considered**: Postmark. Similar to Resend but less ergonomic API.
**Alternative considered**: Resend API. Simpler initial setup but creates vendor
dependency. SMTP is a standard protocol that works with any provider and aligns
with the self-hostable philosophy.
### D2: Email module in apps/journal/app/lib/email.server.ts
@ -50,13 +49,14 @@ text generated by stripping tags.
### D4: Sender domain: noreply@trails.cool
Requires DNS verification (DKIM/SPF records) with Resend. Add TXT records via
Terraform or manually in Hetzner DNS.
Requires DNS records (DKIM/SPF/DMARC) for deliverability. Add TXT records
via Terraform or manually in Hetzner DNS.
## Risks / Trade-offs
- **Resend vendor lock-in** → Low risk. The `sendEmail` wrapper abstracts it.
Swapping to nodemailer later is a one-file change.
- **DNS verification required** → Must add DKIM/SPF records before emails work.
Can use Resend's test domain initially.
- **Free tier limits** → 3k/month is plenty for <100 users.
- **SMTP server required** → Must provide an SMTP server. Can use any provider
(Mailgun, Amazon SES, Postfix, etc.) or a simple relay.
- **DNS records required** → Must add SPF/DKIM/DMARC records for deliverability.
- **No built-in retry** → nodemailer doesn't queue. If SMTP is down, the send
fails. Acceptable for current scale — welcome emails are fire-and-forget,
magic links can be re-requested.