peisear-notify
Notification dispatch pipeline for peisear.
Responsibility
This crate owns:
- Edge detection: deciding when a tracked signal warrants a fresh notification (e.g. a user crossing the burnout overload threshold for the first time, not every snapshot tick that they remain over).
- Dispatch loop: a tokio task that drains
[
DispatchEvent]s from an mpsc channel, applies user preferences and cooldown, and fans out to channels. - Channels: one impl per delivery medium —
in_app: the audit row in thenotificationstable is itself the in-app artefact (the inbox reads from it).email: SMTP viawasm-smtp. Configurable transport, Cloudflare Workers compatible (viawasm-smtp-cloudflare).webhook: HTTP POST a JSON envelope to a per-user URL.
Non-responsibilities
The crate does not own:
- HTTP routes for the inbox or preferences pages — those live
in
peisear-web::handlers::notificationsandpeisear-web::handlers::notification_preferences. - UI rendering — that's
peisear-web::components::notificationsandpeisear-web::components::notification_preferences. - Domain types (
Notification,Preference,Severity,kindandchannelconstants) — those live inpeisear-core::notificationsso any crate, including future ones likepeisear-ai, can produce notification events without taking a heavy dependency on the dispatch pipeline. - Storage CRUD — that's
peisear-storage::notifications.
Why a dedicated crate
The pipeline has its own dependency surface (SMTP, future
webhook HTTP client, possibly future AI-summarised digests).
Isolating it means the peisear-web crate stays lean: a
contributor working on the inbox UI doesn't pay the
compile-time cost of the SMTP transport, and a future
edge-targeted deployment can swap transports without changes
to the web crate.
Why a verb-form name
Verb form follows the responsibility shape: this crate
notifies. Compare with peisear-storage (storage as a
concept), peisear-auth (auth as a system); peisear-notify
(notify as an action). The naming preserves room to grow
into adjacent verbs the project might want later — peisear- broadcast, peisear-summarise, etc. — without a
"notifications" plural that would already feel claimed.