DEV Community

tq-bit
tq-bit

Posted on

MongoDB 2022 Hackathon submission - Introducing Ghost Notifier

What I built

A realtime integration for the Ghost blogging platform. This includes:

  • A backend HTTP service
  • An example frontend library for Ghost's 'Casper' - theme

As a bonus: My LaMetric clock was in the mail today πŸŽ†. It can receive notifications about new and updated posts, so I integrated a dedicated code snippet in this submission. Check out the readme on Github on how to use it together with Ghost notifier. I'm also listing a brief showcase video under 'Additional Resources/Info'.

Category Submission:

About real-time

App Link

This service aims to be self-hosted. I'm providing a docker setup with Ghost + a step-by-step guide on registering the necessary webhooks as part of the readme on Github.

Screenshots

Please see the Github readme for screenshots

Description

Ghost-Notifier does two things.

1. It receives a published article as input and stores a notification

  • Ghost-Notifier is a microservice built on top of MongoDB and Express.js.
  • It receives Ghost articles over HTTP and stores a subset of their data in MongoDB.

2. It produces output when a DB change is detected and sends it to connected clients

  • Third-party clients can subscribe to Ghost-Notifier via. HTTP(S)
  • When a publisher creates or updates a post, MongoDB triggers a notification using its built-in Change Streams
  • This notification is sent via Server-Sent-Event to connected clients

Link to Source Code

GitHub logo tq-bit / ghost-notifier

A realtime application that provides notification messages for your Ghost Blog. Winner of the MongoDB Atlas Hackathon 2022


Ghost-Notifier

Winner of the MongoDB Hackathon 2022 on dev.to

Realtime notifications for your Ghost Blog

License GitHub last commit

About the Project

This project is a selfhosted MVP for realtime notifications in Ghost CMS. It's my submission to the 2022 MongoDB hackathon on dev.to.

Ghost Notifier is built on top of MongoDB ChangeStreams and Ghost webhooks to deliver notifications whenever a new article is published or an existing article is updated.

ghost-notifier landing page

Built With

Get started

I've added to alternate ways for your to give this application a ride:

  • Simulate Ghost Webhooks with a HTTP client and check the app logs on localhost:3000/ (the 'Simulation approach')
  • Start a Ghost Instance locally, register webhooks and the frontend library (the 'Ghost approach')

In the following, I'll explain both in greater detail.

Quickstart

Start by cloning this repos into a folder of your choice and…

Permissive License

MIT

Background

I'm using Ghost CMS to write about web development. The platform's been a valuable asset in my toolkit for the last two years and continues to be so.

Compared to other blogging platforms, Ghost aims to be lightweight in design. It includes no classic plugins, but uses webhooks to trigger third party extensions to tweet, share or trigger workflows.

My blog does not receive enough traffic to add a lot of them. But if I ever attempted to scale, I'd look for more ways to keep users engaged. For instance, with notifications about new content.

Here's where MongoDB ChangeStreams seemed a perfect match for Ghost's webhooks.

How I built it

Ghost-Notifier is a Typescript backend built on Express.js. It uses MongoDB Atlas to store a subset of post data on two events:

  1. New post published
  2. Published post updated

These posts are stored and trigger MongoDB's ChangeStream functionality.

Using MongoDB instead of in-mem DBs opens the gate to even more features:

  • Use MongoDB's toolkit, including sharding, transactions and the query API to make scaling a child's play.
  • It's easier to apply advanced analytics if you run Ghost-Notifier as SAAS <- this would be how I host this app as a product
  • You can keep building on MongoDB's native driver to quickly implement further features, such as a URL-shortener or a search index

I also picked up Server-Sent-Events (SSE) along the way. In this case, they deliver notifications to connected clients whenever a DB entry is updated. I even wrote an article about implementing this technique because I found it to be a valuable alternative to Websockets

MongoDB and SSE play incredibly well together and were swiftly implemented. I'll definitely use this combination more often from now on for stateful realtime-applications.

Additional Resources/Info

Top comments (2)

Collapse
 
menard_codes profile image
Menard Maranan

This is a cool project!

Collapse
 
timotej_avsec profile image
Timotej Avsec

Looks great!