# wascripts/wanewsletter architecture

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

- Interactive diagram: https://gitdiagram.com/wascripts/wanewsletter
- Repository: https://github.com/wascripts/wanewsletter

## Overview

#### Purpose and entry points
WAnewsletter is a PHP-based newsletter management system: it collects subscriptions, manages mailing lists and subscriber profiles, composes and sends campaigns, and exposes archives/profile actions. Public entry points are `subscribe.php`, `newsletter.php`, and `profil_cp.php`; installation begins at `install.php`. Administrative workflows are rooted at `admin/index.php`, with campaign sending in `admin/envoi.php`.

#### Bootstrap, configuration, and shared runtime
Request initialization and common behavior are centralized in `includes/common.inc.php`, supported by constants and shared functions in `includes/constantes.php` and `includes/functions.php`. Runtime configuration is expected under `data/config.sample.inc.php` (deployed as a local config), while mutable application state is stored beneath `data/`, including database, logs, uploads, stats, and temporary files. The application is server-rendered PHP rather than a separate frontend service.

#### Public subscription and subscriber lifecycle
Public-facing flows accept subscriptions and profile changes through `subscribe.php` and `profil_cp.php`. Domain operations are represented by `includes/Subscription.php`, authentication/session behavior by `includes/Auth.php` and `includes/Session.php`, and email confirmation/welcome/unsubscribe text is localized under `languages/en/emails/` and `languages/fr/emails/`. These flows form the boundary between anonymous users and persisted subscriber/list records.

#### Administrative control plane
The admin area handles login, configuration, list/subscriber inspection, campaign authoring, tools, statistics, upgrades, and sending. Key controllers include `admin/login.php`, `admin/config.php`, `admin/show.php`, `admin/stats.php`, and `admin/envoi.php`; they share initialization through `admin/start.inc.php`. Admin templates in `templates/admin/` provide the rendered management UI and campaign send-progress views.

#### Campaign composition, rendering, and delivery
Campaign control flows move from admin composition into templated content and outbound delivery. `includes/Template.php` renders application and message layouts; `includes/Sender.php` is the outbound mail boundary; `includes/Attach.php` handles attached files. `newsletter.php` provides archive/public newsletter presentation. Delivery status and operational outcomes feed logs and statistics under `data/logs/` and `data/stats/`.

#### Persistence and database abstraction
Database access is abstracted behind `includes/Dblayer/Wadb.php` and engine-specific implementations: `includes/Dblayer/Mysqli.php`, `includes/Dblayer/Postgres.php`, `includes/Dblayer/Sqlite3.php`, and `includes/Dblayer/SqlitePdo.php`. Initial schemas are provided in `includes/Dblayer/schemas/`. This isolates subscriber, list, campaign, and administrative data from the selected MySQL, PostgreSQL, or SQLite backend; backup implementations sit alongside the respective drivers.

#### Output, extensibility, and operations
Output can target HTML, JSON, or command-line contexts through `includes/Output/Html.php`, `includes/Output/Json.php`, and `includes/Output/CommandLine.php`. Scheduled or integration-oriented behavior is exposed through `options/cron.php` and `options/extra.php`, with contributor utilities in `contrib/` for conversion, cleanup, and related maintenance. External service dependencies are primarily the configured database and the host’s mail transport; `includes/PopClient.php` additionally indicates POP mailbox interaction capability.

Main entry points: [`admin/envoi.php`](https://github.com/wascripts/wanewsletter/blob/develop/admin/envoi.php) (Campaign sending), [`includes/common.inc.php`](https://github.com/wascripts/wanewsletter/blob/develop/includes/common.inc.php) (Shared runtime), [`admin/start.inc.php`](https://github.com/wascripts/wanewsletter/blob/develop/admin/start.inc.php) (Admin bootstrap), [`includes/Template.php`](https://github.com/wascripts/wanewsletter/blob/develop/includes/Template.php) (Template renderer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public flows"]
  node_public_subscription["Subscription &amp; profiles<br/>PHP entry points"]
  node_archive["Newsletter archive<br/>PHP entry point<br/>[newsletter.php]"]
end

subgraph group_admin["Admin control plane"]
  node_admin_controllers["Admin controllers<br/>PHP control plane"]
  node_campaign_send["Campaign sending<br/>PHP controller<br/>[envoi.php]"]
  node_admin_bootstrap["Admin bootstrap<br/>PHP include<br/>[start.inc.php]"]
  node_admin_templates["Admin UI templates"]
end

subgraph group_core["Application core"]
  node_common_runtime["Shared runtime<br/>PHP bootstrap<br/>[common.inc.php]"]
  node_domain["Subscriber domain<br/>PHP domain layer"]
  node_template["Template renderer<br/>PHP rendering layer<br/>[Template.php]"]
  node_email_copy["Localized email copy<br/>email templates"]
  node_delivery{{"Mail delivery<br/>outbound mail boundary"}}
  node_output["Output adapters<br/>presentation adapters"]
end

subgraph group_ops["Persistence &amp; operations"]
  node_install["Installer<br/>PHP entry point<br/>[install.php]"]
  node_database_layer["Database abstraction<br/>PHP persistence layer"]
  node_schemas["Database schemas<br/>schema definitions"]
  node_state[("Application state<br/>mutable storage")]
  node_automation["Scheduled integrations<br/>PHP automation"]
  node_mail_transport{{"Host mail transport<br/>external service"}}
  node_database[("Configured database<br/>external database")]
  node_pop{{"POP mailbox client<br/>mail integration<br/>[PopClient.php]"}}
end

node_install -->|"installs"| node_schemas
node_schemas -->|"defines"| node_database
node_public_subscription -->|"bootstraps"| node_common_runtime
node_public_subscription -->|"updates subscribers"| node_domain
node_archive -->|"bootstraps"| node_common_runtime
node_archive -->|"renders with"| node_template
node_admin_controllers -->|"initializes via"| node_admin_bootstrap
node_campaign_send -->|"initializes via"| node_admin_bootstrap
node_admin_bootstrap -->|"shares runtime"| node_common_runtime
node_admin_controllers -->|"renders"| node_admin_templates
node_campaign_send -->|"shows progress"| node_admin_templates
node_admin_controllers -->|"manages"| node_domain
node_campaign_send -->|"composes"| node_template
node_template -->|"uses"| node_email_copy
node_campaign_send -->|"dispatches"| node_delivery
node_delivery -->|"sends through"| node_mail_transport
node_domain -->|"persists through"| node_database_layer
node_database_layer -->|"connects to"| node_database
node_common_runtime -->|"selects output"| node_output
node_campaign_send -->|"records outcomes"| node_state
node_automation -->|"runs application logic"| node_common_runtime
node_automation -.->|"can trigger delivery"| node_delivery
node_pop -.->|"mailbox interaction"| node_domain

click node_install "https://github.com/wascripts/wanewsletter/blob/develop/install.php"
click node_archive "https://github.com/wascripts/wanewsletter/blob/develop/newsletter.php"
click node_campaign_send "https://github.com/wascripts/wanewsletter/blob/develop/admin/envoi.php"
click node_admin_bootstrap "https://github.com/wascripts/wanewsletter/blob/develop/admin/start.inc.php"
click node_admin_templates "https://github.com/wascripts/wanewsletter/tree/develop/templates/admin"
click node_common_runtime "https://github.com/wascripts/wanewsletter/blob/develop/includes/common.inc.php"
click node_template "https://github.com/wascripts/wanewsletter/blob/develop/includes/Template.php"
click node_schemas "https://github.com/wascripts/wanewsletter/tree/develop/includes/Dblayer/schemas"
click node_state "https://github.com/wascripts/wanewsletter/tree/develop/data"
click node_pop "https://github.com/wascripts/wanewsletter/blob/develop/includes/PopClient.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_subscription,node_archive toneBlue
class node_admin_controllers,node_campaign_send,node_admin_bootstrap,node_admin_templates toneAmber
class node_common_runtime,node_domain,node_template,node_email_copy,node_delivery,node_output toneMint
class node_install,node_database_layer,node_schemas,node_state,node_automation,node_mail_transport,node_database,node_pop toneRose
```

## Components

### Public flows

- **Subscription & profiles**: PHP entry points · Accepts subscriptions and profile changes.
- [Newsletter archive](https://github.com/wascripts/wanewsletter/blob/develop/newsletter.php): PHP entry point · Renders public newsletter presentation. · `newsletter.php`

### Admin control plane

- **Admin controllers**: PHP control plane · Manages configuration, lists, subscribers, campaigns, tools, and statistics.
- [Campaign sending](https://github.com/wascripts/wanewsletter/blob/develop/admin/envoi.php): PHP controller · Runs campaign delivery and send-progress workflow. · `admin/envoi.php`
- [Admin bootstrap](https://github.com/wascripts/wanewsletter/blob/develop/admin/start.inc.php): PHP include · `admin/start.inc.php`
- [Admin UI templates](https://github.com/wascripts/wanewsletter/tree/develop/templates/admin): templates · `templates/admin`

### Application core

- [Shared runtime](https://github.com/wascripts/wanewsletter/blob/develop/includes/common.inc.php): PHP bootstrap · Centralizes request initialization and common behavior. · `includes/common.inc.php`
- **Subscriber domain**: PHP domain layer · Implements subscription, authentication, and session behavior.
- [Template renderer](https://github.com/wascripts/wanewsletter/blob/develop/includes/Template.php): PHP rendering layer · Renders application and message layouts. · `includes/Template.php`
- **Localized email copy**: email templates · Confirmation, welcome, and unsubscribe messages.
- **Mail delivery**: outbound mail boundary · Sends mail and manages attachments.
- **Output adapters**: presentation adapters · Supports HTML, JSON, and command-line output.

### Persistence & operations

- [Installer](https://github.com/wascripts/wanewsletter/blob/develop/install.php): PHP entry point · Initializes the application schema and setup. · `install.php`
- **Database abstraction**: PHP persistence layer · Selects MySQL, PostgreSQL, or SQLite drivers behind a common interface.
- [Database schemas](https://github.com/wascripts/wanewsletter/tree/develop/includes/Dblayer/schemas): schema definitions · `includes/Dblayer/schemas`
- [Application state](https://github.com/wascripts/wanewsletter/tree/develop/data): mutable storage · Holds local configuration, database files, uploads, logs, stats, and temporary files. · `data`
- **Scheduled integrations**: PHP automation · Provides cron and extension-oriented behavior.
- **Host mail transport**: external service
- **Configured database**: external database · MySQL, PostgreSQL, or SQLite backend.
- [POP mailbox client](https://github.com/wascripts/wanewsletter/blob/develop/includes/PopClient.php): mail integration · `includes/PopClient.php`

## Connections

- Installer → Database schemas: installs
- Database schemas → Configured database: defines
- Subscription & profiles → Shared runtime: bootstraps
- Subscription & profiles → Subscriber domain: updates subscribers
- Newsletter archive → Shared runtime: bootstraps
- Newsletter archive → Template renderer: renders with
- Admin controllers → Admin bootstrap: initializes via
- Campaign sending → Admin bootstrap: initializes via
- Admin bootstrap → Shared runtime: shares runtime
- Admin controllers → Admin UI templates: renders
- Campaign sending → Admin UI templates: shows progress
- Admin controllers → Subscriber domain: manages
- Campaign sending → Template renderer: composes
- Template renderer → Localized email copy: uses
- Campaign sending → Mail delivery: dispatches
- Mail delivery → Host mail transport: sends through
- Subscriber domain → Database abstraction: persists through
- Database abstraction → Configured database: connects to
- Shared runtime → Output adapters: selects output
- Campaign sending → Application state: records outcomes
- Scheduled integrations → Shared runtime: runs application logic
- Scheduled integrations → Mail delivery: can trigger delivery
- POP mailbox client → Subscriber domain: mailbox interaction
