mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-30 21:01:54 +08:00
<!-- Make sure you've read the CONTRIBUTING.md guidelines: https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Preview mode: sandboxed experience with mock projects, placeholder data, and disabled external integrations (payments, webhooks, email rendering, session replays). * One-click preview project creation and automatic preview sign-in for quick access. * **New Features — Walkthrough** * Interactive guided walkthroughs with spotlight, animated cursor, step-driven navigation, and targeted element hooks. * **Style** * UI/UX adjustments for preview: theme behavior, conditional banners/alerts, informational alerts, and walkthrough attributes added across pages. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|---|---|---|
| .. | ||
| capacity-boost | ||
| delivery-info | ||
| notification-preference | ||
| outbox | ||
| render-email | ||
| send-email | ||
| unsubscribe-link | ||
| README.md | ||
Email Infrastructure Overview
This folder contains the HTTP endpoints that sit on top of the new email outbox
pipeline. The pipeline is intentionally asynchronous: instead of sending mail
inside request handlers we persist work items to the EmailOutbox table and let
background workers render, queue, and deliver them.
Execution Flow
- Enqueue – API endpoints (and server-side helpers) call
sendEmailToManyto persist one row per recipient. Each entry captures the template source, render variables, target recipient, priority, and scheduling metadata. - Render –
runEmailQueueStepatomically claims rows that have not been rendered. Emails are rendered via Freestyle, producing HTML/Text/Subject snapshots while capturing render errors in structured fields. - Queue – Rendered rows whose
scheduled_atis in the past are marked as ready (isQueued = true). Capacity is calculated per tenancy based on recent delivery performance to decide how many emails can be handed off to the sender during this iteration. - Send – Claimed rows are processed in parallel. Before delivery we fetch
the latest user data, honour notification preferences and skip users who have
unsubscribed or deleted their account. Provider responses are captured in the
sendServerError*fields so the dashboard can surface actionable feedback. - Delivery Stats – The worker updates
EmailOutboxProcessingMetadataso we can derive execution deltas and expose aggregated metrics via the/emails/delivery-infoendpoint.
Key Tables
EmailOutbox– Durable queue of emails with full status history and audit data. Constraints ensure mutually exclusive sets of render/send error fields and guard against race conditions.EmailOutboxProcessingMetadata– Stores the last worker execution timestamp so we can compute accurate capacity budgets each run.
Mutable vs. Immutable States
Emails can only be edited, paused, retried, or deleted before startedSendingAt is set.
Once sending begins, the entry becomes read-only. Retrying an email effectively resets its
place in the pipeline & queue, see the Prisma schema for more details.