# Notifications Module

Email dispatch via Resend (prod) / Mailpit (local) and in-app inbox via Laravel's built-in `notifications` morph table.

## Responsibilities

- Consume domain events dispatched by other modules (Orders, Items) and dispatch user-facing notifications.
- Gate email delivery by `notification_preferences` per (channel × category).
- Persist an in-app inbox row for every notification regardless of email preference (preferences only gate the `mail` channel).

## Components

- `Notifications/*Notification.php` — Laravel `Notification` classes, one per (recipient × event). `via()` returns gated channels; `toMail()` renders a markdown template; `toDatabase()` returns the inbox payload.
- `Listeners/Send*Email.php` — thin listeners that resolve the recipient and call `$user->notify(...)`. One listener per (event × recipient).
- `Services/NotificationPreferenceGate.php` — single source of truth for channel gating.
- `Services/AdminRecipients.php` — resolves admin users for fan-out.
- `Services/SeedDefaultPreferences.php` — seeds default prefs on user registration (all categories enabled).
- `Controllers/InboxController.php`, `PreferenceController.php` — user-facing inbox + preferences endpoints under `/v1/me/*`.

## Preference semantics

- **Orders / Shipping** are transactional — always-on, cannot be disabled via API.
- **Promotions / PriceDrops / Account** honor `notification_preferences` rows.
- **Admin** notifications bypass the gate entirely (role-based).

## Deploy prerequisites

- Set `MAIL_MAILER=resend` and `RESEND_API_KEY=...` in production env.
- Verify the sending domain in Resend (DKIM). Set `MAIL_FROM_ADDRESS=notifications@alqove.com` and `MAIL_SUPPORT_ADDRESS=support@alqove.com`.
- Local dev uses Sail's Mailpit at `http://localhost:8025` (`MAIL_MAILER=smtp`, host `mailpit`).

## Not in V1

- Push (web or mobile).
- Real-time broadcasting.
- Dedup / idempotency table.
- Preferences UI (API-only; UI added when promotions/price-drops emails ship).
- Seller/admin inbox UIs (Layers 7 / 8).
- Price drops, item publish / relist / remove listeners.
