# apache/spamassassin architecture

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

- Interactive diagram: https://gitdiagram.com/apache/spamassassin
- Repository: https://github.com/apache/spamassassin

## Overview

##### Main Components

a. Core Components:
- Mail Processing Engine (lib/Mail/SpamAssassin/)
- Rule System (rules/ directory)
- Plugin Architecture (lib/Mail/SpamAssassin/Plugin/)
- Bayes Engine (lib/Mail/SpamAssassin/Bayes/)
- Database Storage Systems (sql/)

b. Client/Server Components:
- Spamd Daemon (spamd/)
- Spamc Client (spamc/)
- Apache2 Integration (spamd-apache2/)

c. External Services Integration:
- DNS Blacklist Services
- Razor2
- Pyzor
- DCC
- Various DBL Services

- Client Layer  |

- Service Layer |

- Storage Layer  |

##### Component Relationships

- Mail flow from input through processing pipeline
- Plugin interaction with core engine
- Database connections for various storage backends
- External service communication paths

##### Key Elements to Highlight

a. Input/Output:
- Mail input sources
- Processing results output
- Report generation

b. Processing Pipeline:
- Header analysis
- Body text analysis
- URI checking
- Rule evaluation
- Score computation

c. Storage Systems:
- Bayes database
- Auto-Welcomelist
- TxRep
- User preferences

##### Integration Points

Connections for:
- MTA integration
- Database system connections
- External service APIs
- Plugin hooks

##### Additional Details

Annotations for:
- Configuration file locations
- Plugin loading points
- Database schema references
- API endpoints

- Modular architecture
- Plugin extensibility
- Multiple storage backend support
- Scalability features
- Security boundaries

Remember to:
- Use consistent symbols
- Related components
- Clear data flow directions
- Version information

This system design should capture SpamAssassin's sophisticated architecture while remaining comprehensible to both developers and system administrators.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        SPAMC[Spamc Client]
        APACHE[Apache2 Integration]
        MTA[Mail Transfer Agent]
    end

    subgraph Service
        SPAMD[Spamd Daemon]
        MPE[Mail Processing Engine]
        PLUGIN[Plugin Architecture]
        RULES[Rule System]
        BAYES[Bayes Engine]
    end

    subgraph Storage
        DB[(Database Systems)]
        PREF[(User Preferences)]
        AWL[(Auto-Welcomelist)]
        TXREP[(TxRep)]
    end

    subgraph "External Services"
        DNSBL[DNS Blacklist]
        RAZOR[Razor2]
        PYZOR[Pyzor]
        DCC[DCC]
        DBL[DBL Services]
    end

    %% Client Layer Connections
    SPAMC --> SPAMD
    APACHE --> SPAMD
    MTA --> SPAMD

    %% Service Layer Connections
    SPAMD --> MPE
    MPE --> PLUGIN
    MPE --> RULES
    MPE --> BAYES

    %% Storage Layer Connections
    BAYES --> DB
    MPE --> PREF
    MPE --> AWL
    MPE --> TXREP

    %% External Service Connections
    PLUGIN --> DNSBL
    PLUGIN --> RAZOR
    PLUGIN --> PYZOR
    PLUGIN --> DCC
    PLUGIN --> DBL

    %% Component Mappings
    click MPE "https://github.com/apache/spamassassin/tree/trunk/lib/Mail/SpamAssassin/"
    click RULES "https://github.com/apache/spamassassin/tree/trunk/rules/"
    click PLUGIN "https://github.com/apache/spamassassin/tree/trunk/lib/Mail/SpamAssassin/Plugin/"
    click BAYES "https://github.com/apache/spamassassin/tree/trunk/lib/Mail/SpamAssassin/Bayes/"
    click DB "https://github.com/apache/spamassassin/tree/trunk/sql/"
    click SPAMD "https://github.com/apache/spamassassin/tree/trunk/spamd/"
    click SPAMC "https://github.com/apache/spamassassin/tree/trunk/spamc/"
    click APACHE "https://github.com/apache/spamassassin/tree/trunk/spamd-apache2/"
    click DNSBL "https://github.com/apache/spamassassin/blob/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm"
    click RAZOR "https://github.com/apache/spamassassin/blob/trunk/lib/Mail/SpamAssassin/Plugin/Razor2.pm"
    click PYZOR "https://github.com/apache/spamassassin/blob/trunk/lib/Mail/SpamAssassin/Plugin/Pyzor.pm"
    click DCC "https://github.com/apache/spamassassin/blob/trunk/lib/Mail/SpamAssassin/Plugin/DCC.pm"

    %% Styling
    classDef client fill:#FFE5CC,stroke:#333,stroke-width:2px
    classDef service fill:#CCE5FF,stroke:#333,stroke-width:2px
    classDef storage fill:#E5CCFF,stroke:#333,stroke-width:2px
    classDef external fill:#CCFFE5,stroke:#333,stroke-width:2px

    class SPAMC,APACHE,MTA client
    class SPAMD,MPE,PLUGIN,RULES,BAYES service
    class DB,PREF,AWL,TXREP storage
    class DNSBL,RAZOR,PYZOR,DCC,DBL external
```
