AZ-008 — Email integration and Mocking Bird capture

Status

Done

Context

Read README, especially the selected Resend HTTPS adapter, Mocking Bird limits, deployment classification and safe logging. No external runtime integrations exist. Email will serve password recovery in AZ-010; this increment proves delivery boundaries using a constrained local test-email operation and controlled HTTP tests, without waiting for recovery functionality. AZ-005 supplies authenticated users, CSRF and local/test versus hosted configuration.

Goal

Deliver one concrete email integration with bounded failures and an opt-in local interception capability that records sanitized outbound requests without contacting the real provider.

Requirements

Non-goals

No provider signup/subscription/domain configuration/live send, payments/POS, SMTP, multiple vendors, generic integration framework, developer UI (AZ-009), recovery tokens (AZ-010), request scripting, arbitrary proxy URLs, persisted replay or hosted mock mode.

Implementation guidance

Keep application email contract independent of HTTP; only integration adapter/transport uses vendor JSON and headers. Separate safe capture projection from raw request so redaction is enforced before history storage. Limit preview separately and do not turn an adapter unit-test injection into a configurable production backdoor. The test-email endpoint is a concrete proof and must be guarded with backend deployment config, authentication, CSRF and synthetic-recipient validation together. Do not change the main db:seed or make recovery's mail provider a database concern.

Acceptance criteria

Verification

pnpm quality
pnpm --filter @foodtruck-order/backend test:unit
pnpm --filter @foodtruck-order/backend test:coverage
pnpm build
pnpm validate:docker

Backend aggregate coverage uses PostgreSQL. Add transport/adapter/capture/config/injection tests; integration tests exercise the local proof operation through real user/session persistence and mocked external mail only. Update canonical CI local-test configuration explicitly; do not enable Mocking Bird in hosted migration jobs or defaults. Manually inspect a synthetic request through the protected local API and confirm secrets are absent from structured logs. No real send is needed for implementation acceptance; deployed delivery evidence remains a later release check.

Documentation

Update architecture (integration/transport boundary), techstack (native fetch and Resend rationale), development (mode/config/synthetic recipient/test mail), Docker/CI (explicit local test enablement), testing (client versus mock tests), OpenAPI, current-state/handover. Record an integration ADR with HTTPS-versus-SMTP rationale and external provider prerequisites.

Dependencies

AZ-005 and its predecessors. Can proceed beside AZ-006/AZ-007; there is no UI dependency.

Future considerations

An actual POS/payment adapter may reuse proven timeout/redaction conventions when needed, without assuming email's retry/idempotency semantics or adding unused generic interfaces now.