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.
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)
- Install locally
go install .
- Run the service:
$GOPATH/bin/notifyMask
I assume you already have an existing GCP project.
- 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
-
Then, create a Cloud Compute Engine instance using the image you just published. Create a permanent IP address instead of using an ephemeral one.
-
Copy the instance external IP address and go to your Cloud SQL instance dashboard.
-
Go to the
connection
tab, click+ Add network
and paste your instance IP address.
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.