# vdukhovni/postfix architecture

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

- Interactive diagram: https://gitdiagram.com/vdukhovni/postfix
- Repository: https://github.com/vdukhovni/postfix

## Overview

##### Main Components

a. Core Mail Processing Components:
- SMTP Server (smtpd)
- Queue Manager (qmgr)
- Cleanup Daemon
- Local Delivery Agent
- SMTP Client
- Trivial Rewrite Daemon

b. Security and Authentication Components:
- TLS Manager (tlsmgr)
- SASL Authentication Framework
- Postscreen Daemon
- Access Controls

c. Supporting Services:
- Master Daemon (process manager)
- Lookup Tables
- Address Rewriting
- Mail Filtering

##### Component Relationships

- Incoming mail flow through SMTP/Postscreen
- Queue management and routing
- Delivery paths (local and remote)
- Authentication and security layers
- Database and lookup table interactions

##### Key Processes to Highlight

a. Mail Flow:
- Internet -> Postscreen -> SMTPD -> Cleanup -> Queue -> Delivery

b. Authentication Chain:
- Client -> TLS -> SASL -> Access Control -> Processing

##### Integration Points

Connections to:
- External databases (MySQL, LDAP, etc.)
- DNS services
- Authentication systems
- Mail filtering systems

##### Queue Structure

Different queue types:
- Incoming
- Active
- Deferred
- Hold
- Corrupt

##### Configuration Elements

Configuration components:
- main.cf settings
- master.cf services
- Access tables
- Transport maps

##### Monitoring Points

Monitoring interfaces:
- Logging subsystem
- Performance metrics
- Health checks

- Top level: External interfaces
- Middle level: Core processing
- Bottom level: Storage and resources

This will provide a clear visualization of Postfix's complex mail processing architecture while maintaining the necessary technical detail for a principal software engineer to understand the system's operation and interactions.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Internet
        Client([External Mail Client])
        RemoteMTA([Remote Mail Server])
    end

    subgraph "Security Layer"
        PS[Postscreen Daemon]:::security
        TLS[TLS Manager]:::security
        SASL[SASL Auth]:::security
        AC[Access Controls]:::security
    end

    subgraph "Core Processing"
        SMTP[SMTP Server]:::core
        Clean[Cleanup Daemon]:::core
        Rewrite[Trivial Rewrite]:::core
        QMgr[Queue Manager]:::core
    end

    subgraph "Delivery Agents"
        Local[Local Delivery]:::delivery
        SMTPClient[SMTP Client]:::delivery
    end

    subgraph "Queue Storage"
        InQueue[(Incoming)]:::storage
        ActQueue[(Active)]:::storage
        DefQueue[(Deferred)]:::storage
        HoldQueue[(Hold)]:::storage
        CorruptQueue[(Corrupt)]:::storage
    end

    subgraph "Configuration"
        MainCF[main.cf]:::config
        MasterCF[master.cf]:::config
        AccessTables[Access Tables]:::config
        AddrRewrite[Address Rewriting]:::config
    end

    subgraph "Process Management"
        Master[Master Daemon]:::mgmt
    end

    Client --> PS
    RemoteMTA --> PS
    PS --> TLS
    TLS --> SASL
    SASL --> AC
    AC --> SMTP
    SMTP --> Clean
    Clean --> Rewrite
    Rewrite --> QMgr
    QMgr --> Local
    QMgr --> SMTPClient
    QMgr --> InQueue
    QMgr --> ActQueue
    QMgr --> DefQueue
    QMgr --> HoldQueue
    QMgr --> CorruptQueue
    Master --> SMTP
    Master --> Clean
    Master --> QMgr
    Master --> Local
    Master --> SMTPClient
    MainCF --> Master
    MasterCF --> Master
    AccessTables --> AC
    AddrRewrite --> Rewrite

    classDef core fill:#3498db
    classDef security fill:#2ecc71
    classDef delivery fill:#e74c3c
    classDef storage fill:#f1c40f
    classDef config fill:#9b59b6
    classDef mgmt fill:#34495e

    click SMTP "https://github.com/vdukhovni/postfix/blob/master/postfix/src/smtpd/smtpd.c"
    click QMgr "https://github.com/vdukhovni/postfix/blob/master/postfix/src/qmgr/qmgr.c"
    click Clean "https://github.com/vdukhovni/postfix/blob/master/postfix/src/cleanup/cleanup.c"
    click Local "https://github.com/vdukhovni/postfix/blob/master/postfix/src/local/local.c"
    click SMTPClient "https://github.com/vdukhovni/postfix/blob/master/postfix/src/smtp/smtp.c"
    click Rewrite "https://github.com/vdukhovni/postfix/blob/master/postfix/src/trivial-rewrite/trivial-rewrite.c"
    click TLS "https://github.com/vdukhovni/postfix/blob/master/postfix/src/tlsmgr/tlsmgr.c"
    click SASL "https://github.com/vdukhovni/postfix/blob/master/postfix/src/xsasl/xsasl.h"
    click PS "https://github.com/vdukhovni/postfix/blob/master/postfix/src/postscreen/postscreen.c"
    click Master "https://github.com/vdukhovni/postfix/blob/master/postfix/src/master/master.c"
    click MainCF "https://github.com/vdukhovni/postfix/blob/master/postfix/conf/main.cf"
    click MasterCF "https://github.com/vdukhovni/postfix/blob/master/postfix/conf/master.cf"
    click AccessTables "https://github.com/vdukhovni/postfix/tree/master/postfix/conf/access"
    click AddrRewrite "https://github.com/vdukhovni/postfix/tree/master/postfix/conf/canonical"
```
