Using S3 versioning to sort PretzelBox emails

Sai Ramachandran
4 min readFeb 2, 2022

(tl;dr; — PretzelBox is a serverless inbox for AWS SES; emails in inboxes need to be LIFO sorted; sorting is done by leveraging S3 versioning)

Fundamentally, PretzelBox is an inbox for your domain.

The semantics of being an inbox dictate that emails be shown in descending order by date i.e., emails in inboxes are LIFO or equally, your inbox is a stack.

(The stack like behaviour of inboxes should give you a hint as to why we use the word STACK in our DSL::response)

Sorting of emails can be solved in two ways — the easy way and the hard.

The Easy Way

The easy way would be to put email metadata into a relational database, then use SQL’s sorting mechanisms to retrieve the data in the correct sort order.

Easy as ABC, right?

Easy as ABC, right?

Well,…wrong.

PretzelBox is fully serveless and is not backed by a database. At some point in the product journey, it was decided that we’d avoid using a database for as long as we could, probably for cost reasons, and now, I honestly don’t think a DB is necessary for where we are going.

The Hard Way

--

--

Sai Ramachandran

Building https://squadgpt.ai - GPT for teams. Manage AI costs and retain visibility with SquadGPT. All views personal. Email = sai@squadgpt.ai