Applications
The core tracking pipeline: threads, statuses, and historical snapshots.
The applications feature slice owns the candidate tracking lifecycle. This includes managing application statuses, rendering conversation threads, and handling bulk application operations.
Creation & Outreach Dependency
Unlike a standard CRUD model where records are manually created, an Application row is intrinsically tied to the outreach slice. When a user sends an outreach email, the system automatically creates the underlying Application row and seeds it with the initial outgoing EmailLog.
The Data Model & Snapshots
The Application model is designed to survive destructive upstream actions.
Company SetNull Cascade
In the Prisma schema, the relationship to a Company is explicitly set to onDelete: SetNull rather than Cascade. This is a critical architectural decision: if a user deletes a company list (or a specific company), their historical application data and email threads remain perfectly intact.
Preserving Display Context
companyId can become null, the Application model stores a hard snapshot of the companyName and toEmail at the time of creation. This guarantees the UI can always render the historical application accurately.Status Pipeline
The status field enforces a strict hiring pipeline state machine: Draft, Sent, Replied, Interview, Offer, Rejected, and Hired. Note that status transitions in the UI's thread view are designed to be append-only, preserving a chronological log of how the candidate progressed.
Gmail Threading
Each application optionally stores a unique threadId. This maps directly to a Gmail thread, allowing the application to aggregate and display all incoming EmailMessage replies chronologically inside the tracking view.
Fuzzy Search (GIN Indexes)
To power the global ⌘K search efficiently, the Application model utilizes raw Postgres GIN trigram indexes on the snapped company name (@@index([companyName(ops: raw("gin_trgm_ops"))], type: Gin)). This ensures instant, fuzzy-matched results across thousands of applications without table scans.