Giter Site home page Giter Site logo

andrenbrandao / summail Goto Github PK

View Code? Open in Web Editor NEW
28.0 3.0 0.0 1.53 MB

Consolidate your email subscriptions into a single weekly summary email. Built with Serverless, OAuth2 and Gmail API.

License: MIT License

JavaScript 4.35% TypeScript 95.65%
serverless typescript codementor aws

summail's Introduction

Summail logo

A Weekly Newsletter Email service to unclutter your inbox

What is Summail

This project consolidates your email subscriptions into a single weekly summary email.

It was created as a challenge at codementor.io to practice serverless development with AWS.

Users need to register to newsletters with a suffix +newsletter in order to have only these e-mails selected. For example: [email protected].

Architecture

The architecture decisions were documented in Notion and Miro. I like to draw the possibilities and take notes of the possible consequences of each approach.

Authentication

First, we need to authorize the user through Google and retrieve the access token to make future requests to the Gmail API. Because the access token can expire, it is better to store the refresh token.

OAuth2 Example

MongoDB was used as our database for the only reason I was working with it at my current job. A relational database could also be used in its place.

Storage of Emails

To get the user's emails and store it in a database, the simpler approach would be to keep polling the Gmail API for all the messages. However, this wouldn't scale, so I decided to connect to the Gmail Push Notification using Google Cloud PubSub.

A SQS Queue and also a Dead-Letter were also set up to handle notifications for multiple users and to increase reliability in case of failures.

Gmail PubSub

Keeping the Subscription Alive

We have to keep notifying the Gmail API that we still want to receive events for our users. So, a cron job was set up to run everyday with CloudWatch Events.

Keep PubSub Alive

Sending the Newsletters

Every user might receive dozens of newsletters during a week, so we want to grab these emails per user and send them to a queue. These aggregated messages will then be processed by another lambda that will also send them using AWS SES.

Processing Emails

License

MIT © André Brandão

summail's People

Contributors

andrenbrandao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.