Email Classification

This post details the technical implementation of Slack's Email Classification engine. It describes the classification logic using three data sources: Settings Context (O(1)), Inviter Context (O(1)), and Team Context (database round-trip per domain). The Team Context utilizes Vitess to store aggregate domain counts per team, grouped by role, in a `domains` table. It explains how domain thresholds (e.g., 10% of employees) are used to classify domains as internal or external. The post also outlines an eventually-consistent architecture involving 'Mutate Jobs' for real-time updates to domain counts via UPSERT operations in Vitess, and a 'Healer' component to address data drift caused by asynchronous job queues. Examples illustrate handling user joins, role changes, and deactivations, highlighting the challenges of out-of-order operations and the eventual consistency of the system.