Skip to content

Send an email notification to the system administrator upon consuming an alert message from a Kafka topic.

License

Notifications You must be signed in to change notification settings

fpaupier/notifyMask

Repository files navigation

Go Report Card

Notification service

Subscribe to a Kafka topic of notifications to be sent (alert for someone not wearing their mask), fetch the alert from a Cloud SQL instance, send an email to a system administrator and record that the alert has been sent in the database.

Setup your email provider

Sending email programmatically is hard.

If you don't want to land in the spam folder of your recipient, I advise you use an email service provider. Services like mailgun or mailjet can help with that.

For this project, I used mailjet and its email API, free tier. (the free offer limit is 6,000 emails per month and 200 emails per day which is more than enough for this project)

Running on local

  1. Install locally
go install .
  1. Run the service:
$GOPATH/bin/notifyMask

Deploying to Google Cloud Platform (GCP)

I assume you already have an existing GCP project.

  1. First build and publish the image to Google cloud (make sure the storage bucket write access on your project)
gcloud builds submit --tag gcr.io/YOUR_PROJECT_NAME/notify-mask
  1. Then, create a Cloud Compute Engine instance using the image you just published. Create a permanent IP address instead of using an ephemeral one.

  2. Copy the instance external IP address and go to your Cloud SQL instance dashboard.

  3. Go to the connection tab, click + Add network and paste your instance IP address.

Related Projects

This repository hosts the code for the last part of the project; notifying an admin that someone is not wearing their mask. The previous projects are:

  • pi-mask-detection focuses on the detection of whether someone is wearing their mask or not, as seen per the Raspberry Pi.

  • alertDispatcher is a Go module designed to run at the edge, especially a Raspberry Pi 4 B with 4Go of RAM. The alertDispatcher polls the local SQLite event store and publishes them to a Kafka topic.

  • alertIngress is a Go module designed to run on a server, consuming from a Kafka topic where edge devices pushes their events. For each event consumed, the alert Ingress archives it in PostgresSQL and publishes a message to be consumed by the notification service.