GoNotify is a lightweight, modular notification system written in Go — designed to handle publishing, consuming, and analyzing notifications efficiently using RabbitMQ and PostgreSQL.
You can run it as standalone services (Publisher, Consumer, Analytics), or import it directly into your own Go programs.
- 🧩 Modular architecture (Publisher, Consumer, Analytics)
- 📬 RabbitMQ integration for reliable message queues
- 💾 PostgreSQL integration with SQLC
- 📊 Analytics mode for tracking and insights
- 📨 Email (SMTP) and SMS (Twilio) delivery support
- 🧰 Reusable as a Go library
gonotify/
├── cmd/
│ ├── analytics/ # Analytics CLI
│ ├── consumer/ # Consumer CLI
│ └── publisher/ # Publisher CLI
├── internal/
│ ├── config/ # Database + environment logic
│ └── database/ # SQLC generated queries
├── pkg/
│ └── notify/ # Reusable notification logic
├── sql/
│ ├── queries/
│ └── schema/
└── sqlc.yaml
To install :
git clone github.com/muhammadolammi/gonotify
cd gonotify- Publisher
Runs a pool of publisher workers that push messages to RabbitMQ.
go run ./cmd/publisher💡 You can modify your listener logic by editing the testListenerWorker in cmd/publisher.
- Consumer
Consumes messages and handles email/SMS delivery.
go run ./cmd/consumer- Analytics
Provides analytics and query access to stored notifications.
go run ./cmd/analytics -command <cmd> -get-limit <n> -email <email> -phone <number>Examples:
go run ./cmd/analytics This will get and print all notifications in db.
go run ./cmd/analytics -command=get -get-limit=50 Get all notifications and limit to 50
go run ./cmd/analytics -command=get -get-limit=50 -email=user@example.comFilter the result by email and limit to 50
go run ./cmd/analytics -command=get -get-limit=50 -phone=+123456789Filter the result by phone and limit to 50
go run ./cmd/analytics -command=get -email=user@example.com -phone=+123456789Filter the result by phone and email with no limit
go run ./cmd/analytics -command=get -get-limit=50 -phone=+123456789 -email=user@example.comFilter the result by phone and email and limit to 50
go run ./cmd/analytics -command=clear Delete all notifications in db
All CLI programs load .env variables automatically.
🔧 Environment Variables
Create a .env file in the root directory with the following:
DB_URL=postgres://user:password@localhost:5432/notifydb?sslmode=disable
RABBITMQ_URL=amqp://guest:guest@localhost:5672/
PUBLISHER_POOL=2
CONSUMER_POOL=2
# SMTP (for email)
SMTP_SERVER=smtppro.zoho.com:587 #or your server
SMTP_USERNAME=your_email@example.com
SMTP_PASSWORD=your_password
# Twilio (for SMS)
TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TWILIO_AUTH_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
MESSAGING_SERVICE_SID=xxxxxxxxxxxxxxxxxxxx
TWILLIO_SENDER_NUMBER=+1234567890
You can also import and use GoNotify directly inside your Go applications.
go get github.com/muhammadolammi/gonotify@latestOr with a specific version
go get github.com/muhammadolammi/gonotify@vx.x.xExample: Publisher
package main
import (
"log"
"sync"
"github.com/muhammadolammi/gonotify/pkg/config"
"github.com/muhammadolammi/gonotify/pkg/notify"
)
func publisherListener(id int, config *notify.PublisherConfig, wg *sync.WaitGroup){
// TODO: Replace with your own listener logic.
}
func main() {
publisherConfig, err := config.InitPublisherConfig()
if err != nil {
log.Println("error getting publisher config:", err)
return
}
// Start a listener pool
publisherConfig.StartPublisherListenerPool(
publisherConfig.NumPools,
publisherListener,
)
// Or publish directly
publisherConfig.PublishMessage(notify.Notification{})
}Example: Consumer
consumerConfig, err := config.InitConsumerConfig()
if err != nil {
log.Println("error initializing consumer config:", err)
return
}
consumerConfig.StartConsumerWorkerPool(consumerConfig.NumPools)Example: Analytics
analyticsConfig, err := config.InitAnalyticsConfig()
if err != nil {
log.Println("error initializing analytics config:", err)
return
}
analyticsGetConfig := notify.GetNotificationsConfig{}
analyticsConfig.GetNotifications(analyticsGetConfig)Publisher → Sends notifications into RabbitMQ
Consumer → Listens for messages and sends via email/SMS
Analytics → Reads and aggregates stored notifications
Each service is independent but shares the same database and queue backend.
MIT © Muhammad Olammi
Got ideas, suggestions, or issues? Open an issue or start a discussion on GitHub Issues