23 — Email & SMS
CEO Summary
Email and SMS power all outbound notifications: password reset, receipts, ticket notifications, appointment reminders. Business value: Customer communication, account recovery. Key metrics: Delivery rate, bounce rate. If this breaks: Users cannot reset password; receipts not sent; notifications fail.
Architecture
flowchart TB
subgraph callers [Callers]
Auth[auth - password reset]
Rec[receipts]
Tickets[tickets]
Appt[appointments]
end
subgraph svc [Services]
Mailer[mailer.js]
MailSvc[email.service.js]
SMS[sms.js]
end
subgraph providers [Providers]
SMTP[SMTP/SendGrid]
Twilio[Twilio]
end
Auth --> Mailer
Rec --> Mailer
Rec --> SMS
Tickets --> Mailer
Tickets --> SMS
Appt --> Mailer
Appt --> SMS
Mailer --> SMTP
MailSvc --> SMTP
SMS --> Twilio
Overview
Email and SMS are infrastructure services. No dedicated routes — called by other services.
- Email: mailer.js (sendMail)
- SMS: sms.js (sendSms)
File Structure
backend/
├── services/
│ ├── mailer.js
│ └── email.service.js
└── sms.js
# Or: backend/services/sms.js
Use Cases
| Use Case | Trigger | Service |
|---|---|---|
| Password reset | Forgot password flow | mailer.js |
| Receipt email/SMS | POS finalize, invoice paid | receipts.routes → sendMail, sendSms |
| Ticket notifications | ticketNotification.service | mailer, sms |
| Appointment reminders | Appointment booking/reminder | mailer, sms |
Configuration
SMTP, SendGrid, or similar for email. Twilio or similar for SMS. Env vars for credentials (e.g. SMTP_HOST, TWILIO_ACCOUNT_SID).
Integration Points
| System | Connection |
|---|---|
| Auth | Password reset email |
| Receipts | Email/SMS receipt delivery |
| Tickets | ticketNotification.service |
| Appointments | Appointment reminders |
Key Paths
| Path | Purpose |
|---|---|
backend/services/mailer.js | sendMail |
backend/sms.js | sendSms |