# Architecture

> How Sypnia Mail is built: its parts, where Rust runs, and how they connect.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://mail.docs.sypnia.com/architecture/

For agents: Mail architecture: one Rust binary (axum, lettre, mail-parser; Handlebars-compatible renderer) with API, SMTP relay, renderer, queue, sender, event receiver, webhook dispatcher, inbound parser, MCP; Postgres for domains/templates/e-mails/events/suppressions; S3-compatible storage for attachments and raw messages; transport SES or SMTP; @sypnia/mail TS; guardrail rules open, review tools and console private.

**Figure**: Sypnia Mail: the API and the SMTP relay, the engine's queue and sender, the transport, and where state lives.

1. Your app calls the API, or an SMTP client talks to the relay.
2. The engine checks, renders and queues the e-mail in Postgres.
3. The sender hands it to Amazon SES (or SMTP) at the allowed pace.
4. Delivery events and inbound mail come back and are recorded and sent to your webhooks.

Apps call the Mail API; older apps use the SMTP relay. The engine is one Rust binary with the API, the SMTP relay, the template renderer, the queue, the sender, the event receiver, the webhook dispatcher, the inbound parser and the MCP server. It keeps domains, templates, e-mails, events and suppressions in Postgres and attachments and raw messages in S3-compatible storage. The transport is Amazon SES or any SMTP server.

| Part                                                                        | Language                                                                                 | Open source                                    |
| --------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------- |
| Mail engine: API, SMTP relay, renderer, queue, sender, events, inbound, MCP | Rust (axum, lettre, mail-parser); templates rendered with a Handlebars-compatible engine | yes                                            |
| `@sypnia/mail` and its React components                                     | TypeScript                                                                               | yes                                            |
| Deliverability guardrails and abuse review in Sypnia Cloud                  | Rust and TypeScript                                                                      | the guardrail rules, yes; the review tools, no |
| Console                                                                     | TypeScript (React)                                                                       | no                                             |

- [Request paths](/architecture/request-paths/): A send, a bounce and an inbound message, step by step.
- [Data model](/architecture/data-model/): The sypnia_mail schema: domains, templates, e-mails, events, suppressions, webhooks and inbound.
- [Reference implementation on AWS](/architecture/reference-implementation-aws/): Every AWS service Mail uses in Sypnia Cloud, and how.
- [Failures and scaling](/architecture/failures-and-scaling/): What happens when SES, the database or your webhook fails, and how Mail grows.
- [Codebase](/architecture/codebase/): How the open-source repository is organized.
