# team254/cheesy-mail architecture

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

- Interactive diagram: https://gitdiagram.com/team254/cheesy-mail
- Repository: https://github.com/team254/cheesy-mail

## Overview

cheesy-mail receives SMTP mail, validates and parses it, checks sender/list permissions, deduplicates messages, distributes them through AWS SES, and supports blog, Slack, attachment, and reply-related behavior in the message model. The sampled code shows the SMTP-to-processing handoff, membership API calls, attachment handling, SES delivery, and blog posting; README and excerpts do not establish every integration’s exact wiring, so uncertain links are omitted or marked dashed.

Main entry points: [`mail_message.go`](https://github.com/team254/cheesy-mail/blob/master/mail_message.go) (Message workflow), [`main.go`](https://github.com/team254/cheesy-mail/blob/master/main.go) (Service coordinator), [`smtp_server.go`](https://github.com/team254/cheesy-mail/blob/master/smtp_server.go) (SMTP listener), [`smtp_client_session.go`](https://github.com/team254/cheesy-mail/blob/master/smtp_client_session.go) (SMTP session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and ingress"]
  node_main["Service coordinator<br/>[main.go]"]
  node_smtp["SMTP listener<br/>[smtp_server.go]"]
  node_session["SMTP session"]
end

subgraph group_processing["Message processing"]
  node_message["Message workflow<br/>[mail_message.go]"]
  node_cache[("Deduplication cache<br/>[message_cache.go]")]
  node_attachment[("Attachment storage<br/>[mail_message.go]")]
end

subgraph group_delivery["Distribution and integrations"]
  node_ses["AWS SES"]
  node_blog["Blog service"]
  node_slack["Slack service"]
  node_reply["Reply handling<br/>[mail_message.go]"]
end

subgraph group_support["Identity and configuration"]
  node_membership["Membership API<br/>[user_api.go]"]
  node_config["Configuration and decrypt<br/>[config.go]"]
end

node_sender(("Mail sender"))
node_nginx["NGINX proxy"]

node_main -->|"loads settings"| node_config
node_main -->|"starts listener"| node_smtp
node_sender -->|"opens SMTP"| node_smtp
node_smtp -->|"creates sessions"| node_session
node_session -->|"parses mail"| node_message
node_session -->|"queues message"| node_main
node_main -->|"checks duplicate"| node_cache
node_main -->|"processes message"| node_message
node_message -->|"checks permissions"| node_membership
node_message -->|"saves files"| node_attachment
node_message -->|"sends email"| node_ses
node_message -->|"posts message"| node_blog
node_message -.->|"posts notification"| node_slack
node_message -->|"handles replies"| node_reply
node_smtp -.->|"serves auth"| node_nginx
node_membership -->|"reads settings"| node_config

click node_main "https://github.com/team254/cheesy-mail/blob/master/main.go"
click node_smtp "https://github.com/team254/cheesy-mail/blob/master/smtp_server.go"
click node_session "https://github.com/team254/cheesy-mail/blob/master/smtp_client_session.go"
click node_message "https://github.com/team254/cheesy-mail/blob/master/mail_message.go"
click node_cache "https://github.com/team254/cheesy-mail/blob/master/message_cache.go"
click node_membership "https://github.com/team254/cheesy-mail/blob/master/user_api.go"
click node_config "https://github.com/team254/cheesy-mail/blob/master/config.go"
click node_attachment "https://github.com/team254/cheesy-mail/blob/master/mail_message.go"
click node_reply "https://github.com/team254/cheesy-mail/blob/master/mail_message.go"

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_main,node_smtp,node_session toneBlue
class node_message,node_cache,node_attachment toneAmber
class node_ses,node_blog,node_slack,node_reply toneMint
class node_membership,node_config toneRose
class node_sender,node_nginx toneIndigo
```

## Components

### Runtime and ingress

- [Service coordinator](https://github.com/team254/cheesy-mail/blob/master/main.go): `main.go`
- [SMTP listener](https://github.com/team254/cheesy-mail/blob/master/smtp_server.go): `smtp_server.go`
- [SMTP session](https://github.com/team254/cheesy-mail/blob/master/smtp_client_session.go): `smtp_client_session.go`

### Message processing

- [Message workflow](https://github.com/team254/cheesy-mail/blob/master/mail_message.go): `mail_message.go`
- [Deduplication cache](https://github.com/team254/cheesy-mail/blob/master/message_cache.go): `message_cache.go`
- [Attachment storage](https://github.com/team254/cheesy-mail/blob/master/mail_message.go): `mail_message.go`

### Distribution and integrations

- **AWS SES**
- **Blog service**
- **Slack service**
- [Reply handling](https://github.com/team254/cheesy-mail/blob/master/mail_message.go): `mail_message.go`

### Identity and configuration

- [Membership API](https://github.com/team254/cheesy-mail/blob/master/user_api.go): `user_api.go`
- [Configuration and decrypt](https://github.com/team254/cheesy-mail/blob/master/config.go): `config.go`

### Other components

- **Mail sender**
- **NGINX proxy**

## Connections

- Service coordinator → Configuration and decrypt: loads settings (evidence: `main.go`)
- Service coordinator → SMTP listener: starts listener (evidence: `main.go`)
- Mail sender → SMTP listener: opens SMTP (evidence: `smtp_server.go`)
- SMTP listener → SMTP session: creates sessions (evidence: `smtp_server.go`)
- SMTP session → Message workflow: parses mail (evidence: `smtp_client_session.go`)
- SMTP session → Service coordinator: queues message (evidence: `smtp_client_session.go`)
- Service coordinator → Deduplication cache: checks duplicate (evidence: `main.go`)
- Service coordinator → Message workflow: processes message (evidence: `main.go`)
- Message workflow → Membership API: checks permissions (evidence: `mail_message.go`)
- Message workflow → Attachment storage: saves files (evidence: `mail_message.go`)
- Message workflow → AWS SES: sends email (evidence: `mail_message.go`)
- Message workflow → Blog service: posts message (evidence: `mail_message.go`)
- Message workflow → Slack service: posts notification
- Message workflow → Reply handling: handles replies (evidence: `mail_message.go`)
- SMTP listener → NGINX proxy: serves auth (evidence: `smtp_server.go`)
- Membership API → Configuration and decrypt: reads settings (evidence: `user_api.go`)
