Skip to content

Instantly share code, notes, and snippets.

@supertr0n
Last active March 9, 2024 18:22
Show Gist options
  • Save supertr0n/f006a5f61b60160862ec13024e262b80 to your computer and use it in GitHub Desktop.
Save supertr0n/f006a5f61b60160862ec13024e262b80 to your computer and use it in GitHub Desktop.
Example architecture decision record (ADR) entry

0015. Email Sending Architecture

This is a trivial example of an architecture decision record (ADR) entry, using ASCII diagrams (from Monodraw).

Date: 2024-01-01

Status

Accepted

Decision

Use proper segregated architecture for email sending, allowing easy future vendor changes

Details

We will likely need to change email provider soon to choose a more EU-centric privacy focused provider, so building new email functionality should be layered correctly to allow this swap and to allow for easy testing too.

This is the rough architecture:

 
BACKGROUND TASK FOR BATCH SENDING CONFIRMATION EMAILS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━


║ BACKGROUND TASK                 ║ ORCHESTRATION SERVICE             ║ COMMAND HANDLER
┌─────────────────────────────┐   ┌───────────────────────────────┐   ┏━━━━━━━━━━━━━━━━━━━━━━━━━┓
│                             │   │                               │   ┃          Send           ┃
│     MessageSendingTask      │──▶│ CustomerMessageSendingService │──▶┃    ConfirmationEmail    ┃
│                             │   │                               │   ┃     CommandHandler      ┃
└─────────────────────────────┘   └───────────────────────────────┘   ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛
                                                  │                                │
TRIGGERS:                                         ▼                                ▼
- Every 5 mins                    ┌───────────────────────────────┐         ┏━━┳━━━━━━━━━┓
- NewMessageQueuedEvent           │  CustomerMessageQueueService  │         ┃DB┃ Orders  ┃
                                  └───────────────────────────────┘         ┗━━┻━━━━━━━━━┛
                                                  │
                                                  ▼
                                         ┏━━┳━━━━━━━━━━━━━━┓
                                         ┃DB┃ Orders       ┃
                                         ┗━━┻━━━━━━━━━━━━━━┛
 
 
 
COMMAND HANDLER FOR SENDING CONFIRMATION EMAILS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

                                                          │
       BUSINESS LOGIC                BUSINESS LOGIC                    INFRASTRUCTURE                    Either in-house or
   Load order, mark as        Convert model to fields etc.│      Email sending, retry logic                official Nuget
  sending, mark as failed
            etc.              ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ │ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐
                                     IEmailService                  IEmailDeliveryService
                              └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ │ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━┓   ┌─────────────────────────┐   ┌───────────────────────────────────┐   ┌──────────────────────────┐
┃          Send           ┃   │                         │ │ │                                   │   │                          │
┃    ConfirmationEmail    ┃──▶│  TemplatedEmailService  │──▶│ VendorSpecificEmailDeliveryService│──▶│      VendorApiClient     │
┃     CommandHandler      ┃   │                         │ │ │                                   │   │                          │
┗━━━━━━━━━━━━━━━━━━━━━━━━━┛   └─────────────────────────┘   └───────────────────────────────────┘   └──────────────────────────┘
             │                                            │ ┌───────────────────────────────────┐                 │
             ▼                                              │                                   │                 ▼
      ┏━━┳━━━━━━━━━┓                                      │ │     NoopEmailDeliveryService      │      ╔════════════════════╗
      ┃DB┃ Orders  ┃                                        │                                   │      ║  External Vendor   ║
      ┗━━┻━━━━━━━━━┛                                      │ └───────────────────────────────────┘      ║        API         ║
                                                                                                       ╚════════════════════╝
                                                          │           VENDOR SPECIFIC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment