System Architecture
ServerlessInbox is built entirely on AWS serverless services. There are no persistent servers—all compute runs as on-demand Lambda functions, with DynamoDB as the primary data store and S3 for binary storage.
A deployment has two distinct planes, and it is worth keeping them apart while reading this page:
- The request path — everything involved in accepting, storing, searching and delivering mail, and in serving the admin and client APIs. This is what runs when a user or a message arrives.
- The deployment and management path — the machinery that provisions the deployment, keeps it current, and looks after it over its lifetime. None of it sits between a message and a mailbox.
Service Map
Section titled “Service Map”graph LR Clients["Email clients<br/>Webmail UI"] -->|JMAP| JMAP["jmap-api λ"] AdminUI["Admin UI"] -->|REST /admin| Admin["admin-api λ"] Clients -->|REST /user| User["user-api λ"] SES_IN["AWS SES"] -->|receipt rule| Ingest["email-processor λ"]
JMAP & Admin & User & Ingest --> DDB[("DynamoDB")] JMAP & Admin & Ingest --> S3[("S3")]Figure 1: The three entry points into the system: email clients via JMAP, admin operations via REST, and inbound email via SES.
Component Overview
Section titled “Component Overview”The table below is an orientation map of the request path, not an inventory. Every deployed function, with its triggers, environment and resource access, is listed in the Lambda Functions reference.
| Component | Type | Purpose |
|---|---|---|
jmap-api | API Lambda | JMAP protocol handler for email clients |
admin-api | API Lambda | Tenant and user administration, served under /admin |
user-api | API Lambda | Per-user settings that follow the account, served under /user |
email-processor | Event Lambda | Processes incoming email from SES |
email-sender | Queue Lambda | Sends outgoing email via SES |
sqs-ses-event-processor | Event Lambda | Handles SES delivery/bounce/complaint feedback |
websocket-connect/disconnect/message | WebSocket Lambdas | Manage client WebSocket connections |
state-change-fanout | Internal Lambda | Pushes real-time notifications to connected WebSocket clients and delivers them to webhook push subscriptions |
expiry-sweeper | Scheduled Lambda | Every 15 minutes: fails overdue import jobs, removes expired remote connections and expires push subscriptions; once a day: expires personal access tokens |
audit-writer | Queue Lambda | Persists audit events to DynamoDB |
tantivy-indexer | Scheduled Lambda | Incrementally rebuilds per-account full-text search indexes in S3 every 6 hours |
authorizer | Authorizer Lambda | JWT validation for API Gateway |
Data stores
Section titled “Data stores”| Store | Contents | Lifecycle |
|---|---|---|
| MailboxDataStack (Config, Item, Changelog, Audit Log, Mail Feedback, Personal Access Token tables + S3) | Users, accounts, domains, IDPs, emails, threads, mailboxes, delivery feedback, search indexes | Retained across mailbox stack redeploys |
| DynamoDB JWK cache table | Cached OIDC public keys, maintained by the auth key store | Ephemeral—rebuilt on each deploy |
| DynamoDB WebSocket connections table | Active client push connections | Ephemeral—transient session state |
Deployment and Management Path
Section titled “Deployment and Management Path”Everything above runs while mail is moving. The components below do not. They provision the deployment, keep it current, and look after it — and a message never passes through any of them.
graph LR CFN["CloudFormation<br/>create / update"] --> Deployers["Custom-resource deployers"] CFN --> Diag["Stack-failure diagnostics"] CFN -->|on stack delete| Sweep["Sweeper"]
Releases["Published releases"] --> Update["Self-update"] Update --> Targets["Lambda code<br/>Edge functions<br/>UI assets"]
Timer["Schedules"] --> Keys["Auth key store"] Timer --> Lic["Licence refresher"] Timer --> Support["Support access"] Customer["Customer grant"] --> SupportFigure 2: The deployment and management plane. Nothing here sits in the path of a message.
Custom-resource deployers. Some of the deployment cannot be expressed as plain CloudFormation resources, so the stack drives it through custom resources at deploy time: configuring the identity provider in use, preparing the data layer, and provisioning the edge stack. These run during a create or update and then stop. They are provisioning machinery, not services — nothing calls them while the deployment is serving traffic.
Self-update. The deployment resolves the currently published artifact versions and updates its own Lambda code, edge functions and UI assets, smoke-testing each update and rolling a failed one back. It is on by default and bounded by a template parameter. See Self-Update.
Support access. A separate access path, granted explicitly by the customer, read-only, scoped to the deployment’s own resources, and time-boxed. It has its own roles and tiers, entirely distinct from the identity provider that authenticates normal users, and expiry is applied by a scheduled job inside the account. See Support.
Licence refresher. A component that periodically obtains a licence token and makes it available to the deployment. What that token gates is extended features and limits — never mail flow, which keeps working whether or not a licence can be obtained. See License Model.
Stack-failure diagnostics. When a stack operation fails, this component captures what happened so the failure can be diagnosed without the operator having to reconstruct it from CloudFormation events after the fact. It is optional: an operator who does not want failure detail leaving the account can switch it off at deploy time, and no diagnostic resources are created.
Auth key store. Verifying a token requires the issuer’s current public keys. Rather than having every request fetch them, a dedicated component maintains them in the deployment and refreshes them on a schedule, so the request path reads keys locally and does not depend on the identity provider being reachable on each call.
Sweeper. Deleting a stack leaves behind resources CloudFormation cannot remove itself — replicated edge functions that only become deletable after a propagation delay, certificates still in use at the moment of deletion, and similar cases. The sweeper is the cleanup machinery that removes them, retrying the ones that are not yet removable, so a deleted deployment does not leave residue in the account.
Key Design Choices
Section titled “Key Design Choices”No persistent servers. All compute is Lambda. There are no EC2 instances, containers, or processes to keep alive.
Real-time push via direct Lambda invocation. After writing to DynamoDB, the processing Lambda invokes state-change-fanout directly. state-change-fanout looks up active connections and pushes via API Gateway Management API, then posts a short change hint to the account’s verified webhook push subscriptions. There is no message bus in this path.
Full-text search is a secondary feature. Simple mailbox queries (the vast majority) read DynamoDB directly. Tantivy is only used for complex text-search queries and runs as an in-process CGO library inside jmap-api, reading each account’s index straight from S3 and merging it with recent changelog entries so newly-arrived mail is still findable between index rebuilds. See Search Architecture for details.
Separate data stack prevents lifecycle conflicts. The six retained DynamoDB tables and S3 bucket live in a separate CloudFormation stack that is never deleted when the mailbox stack is deleted. This enables safe deploy → delete → redeploy cycles without data loss or table recreation.
Operational machinery stays off the mail path. Self-update, support access, licensing, stack-failure diagnostics and the sweeper are all deliberately outside the request path. Each of them can be unavailable, disabled, or mid-operation without mail stopping — the failure modes of managing a deployment are kept separate from the failure modes of delivering a message.
Multi-tenant prepared, not multi-tenant deployed. Tenant isolation is enforced in the data layer, but running several organisations on one deployment is not available yet — today, one deployment serves one organisation.
Go Deeper
Section titled “Go Deeper”- Email Processing Pipeline — Full inbound and outbound email flows
- Search Architecture — How Tantivy integrates with JMAP
- Trust & Code Integrity — Signed Go binaries, open TypeScript Lambdas, and what licensing does and does not gate
- Self-Update — How a deployment updates itself, and what keeps that safe
- Support — How support access is granted, scoped, and revoked
- License Model — Tiers, what a licence gates, and the downgrade guarantee
- Lambda Functions — Reference listing of every deployed function