# karastojko/mailio architecture

> Architecture diagram of the GitHub repository karastojko/mailio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/karastojko/mailio
- Repository: https://github.com/karastojko/mailio

## Overview

##### Main Components

a) Core Library Components:
- MIME Message Handler
- Protocol Handlers (SMTP, POP3, IMAP)
- Encoding/Decoding Systems
- Dialog Management

b) External Dependencies:
- OpenSSL (for SSL/TLS support)
- Boost Library
- C++ Standard Library

**┌─────────────────────────────────────────────┐**
- Client Application             │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Mailio Public API              │
- ┬─────────────┬────────────────┤
- SMTP     │    POP3     │      IMAP      │
- Handler    │   Handler    │    Handler     │
- ┴─────────────┴────────────────┘
- ↓
**┌─────────────────────────────────────────────┐**
- Message Processing Layer           │
- ┬─────────────┬────────────────┤
- MIME     │   Message   │    Mailbox     │
- Processor  │   Builder   │    Manager     │
- ┴─────────────┴────────────────┘
- ↓
**┌─────────────────────────────────────────────┐**
- Encoding Layer                  │
- ┬────────┬────────┬────────┬────────┤
- Base64  │Binary  │ Bit7   │ Bit8   │  QP    │
- ┴────────┴────────┴────────┴────────┘
- ↓
**┌─────────────────────────────────────────────┐**
- Network Layer                  │
- (Dialog & Protocol Handling)         │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- External Dependencies             │
- ┬─────────────┬────────────────┤
- OpenSSL   │    Boost    │  C++ Std Lib   │
- ┴─────────────┴────────────────┘

##### Important Elements to Highlight

a) Protocol Support:

b) Message Processing:
- Relationship between MIME processing and message building
- Support for different content types and encodings

c) Encoding Systems:
- Encoding methods (Base64, Binary, Bit7, Bit8, Quoted Printable)
- Their relationship to both message processing and network layers

##### Implementation Details to Consider

- Relationship between header files (from include/mailio/) and their implementations
- Separation between public API and internal implementations
- Extension points for future features (like IMAP IDLE support)

##### Key Interactions to Illustrate

- Message creation and parsing flow
- Protocol handler interaction with the network layer
- Encoding/decoding process flow
- Authentication flow for different protocols

- Clear hierarchical layouts
- Proper text formatting
- Export to common formats

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Application"]
        CA[Client Code]
    end

    subgraph API["Mailio Public API"]
        SMTP["SMTP Handler"]:::protocol
        POP3["POP3 Handler"]:::protocol
        IMAP["IMAP Handler"]:::protocol
    end

    subgraph Processing["Message Processing Layer"]
        MIME["MIME Processor"]:::core
        MSG["Message Handler"]:::core
        MBX["Mailbox Manager"]:::core
    end

    subgraph Encoding["Encoding Layer"]
        B64["Base64"]:::encoding
        BIN["Binary"]:::encoding
        B7["Bit7"]:::encoding
        B8["Bit8"]:::encoding
        QP["Quoted Printable"]:::encoding
        CB["Codec Base"]:::encoding
    end

    subgraph Network["Network Layer"]
        DLG["Dialog Manager"]:::network
    end

    subgraph External["External Dependencies"]
        SSL["OpenSSL"]:::external
        BOOST["Boost"]:::external
        STD["C++ Std Lib"]:::external
    end

    %% Connections
    CA --> SMTP & POP3 & IMAP
    SMTP & POP3 & IMAP --> MIME
    MIME --> MSG
    MSG --> MBX
    MSG --> B64 & BIN & B7 & B8 & QP
    B64 & BIN & B7 & B8 & QP --> CB
    SMTP & POP3 & IMAP --> DLG
    DLG --> SSL & BOOST & STD

    %% Click Events
    click SMTP "https://github.com/karastojko/mailio/blob/master/include/mailio/smtp.hpp"
    click POP3 "https://github.com/karastojko/mailio/blob/master/include/mailio/pop3.hpp"
    click IMAP "https://github.com/karastojko/mailio/blob/master/include/mailio/imap.hpp"
    click MIME "https://github.com/karastojko/mailio/blob/master/include/mailio/mime.hpp"
    click MSG "https://github.com/karastojko/mailio/blob/master/include/mailio/message.hpp"
    click MBX "https://github.com/karastojko/mailio/blob/master/include/mailio/mailboxes.hpp"
    click B64 "https://github.com/karastojko/mailio/blob/master/include/mailio/base64.hpp"
    click BIN "https://github.com/karastojko/mailio/blob/master/include/mailio/binary.hpp"
    click B7 "https://github.com/karastojko/mailio/blob/master/include/mailio/bit7.hpp"
    click B8 "https://github.com/karastojko/mailio/blob/master/include/mailio/bit8.hpp"
    click QP "https://github.com/karastojko/mailio/blob/master/include/mailio/quoted_printable.hpp"
    click DLG "https://github.com/karastojko/mailio/blob/master/include/mailio/dialog.hpp"
    click CB "https://github.com/karastojko/mailio/blob/master/include/mailio/codec.hpp"

    %% Styles
    classDef protocol fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef encoding fill:#FFE4B5,stroke:#333,stroke-width:2px
    classDef network fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        P1[Protocol Handlers]:::protocol
        C1[Core Components]:::core
        E1[Encoding Components]:::encoding
        N1[Network Components]:::network
        EX1[External Dependencies]:::external
    end
```
