Skip to main content

Documentation Index

Fetch the complete documentation index at: https://grantmaster.dev/llms.txt

Use this file to discover all available pages before exploring further.

Engineering reference: For service contracts, EventBus events, and data-layer details see src/features/email/email.md.

Email

Overview

The email feature provides an admin-facing email operations panel for monitoring and managing the organization’s transactional email system, which is powered by Postmark. It allows admins to view delivery statistics, browse email activity, manage bounced addresses, inspect templates, and send test emails. This feature is an operations tool, not a user-facing notification center. It surfaces Postmark’s server-level data through a unified UI. Entry point: EmailManagement component (admin settings area)

Data Model

Firestore Collections

None. All data is fetched live from the Postmark API via shared/email/postmarkAdminService.

Key TypeScript Types

// Delivery statistics summary
interface EmailStats {
  sent: number;
  delivered: number;
  bounced: number;
  opened: number;
  clicked: number;
  // ... additional Postmark stat fields
}

// Individual email event record
interface EmailActivity {
  recipient: string;
  subject: string;
  status: 'sent' | 'delivered' | 'bounced' | 'opened' | 'clicked' | 'pending';
  sentAt: string;
  // ... additional Postmark activity fields
}

Key Behaviors

Stats Overview

On load, useEmailManagementState fetches three data sources in parallel: getEmailStats(), getEmailActivity(), getBounces(). Stats are displayed in EmailStatsCards (sent, delivered, bounce rate, open rate).

Activity Feed

ActivityTab displays the full email activity log. Users can search by recipient email (handleSearchsearchEmailByRecipient()). Results replace the activity list while the search query is active; clearing the query reloads the full activity list.

Bounce Management

SuppressionTab shows bounced addresses fetched from Postmark’s suppression list. Admins can reactivate a bounced address via handleActivateBounce()activateBounce(email), which removes the address from Postmark’s suppression list and triggers a data refresh.

Template Management

TemplatesTab lists Postmark email templates available on the server. Admins can send a test email to a specified address using a selected template via handleSendTest(email, template)sendTestEmail(email, template).

Error Handling

All API calls are wrapped with Sentry error capture. Errors display as toast notifications and set a visible error state in the UI.

Service Contract

All Postmark API calls are made through shared/email/postmarkAdminService — this feature does not own a service file directly.
HookOwnsKey interface
useEmailManagementStateAll email management statestats, activity, bounces, handleSearch, handleSendTest, handleActivateBounce, handleRefresh
Shared serviceLocationMethods used
postmarkAdminServicesrc/shared/email/getEmailStats, getEmailActivity, getBounces, searchEmailByRecipient, sendTestEmail, activateBounce

Events

Emitted

None. Email management operations are administrative; no EventBus events are emitted.

Consumed

None.

Dependencies

Depends on:
  • shared/email/postmarkAdminService — Postmark API integration
  • Sentry (@sentry/react) — error capture
  • sonner — toast notifications
Depended on by:
  • Settings / admin area — EmailManagement is surfaced as an admin panel tab

File Structure

email/
├── components/
│   └── EmailManagement/
│       ├── ActivityTab.tsx             # Email activity log with search
│       ├── EmailManagementContext.tsx  # Local context for tab state
│       ├── EmailStatsCards.tsx         # Stats summary cards
│       ├── SuppressionTab.tsx          # Bounce/suppression management
│       ├── TemplatesTab.tsx            # Template list + test send
│       └── index.tsx                  # Composed EmailManagement export
├── hooks/
│   └── useEmailManagementState.tsx    # Primary state hook
└── index.ts