Skip to content

Ingress alerts for the Pi Mask Detection project. Read records from a Kafka topic and persist them to a PostgreSQL database.

License

Notifications You must be signed in to change notification settings

fpaupier/alertIngress

Repository files navigation

Go Report Card

Alert Ingress

Ingress alerts for the Pi Mask Detection project. Read records from a Kafka topic and persist them to a PostgreSQL database.

Prerequisites

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:

  1. 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.
  2. 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 into credentials.go to ensure it's not version controlled.

Running on local

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

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/alert-ingress
  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 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.