# alexisducerf/maarchcourrier architecture

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

- Interactive diagram: https://gitdiagram.com/alexisducerf/maarchcourrier
- Repository: https://github.com/alexisducerf/maarchcourrier

## Overview

##### Project Type and Purpose
- Maarch_Courrier is a monolithic, full-stack PHP web application providing electronic mail and document management (GEC).
- It supports desktop and smartphone clients, extensive modular features (attachments, life-cycle, full text, CMIS integration, SOAP/REST web services), and batch processes (indexing, notifications).

##### High-Level Architectural Components
a. Clients
- Desktop browsers (HTML/CSS/JS using apps/maarch_entreprise/js & css)
- Smartphone UI (apps/maarch_entreprise/smartphone)
b. Web Server Layer
- Nginx or Apache serving index.php and ws_server.php
- PHP-FPM or mod_php runtime
- Docker stack available in dockerphp56 for consistent dev/test
c. Application Layer (PHP code)
- Entry points:
– index.php (front controller)
– install/index.php (installation wizard)
– ws_server.php (SOAP/REST/XML-RPC endpoints)
- Core framework (core/): request routing, base controllers, security, session, service control, ORM/db abstraction
- Business modules (modules/ & apps/maarch_entreprise/): each feature comes as a module directory with:
– PHP controllers, classes (class/, ws.php)
– UI templates (template/, css/, js/, lang/, xml/IVS for validation, xml/services for API)
– SQL definitions (sql/data, sql/structure)
– Batch scripts for offline jobs (batch_tools, scripts/*.sh/.bat)
- Shared libraries (apps/maarch_entreprise/tools/): PEAR SOAP, Zend Lucene (full-text), Html2Text, Log4php, PDF libs, phpids, tinyMCE, QRCode, etc.
d. Data Storage
- Relational Database (PostgreSQL primary; supports MySQL/Oracle) – stores application data, modules’ tables, ACLs, history, indexing metadata.
- File storage for attachments, document conversions, PDF prints.
- Full-text index (Zend_Search_Lucene under tools/Zend/Search/Lucene).
e. External Services
- IMAP/SMTP for mail sending/receiving (php_imap, pear/SOAP for mail gateway)
- CMIS repository for document storage (class/cmis)
- LibreOffice, Ghostscript, wkhtmltopdf, Imagick for document conversions
- LDAP module for user synchronization (modules/ldap)
- Web services: SOAP, REST, XML-RPC endpoints provide CRM integration
f. Batch/CRON Jobs
- Full-text indexing (modules/full_text/scripts & batch)
- Notifications (modules/notifications/batch)
- Thumbnails generation (modules/thumbnails/batch)
- Life-cycle processes (modules/life_cycle/batch)
- Sendmail queue processing (modules/sendmail/batch)

##### Relationships and Data Flows
- Browser → HTTP → Web Server → PHP Front Controller → Core Router
- Router dispatches requests to modules/controllers under apps/ or modules/
- Controllers invoke domain classes (core/class, modules/*/class) → DB via PDO (class/class_db_pdo.php)
- Data returned to controllers → templates → HTML/CSS/JS to client
- File uploads/downloads managed via PHP and physical storage
- Batch scripts invoked by Cron → CLI PHP → modules’ batch_tools → DB/filesystem/index engine

##### Architectural Patterns & Principles
- Modular monolith: each feature encapsulated in its own directory with consistent structure (class, controller, view, sql, xml, lang, js, css).
- Front-controller & router in core/init.php → dispatch to object controllers.
- Data abstraction via core/class/class_db_pdo and class_db for multi-DB support.
- Separation of concerns: core framework vs feature modules vs shared tools.
- XML-driven configuration/validation (xml/IVS, xml/services, xml/menu).
- Support for extensibility: custom/ directory for overrides, modules can be added or disabled via XML.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients Layer
    subgraph "Clients" 
        direction TB
        DesktopUI["Desktop Browser\n(HTML/CSS/JS)"]:::client
        MobileUI["Smartphone UI"]:::client
    end

    %% Web Server & Runtime
    subgraph "Web Server & PHP Runtime"
        direction TB
        WebServer["Nginx/Apache"]:::server
        PHPRuntime["PHP-FPM / mod_php"]:::server
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        FrontController["index.php\n(Front Controller)"]:::app
        InstallWizard["install/index.php\n(Installation Wizard)"]:::app
        WebServices["ws_server.php\n(SOAP/REST/XML-RPC)"]:::app

        subgraph "Core Framework"
            direction TB
            CoreInit["core/init.php\n(Init & Routing)"]:::core
            CoreClasses["core/class/"]:::core
            CoreDB["class_db.php\nclass_db_pdo.php"]:::core
            CoreSQL["core/sql/"]:::core
            CoreXML["core/xml/\ncore/xml/IVS/"]:::core
        end

        subgraph "Feature Modules"
            direction TB
            Attachments["modules/attachments"]:::module
            FullText["modules/full_text"]:::module
            LifeCycle["modules/life_cycle"]:::module
            Notifications["modules/notifications"]:::module
            Thumbnails["modules/thumbnails"]:::module
            Sendmail["modules/sendmail"]:::module
            LDAP["modules/ldap"]:::module
        end

        subgraph "Shared Tools & Libraries"
            direction TB
            PEARSOAP["apps/maarch_entreprise/tools/PEAR/SOAP/"]:::tool
            ZendLucene["apps/maarch_entreprise/tools/Zend/Search/Lucene/"]:::tool
            HTML2Text["apps/maarch_entreprise/tools/html2text/"]:::tool
            Log4php["apps/maarch_entreprise/tools/log4php/"]:::tool
            PDFLibs["apps/maarch_entreprise/tools/pdfb/\napps/maarch_entreprise/tools/pdfb/fpdf_1_7/"]:::tool
            PHPIDS["apps/maarch_entreprise/tools/phpids/"]:::tool
            TinyMCE["apps/maarch_entreprise/tools/tiny_mce/"]:::tool
            QRCode["apps/maarch_entreprise/tools/phpqrcode/"]:::tool
        end
    end

    %% Data Storage
    subgraph "Data Storage"
        direction TB
        RDBMS["PostgreSQL\n(MySQL/Oracle)"]:::db
        FileStore["File Storage"]:::db
        FullTextIndex["Zend_Search_Lucene\nIndex"]:::db
    end

    %% External Services
    subgraph "External Services"
        direction TB
        SMTPIMAP["IMAP/SMTP"]:::external
        CMIS["CMIS Repository"]:::external
        Conversion["LibreOffice/Ghostscript/\nwkhtmltopdf/Imagick"]:::external
        LDAPService["LDAP Sync"]:::external
    end

    %% Batch/CRON Jobs
    subgraph "Batch / CRON Jobs"
        direction TB
        BatchFullText["modules/full_text/scripts"]:::batch
        BatchNotifications["modules/notifications/batch/scripts"]:::batch
        BatchThumbnails["modules/thumbnails/scripts"]:::batch
        BatchLifeCycle["modules/life_cycle/batch/scripts"]:::batch
        BatchSendmail["modules/sendmail/batch/scripts"]:::batch
    end

    %% Docker Dev Stack
    Docker["dockerphp56/"]:::docker

    %% Custom Overrides and SQL
    CustomExt["custom/"]:::misc
    SQLSchema["sql/ & apps/maarch_entreprise/sql/"]:::misc

    %% Connections
    DesktopUI -->|HTTP| WebServer
    MobileUI -->|HTTP| WebServer
    WebServer --> PHPRuntime
    PHPRuntime --> FrontController
    PHPRuntime --> InstallWizard
    PHPRuntime --> WebServices

    FrontController --> CoreInit
    InstallWizard --> CoreInit
    WebServices --> CoreInit

    CoreInit --> CoreClasses
    CoreInit --> CoreDB
    CoreInit --> CoreSQL
    CoreInit --> CoreXML

    CoreClasses --> Attachments
    CoreClasses --> FullText
    CoreClasses --> LifeCycle
    CoreClasses --> Notifications
    CoreClasses --> Thumbnails
    CoreClasses --> Sendmail
    CoreClasses --> LDAP

    Attachments --> RDBMS
    FullText --> RDBMS
    LifeCycle --> RDBMS
    Notifications --> RDBMS
    Thumbnails --> FileStore
    Sendmail --> RDBMS
    LDAP --> RDBMS

    Attachments --> FileStore
    FullText --> FullTextIndex

    WebServices --> SMTPIMAP
    WebServices --> CMIS
    WebServices --> LDAPService

    FrontController -->|uses| PEARSOAP
    FullText -->|uses| ZendLucene
    FrontController -->|uses| HTML2Text
    FrontController -->|uses| Log4php
    FrontController -->|uses| PDFLibs
    FrontController -->|uses| PHPIDS
    FrontController -->|uses| TinyMCE
    FrontController -->|uses| QRCode

    BatchFullText --> RDBMS
    BatchFullText --> FullTextIndex
    BatchNotifications --> RDBMS
    BatchThumbnails --> FileStore
    BatchLifeCycle --> RDBMS
    BatchSendmail --> RDBMS

    Docker --> WebServer
    Docker --> PHPRuntime

    CustomExt --> Attachments
    CustomExt --> FullText
    CustomExt --> LifeCycle
    CustomExt --> Notifications
    CustomExt --> Thumbnails
    CustomExt --> Sendmail
    CustomExt --> LDAP

    SQLSchema --> RDBMS

    %% Click Events
    click DesktopUI "https://github.com/alexisducerf/maarchcourrier/tree/master/apps/maarch_entreprise/css"
    click DesktopUI "https://github.com/alexisducerf/maarchcourrier/tree/master/apps/maarch_entreprise/js"
    click MobileUI "https://github.com/alexisducerf/maarchcourrier/tree/master/apps/maarch_entreprise/smartphone"
    click FrontController "https://github.com/alexisducerf/maarchcourrier/blob/master/index.php"
    click InstallWizard "https://github.com/alexisducerf/maarchcourrier/blob/master/install/index.php"
    click WebServices "https://github.com/alexisducerf/maarchcourrier/blob/master/ws_server.php"
    click CoreInit "https://github.com/alexisducerf/maarchcourrier/blob/master/core/init.php"
    click CoreClasses "https://github.com/alexisducerf/maarchcourrier/tree/master/core/class/"
    click CoreDB "https://github.com/alexisducerf/maarchcourrier/blob/master/core/class/class_db_pdo.php"
    click CoreDB "https://github.com/alexisducerf/maarchcourrier/blob/master/core/class/class_db.php"
    click CoreSQL "https://github.com/alexisducerf/maarchcourrier/tree/master/core/sql/"
    click CoreXML "https://github.com/alexisducerf/maarchcourrier/tree/master/core/xml/"
    click CoreXML "https://github.com/alexisducerf/maarchcourrier/tree/master/core/xml/IVS/"
    click Attachments "https://github.com/alexisducerf/maarchcourrier/tree/master/modules/attachments"
    click FullText "https://github.com/alexisducerf/maarchcourrier/tree/master/modules/full_text"
    click LifeCycle "https://github.com/alexisducerf/maarchcourrier/tree/master/modules/life_cycle"
    click Notifications "https://github.com/alexisducerf/maarchcourrier/tree/master/modules/notifications"
    click Thumbnails "https://github.com/alexisducerf/maarchcourrier/tree/master/modules/thumbnails"
    click Sendmail "https://github.com/alexisducerf/maarchcourrier/tree/master/modules/sendmail"
    click LDAP "https://github.com/alexisducerf/maarchcourrier/tree/master/modules/ldap"
    click PEARSOAP "https://github.com/alexisducerf/maarchcourrier/tree/master/apps/maarch_entreprise/tools/PEAR/SOAP/"
    click ZendLucene "https://github.com/alexisducerf/maarchcourrier/tree/master/apps/maarch_entreprise/tools/Zend/Search/Lucene/"
    click HTML2Text "https://github.com/alexisducerf/maarchcourrier/tree/master/apps/maarch_entreprise/tools/html2text/"
    click Log4php "https://github.com/alexisducerf/maarchcourrier/tree/master/apps/maarch_entreprise/tools/log4php/"
    click PDFLibs "https://github.com/alexisducerf/maarchcourrier/tree/master/apps/maarch_entreprise/tools/pdfb/"
    click PDFLibs "https://github.com/alexisducerf/maarchcourrier/tree/master/apps/maarch_entreprise/tools/pdfb/fpdf_1_7/"
    click PHPIDS "https://github.com/alexisducerf/maarchcourrier/tree/master/apps/maarch_entreprise/tools/phpids/"
    click TinyMCE "https://github.com/alexisducerf/maarchcourrier/tree/master/apps/maarch_entreprise/tools/tiny_mce/"
    click QRCode "https://github.com/alexisducerf/maarchcourrier/tree/master/apps/maarch_entreprise/tools/phpqrcode/"
    click Docker "https://github.com/alexisducerf/maarchcourrier/tree/master/dockerphp56/"
    click BatchFullText "https://github.com/alexisducerf/maarchcourrier/tree/master/modules/full_text/scripts/"
    click BatchNotifications "https://github.com/alexisducerf/maarchcourrier/tree/master/modules/notifications/batch/scripts/"
    click BatchThumbnails "https://github.com/alexisducerf/maarchcourrier/tree/master/modules/thumbnails/scripts/"
    click BatchLifeCycle "https://github.com/alexisducerf/maarchcourrier/tree/master/modules/life_cycle/batch/scripts/"
    click BatchSendmail "https://github.com/alexisducerf/maarchcourrier/tree/master/modules/sendmail/batch/scripts/"
    click CustomExt "https://github.com/alexisducerf/maarchcourrier/tree/master/custom/"
    click SQLSchema "https://github.com/alexisducerf/maarchcourrier/tree/master/sql/"
    click SQLSchema "https://github.com/alexisducerf/maarchcourrier/tree/master/apps/maarch_entreprise/sql/"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#0066CC,color:#003366
    classDef server fill:#DFF2D8,stroke:#4F8A10,color:#336600
    classDef app fill:#EAF5FF,stroke:#3385FF,color:#004C99
    classDef core fill:#D1E7DD,stroke:#0F5132,color:#0B2E13
    classDef module fill:#E0F7FA,stroke:#007C91,color:#004D59
    classDef tool fill:#F0F0F0,stroke:#888888,color:#333333
    classDef db fill:#FFF3CD,stroke:#FFEEBA,color:#664D03
    classDef external fill:#FFE5D9,stroke:#FF8C42,color:#A63A00
    classDef batch fill:#F3E5F5,stroke:#CE93D8,color:#6A1B9A
    classDef docker fill:#E0E0E0,stroke:#9E9E9E,color:#424242
    classDef misc fill:#F5F5F5,stroke:#BDBDBD,color:#616161
```
