Outreach
The user's own job outreach: templates, sending, and immutable history.
The outreach slice is the core engine for user-driven job applications. It owns the templates a user writes and the exact logging of what was sent to companies.
Strict Separation from Mail
mail slice.The
outreach slice uses the integrations-google Gmail OAuth grant to send mail directly from the user's own inbox. Conversely, the mail slice uses Resend (SMTP) to send transactional platform mail (like password resets) from our corporate domain. Never route one through the other.The Data Model
The slice relies heavily on three core models: EmailTemplate, EmailLog, and EmailMessage.
Email Templates
User-authored templates (EmailTemplate) are split into a header, content, and footer. They support dynamic {{placeholders}} (like companyName, hiringRoles, or senderName) which are compiled and injected exactly at send time.
Immutable Email Logs
The EmailLog table tracks the outgoing dispatch of an application. It has foreign keys to the Template, Resume, and Application involved—but critically, all of these are explicitly onDelete: SetNull.
Because of this, the log takes a hard snapshot of the templateType, resumeName, companyName, and toEmail at the exact moment of sending. If a user later deletes their resume or edits the template they used, the historical log of exactly what was sent on that day survives untouched.
Performance Optimization
EmailLog is the highest-volume table in the schema and uses SetNull foreign keys, explicit Postgres indexes (@@index([templateId])) were manually added. Without these, deleting a template would trigger a full table scan of the entire log history.Email Messages (Gmail Sync)
While the EmailLog tracks the singular outgoing action, the EmailMessage model is a raw replica of the Gmail conversation (subject, snippet, body, and threadId). These are synced asynchronously and cascade directly from the Application model, rendering the full chronological thread in the UI.