@startuml
title Email Admin JSON Payload Validation (Before)

skinparam backgroundColor #FFFFFF
skinparam defaultFontColor #000000
skinparam ArrowColor #000000
skinparam SequenceLifeLineBorderColor #000000
skinparam SequenceLifeLineBackgroundColor #F4F4F4
skinparam ParticipantBorderColor #000000
skinparam ParticipantBackgroundColor #FFE6CC
skinparam NoteBackgroundColor #FFF2CC
skinparam NoteBorderColor #000000

actor "Admin Client" as Client
participant "AdminPlugin\n(/email*, /email-failure*, /email-template*)" as Plugin
participant "Admin Handlers\ncreate/update cores" as Handlers
participant "DatabaseAdapter" as DB
database "tenant.sent_emails\ntenant.email_send_failures\ntenant.email_templates" as Tables

Client -> Plugin: POST create/update request\nwith metadata or variables
Plugin -> Handlers: decoded JSON body
Handlers -> DB: pass metadata/variables through
DB -> Tables: INSERT / UPDATE
Tables --> DB: OK
DB --> Handlers: OK
Handlers --> Plugin: success
Plugin --> Client: 200

note right of Handlers
metadata accepts any JSON shape here.\nvariables can include duplicates/blanks.\nNo explicit JSON size/depth bound.
end note

@enduml
