Inbox Architecture & Technical Specs

AI spam detection, Gmail-like search, rules engine, and email drafting.

1. AI-Powered Spam Detection & Drafting

Score RangeLabelAction
0-30safeDeliver to inbox
31-70suspiciousDeliver with warning banner
71-100spamRoute to spam folder

2. Gmail-Like Search

OperatorDescriptionExample
`from:`Sender email contains`from:boss@company.com`
`to:`Recipient email contains`to:support@company.com`
`subject:`Subject contains`subject:invoice`
`has:attachment`Has attachments`has:attachment`
`is:starred`Starred conversations`is:starred`
`is:unread`Unread conversations`is:unread`
`is:pinned`Pinned conversations`is:pinned`
`is:muted`Muted conversations`is:muted`
`before:`Before date`before:2026-04-01`
`after:`After date`after:2026-03-01`
`label:`Has tag/label`label:finance`
`in:sent`In sent folder`in:sent`
`in:drafts`In drafts folder`in:drafts`
`in:archive`In archive`in:archive`
`in:trash`In trash`in:trash`
QueryWhat it matches
-------------------------------------------------------------------------------------------
`from:boss@company.com`Messages from that sender
`subject:invoice has:attachment`Invoices with attachments
`is:unread from:client after:2026-04-01`Unread messages from "client," sent after April 1st
`quarterly report is:starred`Starred conversations matching "quarterly report"

3. Smart Rules Engine

OperatorUse CaseExample
`contains`General matchfrom contains "@acme.com"
`equals`Exact matchsubject equals "Invoice"
`starts_with`Prefixsubject starts_with "RE:"
`ends_with`Suffixfrom ends_with "@vendor.com"
`not_contains`Excludebody not_contains "unsubscribe"
ActionEffect
-----------------------------------------------
`move_to_folder`Files the message into a folder
`mark_read`Marks the message read
`star`Stars the conversation
`delete`Deletes the message
`forward_to`Forwards to another address
Rule NameConditionsActionsPriority
----------------------------------------------------------------------------
VIP Customerfrom contains "enterprise.com"star, move_to_folder:VIP1
Invoice Filingsubject contains "invoice"move_to_folder:Finance2
Spam Suspectfrom contains "noreply"delete1

4. Outbound Delivery

Outgoing mail goes through a queue that renders templates, tracks delivery, and retries on transient failure.

Sending an email (API):

bash POST /inbox/messages/send { "accountId": "acct-xxx", "to": ["client@company.com"], "subject": "Meeting Request", "body": "Hi,\n\nI would like to schedule a meeting to discuss the quarterly results." }

Response:

json { "data": { "id": "msg-xxx", "direction": "outbound", "subject": "Meeting Request", "folder": "DRAFTS" } }

The message is queued for delivery and its status updates to sent once the outbound worker dispatches it. Passing a future scheduledFor timestamp holds the send until that time instead of dispatching immediately.

Templates: stored with {{variable}} placeholders (e.g. {{customerName}}, {{orderId}}) that get filled in at send time.

5. Conversation Threading

Messages are grouped into conversations by thread, ordered oldest-to-newest, with participant tracking and status kept in sync across the whole thread.

Get a conversation with its messages (API):

bash GET /inbox/threads/{conversationId}

Response:

json { "id": "conv-xxx", "subject": "Q2 Project Update", "status": "open", "messages": [ { "id": "msg-001", "from": { "name": "Client", "email": "client@acme.com" }, "subject": "Q2 Project Update", "textBody": "Hi,\n\nHere are the updates for Q2...", "attachments": [], "createdAt": "2026-05-10T14:00:00Z" } ] }

A conversation carries subject, participants, tags, priority (low / medium / high), status (open / closed / snoozed / archived / trash / sent / draft), an assignee, and read/star/pin/mute flags — everything a shared-inbox team needs to coordinate without stepping on each other.

Composes with the rest of the OS