nicholaschiang / hammock

Move your newsletters outside of your inbox. Focus on and learn from the content you love in a distraction-free reading space.
https://readhammock.com
GNU Affero General Public License v3.0
11 stars 1 forks source link
newsfeed newsletter-management newsletters nextjs react typescript

Hammock

Hammock moves your favorite newsletters outside of your understandably cluttered inbox, letting you focus on and learn from the content you love in a distraction-free reading space.

Terminology and Data Model

User

A user is a person; someone who uses the app.

Subscription

A subscription is a recurring newsletter from a specific email address.

Message

A message is an email from a recurring newsletter (extends Subscription).

Implementation

Included below are some high-level descriptions of how Hammock is implemented. The purpose of this writing is not so much to act as documentation but rather to encourage better README-driven development.

Gmail Sync

Our Gmail sync is composed of various methods to ensure that our Supabase-managed PostgreSQL database is always up-to-date with our users' Gmail inboxes:

  1. When the user first signs up, they call our /api/sync endpoint which starts a full sync using Gmail's messages.list API endpoint. This endpoint syncs 10 messages and then redirects (using the nextPageToken) to /api/sync recursively to sync the next 10 messages and so on and so forth. We save the current sync cursor (the nextPageToken returned by the last messages.list call) in our database so subsequent calls to /api/sync start right where we left off.
  2. When the user signs up, we also setup a Google Pub/Sub subscription using Gmail's users.watch API endpoint. This push subscription then calls our /api/push endpoint which uses Gmail's history.list API to sync newly received messages as they come in.

Development

Hammock aims to use the most cutting-edge, performant, and production-ready solutions available. Included below is our current selection and the reasoning behind it, but we're always open to improvements!

Languages

Frameworks

Tooling

Database

Commit Message Format

I have very precise rules over how Git commit messages in this repository must be formatted. This format leads to easier to read commit history.

Please refer to the following documentation for more info:

Commit Message Header

Commit messages that do not adhere to the following commit style will not be merged into develop:

<type>(<scope>): <short summary>
  │       │             │
  │       │             └─⫸ Summary in present tense. Not capitalized. No period at the end.
  │       │
  │       └─⫸ Commit Scope: The page, API route, or component modified.
  │
  └─⫸ Commit Type: ci|docs|feat|fix|perf|refactor|test|deps|chore

The <type> and <summary> fields are mandatory, the (<scope>) field is optional.

Type

Must be one of the following:

Git Flow

This repository follows the standard git-flow workflow with a couple of important exceptions:

Git Flow Diagram