Skip to content

Latest commit

 

History

History
92 lines (80 loc) · 2.74 KB

File metadata and controls

92 lines (80 loc) · 2.74 KB

MAIL-CARD Data Flow Architecture

sequenceDiagram
    participant C as Email Client
    participant S as SMTP Server
    participant Q as Mail Queue
    participant R as Message Router
    participant D as DKIM Signer
    participant ST as Storage
    participant I as IMAP Server
    
    Note over C,I: Email Sending Flow
    C->>S: SMTP Connection
    S->>C: 220 Ready
    C->>S: EHLO client.domain
    S->>C: 250 Hello
    C->>S: MAIL FROM: sender@domain.com
    S->>C: 250 OK
    C->>S: RCPT TO: recipient@domain.com
    S->>C: 250 OK
    C->>S: DATA
    C->>S: Email Content
    S->>C: 250 Queued
    
    S->>Q: Add to Queue
    Q->>R: Process Message
    R->>D: Sign with DKIM
    D->>R: Signed Message
    R->>ST: Store Message
    ST->>R: Store Confirmation
    
    Note over C,I: Email Retrieval Flow
    C->>I: IMAP Connection
    I->>C: 220 Ready
    C->>I: LOGIN user pass
    I->>C: OK Authenticated
    C->>I: SELECT INBOX
    I->>ST: Fetch Messages
    ST->>I: Message List
    I->>C: Message Headers
    C->>I: FETCH 1 RFC822
    I->>ST: Get Full Message
    ST->>I: Message Content
    I->>C: Email Content
Loading

Message Processing Pipeline

📤 Inbound Mail Flow

  1. SMTP Reception - Accept incoming connections
  2. Authentication - Verify sender credentials
  3. Queue Processing - Add to delivery queue
  4. Security Checks - SPF, DKIM, DMARC validation
  5. Message Storage - Persist to database
  6. Notification - Update mailbox indexes

📥 Outbound Mail Flow

  1. Message Composition - Create email content
  2. DKIM Signing - Cryptographic signature
  3. Queue Management - Add to outbound queue
  4. DNS Resolution - Find MX records
  5. Delivery Attempt - Send to destination
  6. Bounce Handling - Process delivery failures

🔍 Search & Retrieval

  1. Query Processing - Parse search criteria
  2. Index Lookup - Search optimized indexes
  3. Result Assembly - Gather matching messages
  4. Permission Check - Verify access rights
  5. Response Formatting - Structure output
  6. Client Delivery - Send to application

Performance Optimizations

⚡ Caching Strategy

  • Message Headers: Frequently accessed metadata
  • Authentication Tokens: Session credentials
  • DNS Results: MX record lookups
  • Configuration: Runtime settings

🔄 Parallel Processing

  • Message Delivery: Concurrent outbound sending
  • Mailbox Sync: Parallel IMAP operations
  • Search Queries: Multi-threaded indexing
  • Log Writing: Asynchronous audit trails

📊 Scalability Features

  • Horizontal Scaling: Multi-node deployment
  • Load Balancing: Distributed request handling
  • Data Sharding: Partitioned message storage
  • Connection Pooling: Reused database connections