Ingress alerts for the Pi Mask Detection project. Read records from a Kafka topic and persist them to a PostgreSQL database.
This project uses a PostgreSQL instance, hosted on GCP with their Cloud SQL services. The tables used to create the DB are
defined in the schema.sql
file.
Note:
- To store image data on a PostgreSQL DB, you can use the
bytea
data type which allows the storage of binary strings. More info on the PostgreSQL doc. - For Kafka; I use a service provider to manage the cluster, Confluent. See their Go api on GitHub.
You'll need to update the
credentials-template.go
file with your credentials and rename it intocredentials.go
to ensure it's not version controlled.
- Install locally
go install .
- Run the service:
$GOPATH/bin/alertIngress
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/alert-ingress
-
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 responsible for the ingress of alert events from potentially several Raspberry Pi or other edge devices. The other moving parts of the 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.
-
notifyMask is a Go module designed to run on a server, sending email notification to a system administrator when an event occurs.