# oza75/laravel-ses-complaints architecture

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

- Interactive diagram: https://gitdiagram.com/oza75/laravel-ses-complaints
- Repository: https://github.com/oza75/laravel-ses-complaints

## Overview

##### Main Components

a) External Services Layer:
- AWS SES (for email sending)
- AWS SNS (for notifications)

b) Package Core Components:
- SNS Controller (entry point for AWS notifications)
- Middleware System
- Event System
- Models Layer
- Database Tables

##### Component Relationships

**[AWS SES] ←→ [AWS SNS]**
- ↓
**[SNS Controller]**
- ↓
**[Middleware Pipeline]**
- ↓
**[Event System] → [Listeners]**
- ↓
**[Models] ←→ [Database]**

##### Specific Implementation Details

a) Request Flow:
- SNS notification endpoints (/aws/sns/ses/bounces and /aws/sns/ses/complaints)
- Subscription confirmation flow
- Notification processing pipeline

b) Email Sending Flow:
- Pre-send check pipeline
- Middleware validation process
- Bounce/Complaint verification

##### Key Elements to Highlight

- The CheckPipeline utility
- BounceCheckMiddleware and ComplaintCheckMiddleware
- Event system (BounceNotificationCreated, ComplaintNotificationCreated)
- Database tables (ses_notifications and sns_subscriptions)

##### Implementation Notes

- Use standardized UML notation where appropriate
- Keep the main flow clear and centered
- Related components together
- Clear separation between AWS services and package internals

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph AWS["AWS Services"]
        direction TB
        SES[("AWS SES")]:::aws
        SNS[("AWS SNS")]:::aws
        SES <--> SNS
    end

    subgraph Entry["Entry Points"]
        direction TB
        SNSC["SNS Controller"]:::controller
        BR["Bounce Request"]:::request
        CR["ComplaintRequest"]:::request
        SR["Register Subscription Request"]:::request
    end

    subgraph Pipeline["Middleware & Pipeline"]
        direction TB
        BCM["Bounce Check Middleware"]:::middleware
        CCM["Complaint Check Middleware"]:::middleware
        CP["Check Pipeline"]:::utility
    end

    subgraph Events["Event System"]
        direction TB
        BNC["Bounce Notification Created"]:::event
        CNC["Complaint Notification Created"]:::event
        SSR["SNS Subscription Request Confirmed"]:::event
        CIM["Check Is Message Should Be Send"]:::listener
    end

    subgraph Data["Data Layer"]
        direction TB
        NM["Notification Model"]:::model
        SM["Subscription Model"]:::model
        DB[(Database)]:::database
    end

    subgraph Config["Configuration"]
        direction TB
        CONF["Package Config"]:::config
        SP["Service Provider"]:::provider
        RT["Routes"]:::routes
    end

    %% Relationships
    SNS --> SNSC
    SNSC --> BR & CR & SR
    BR & CR --> Pipeline
    Pipeline --> BCM & CCM
    BCM & CCM --> CP
    CP --> Events
    BNC & CNC & SSR --> CIM
    Events --> NM & SM
    NM & SM <--> DB

    %% Click Events
    click SNSC "https://github.com/oza75/laravel-ses-complaints/blob/master/src/Controllers/SNSController.php"
    click BCM "https://github.com/oza75/laravel-ses-complaints/blob/master/src/Middlewares/BounceCheckMiddleware.php"
    click CCM "https://github.com/oza75/laravel-ses-complaints/blob/master/src/Middlewares/ComplaintCheckMiddleware.php"
    click BNC "https://github.com/oza75/laravel-ses-complaints/blob/master/src/Events/BounceNotificationCreated.php"
    click CNC "https://github.com/oza75/laravel-ses-complaints/blob/master/src/Events/ComplaintNotificationCreated.php"
    click SSR "https://github.com/oza75/laravel-ses-complaints/blob/master/src/Events/SnsSubscriptionRequestConfirmed.php"
    click CIM "https://github.com/oza75/laravel-ses-complaints/blob/master/src/Listeners/CheckIsMessageShouldBeSend.php"
    click NM "https://github.com/oza75/laravel-ses-complaints/blob/master/src/Models/Notification.php"
    click SM "https://github.com/oza75/laravel-ses-complaints/blob/master/src/Models/Subscription.php"
    click BR "https://github.com/oza75/laravel-ses-complaints/blob/master/src/Requests/BounceRequest.php"
    click CR "https://github.com/oza75/laravel-ses-complaints/blob/master/src/Requests/ComplaintRequest.php"
    click SR "https://github.com/oza75/laravel-ses-complaints/blob/master/src/Requests/RegisterSubscriptionRequest.php"
    click CONF "https://github.com/oza75/laravel-ses-complaints/blob/master/config/config.php"
    click SP "https://github.com/oza75/laravel-ses-complaints/blob/master/src/LaravelSesComplaintsServiceProvider.php"
    click CP "https://github.com/oza75/laravel-ses-complaints/blob/master/src/Utilities/CheckPipeline.php"
    click RT "https://github.com/oza75/laravel-ses-complaints/blob/master/src/routes.php"

    %% Styles
    classDef aws fill:#2196F3,stroke:#1565C0,color:white
    classDef controller fill:#4CAF50,stroke:#388E3C,color:white
    classDef middleware fill:#FF9800,stroke:#F57C00,color:white
    classDef event fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef listener fill:#BA68C8,stroke:#9C27B0,color:white
    classDef model fill:#00BCD4,stroke:#0097A7,color:white
    classDef database fill:#FFC107,stroke:#FFA000,color:white
    classDef config fill:#607D8B,stroke:#455A64,color:white
    classDef provider fill:#795548,stroke:#5D4037,color:white
    classDef request fill:#E91E63,stroke:#C2185B,color:white
    classDef utility fill:#8BC34A,stroke:#689F38,color:white
    classDef routes fill:#3F51B5,stroke:#303F9F,color:white
```
