# probesys/agentj architecture

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

- Interactive diagram: https://gitdiagram.com/probesys/agentj
- Repository: https://github.com/probesys/agentj

## Overview

##### Project type and purpose
- AgentJ is a Docker-orchestrated, full-stack mail-security system with a web interface.
- It combines a mail‐processing pipeline (Postfix, Amavis, SpamAssassin, ClamAV, OpenDKIM, policyd‐rate‐limit, sender verification) with a Symfony-based MVC web application (PHP 8.2, Twig, JS/CSS) and a MariaDB data store.

##### Key structural elements (from file tree and README)
- Top-level “app” folder: Symfony 7 application (src, templates, public assets, Dockerfiles, config).
- Service folders: “amavis”, “opendkim”, “policyd-rate-limit”, “smtp”, “senderverifmilter”. Each defines a container image, entrypoint script, and configuration files.
- Orchestration: docker-compose.yml and compose.dev.yml tie together containers.
- Data persistence: MariaDB initialized via mariadb-entrypoint-initdb.d in Docker.
- Testing: “tests” folder with Dockerfile and scripts for integration tests.

##### Essential details to capture
- All mail-processing containers and their scan/sign/relay sequence.
- Symfony MVC web UI and its assets pipeline (Webpack Encore).
- Database interactions via Doctrine.
- Background/cron tasks and Messenger usage.
- External connector integrations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    classDef mail fill:#D0E7FF,stroke:#000,stroke-width:1px
    classDef app fill:#D0FFD0,stroke:#000,stroke-width:1px
    classDef data fill:#FFE5B4,stroke:#000,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#000,stroke-width:1px

    Internet([Internet]):::external

    subgraph "Mail Pipeline"
        SMTPIn["SMTP-in (Postfix)"]:::mail
        Amavis["Amavis + SpamAssassin/ClamAV"]:::mail
        OpenDKIM["OpenDKIM"]:::mail
        Policyd["policyd-rate-limit"]:::mail
        SenderVerif["SenderVerifMilter"]:::mail
        SMTPOut["SMTP-out (Postfix)"]:::mail
        SMTPRelay["SMTP-relay (Postfix)"]:::mail
        Destination((Destination)):::external
    end

    subgraph "Application Layer"
        Browser([User Browser]):::external
        AppContainer["Symfony App Container"]:::app
        MVC["MVC Codebase"]:::app
        Workers["Background Workers"]:::app
    end

    subgraph "Data Layer"
        MariaDB[(MariaDB)]:::data
    end

    subgraph "External Services"
        LDAP[(LDAP/Active Directory)]:::external
        Office365[(Office365)]:::external
    end

    Internet -->|"SMTP"| SMTPIn
    SMTPIn -->|"LMTP"| Amavis
    Amavis -->|"scan/sign"| OpenDKIM
    OpenDKIM -->|"rate-limit"| Policyd
    Policyd -->|"SMTP"| SMTPOut
    SMTPOut -->|"relay"| SMTPRelay
    SMTPRelay -->|"deliver"| Destination

    Browser -->|"HTTP/S"| AppContainer
    SenderVerif -->|"API/DB"| AppContainer
    Workers -->|"invoke"| AppContainer

    AppContainer -->|"uses ORM"| MariaDB
    Workers -->|"reads/writes"| MariaDB

    Workers -->|"LDAP Import"| LDAP
    Workers -->|"O365 Import"| Office365

    AppContainer --> MVC

    Compose["Docker Compose"]:::external
    Compose --> SMTPIn
    Compose --> AppContainer
    Compose --> MariaDB

    class SMTPIn,Amavis,OpenDKIM,Policyd,SenderVerif,SMTPOut,SMTPRelay mail
    class AppContainer,MVC,Workers app
    class MariaDB data
    class Internet,Destination,LDAP,Office365,Compose external

    click SMTPIn "https://github.com/probesys/agentj/tree/main/smtp/Dockerfile"
    click Amavis "https://github.com/probesys/agentj/tree/main/amavis/Dockerfile"
    click OpenDKIM "https://github.com/probesys/agentj/tree/main/opendkim/Dockerfile"
    click Policyd "https://github.com/probesys/agentj/tree/main/policyd-rate-limit/Dockerfile"
    click SenderVerif "https://github.com/probesys/agentj/tree/main/senderverifmilter/Dockerfile"
    click SMTPOut "https://github.com/probesys/agentj/blob/main/smtp/conf/out/postfix/main.cf"
    click AppContainer "https://github.com/probesys/agentj/tree/main/app/Dockerfile"
    click MVC "https://github.com/probesys/agentj/tree/main/app/src"
    click Workers "https://github.com/probesys/agentj/tree/main/app/src/Command"
    click MariaDB "https://github.com/probesys/agentj/blob/main/mariadb-entrypoint-initdb.d/opendkim_user.sh"
    click Compose "https://github.com/probesys/agentj/blob/main/docker-compose.yml"
```
