Overview
PyqDeck uses Resend for email delivery and Mailgen for HTML email template generation. The system is implemented but not yet wired into the application’s routes/controllers.Configuration
Environment Variables
Setup (backend/src/config/mail.config.js)
RESEND_API_KEY is set, resendClient is null and all email functions become no-ops. This allows the app to run locally without email configuration.
Email Types
Three email functions are available inbackend/src/services/mail.service.js:
1. Verification Email (OTP)
2. Welcome Email
3. Password Reset Email (OTP)
How Templates Work
There are no static HTML template files. All email templates are generated dynamically via Mailgen’s API at runtime.OTP Emails (Action-based)
Welcome Email (Text-based)
Sending the Email
Error Handling
All three functions follow the same pattern:- No API key → returns immediately (no error)
- Send fails → logs error + throws (caller must handle)
- Success → logs confirmation
Current Status: Not Yet Wired In
The email service functions are implemented but not called anywhere in the application. No controller, route, or service imports frommail.service.js.
Where They Should Be Connected
Example: Wiring into Clerk Webhook
Resend Setup
Getting an API Key
- Sign up at resend.com
- Create an API key from the dashboard
- Free tier: 3,000 emails/month, 100 emails/day
Domain Verification
For production, verify your domain in Resend to:- Remove the “via resend.net” footer
- Use your own
fromaddress (e.g.,noreply@pyqdeck.in) - Improve email deliverability
Testing Locally
Resend provides a test mode where emails are logged but not actually sent. Use the test API key (re_123456789) for local development.
Testing
The email service has full test coverage:Happy Path Tests
Error Path Tests
No-Config Tests
Future Enhancements
When wiring the email system into the app, consider:- Email queue — Use a queue (Bull, Redis) to handle email sending asynchronously
- Email templates — Create custom Mailgen themes or switch to a more flexible template engine for complex emails
- Email analytics — Track open rates, click rates via Resend’s analytics API
- Additional email types — Notification emails, study reminders, paper update alerts
- OTP storage — Store OTPs with expiry in Redis or MongoDB for verification
Next Steps
- Explore the auth flow
- Review the data pipeline
- Check monitoring setup

