WPD Message Gateway

A unified Go library and HTTP API for sending Email, SMS, Push, and Chat messages.
One interface, multiple providers. Write your messaging code once β switch between Mailgun, Twilio, Firebase, WhatsApp, and more without changing a single line of application code.
Why Use This?
- π One API, Many Providers β Send emails via Mailgun today, switch to SendGrid tomorrow. No code changes.
- π¦ DevBox Included β Built-in web UI to preview emails, SMS, push notifications, and chat messages during development.
- π§ͺ E2E Testing Ready β Memory provider stores messages in RAM. Query them via REST API for automated testing.
- π Go Library + HTTP Server β Use as a Go package (
import) or deploy as a standalone microservice.
How It Works
βββββββββββββββββββ
β Your App β
ββββββββββ¬βββββββββ
β POST /v1/email
βΌ
βββββββββββββββββββ
β Gateway Serviceβ
β (Routes by β
β provider name) β
ββββββββββ¬βββββββββ
β
β providers.defaults.email = ?
β
ββββββ΄βββββββββββββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ
β "memory" β β "mailgun" β
β β β "sendgrid" β
β βββββββββββββββ β β etc. β
β β DevBox UI β β β β
β β (RAM store) β β β Real Provider β
β βββββββββββββββ β β (API calls) β
β + β β β
β βββββββββββββββ β βββββββββββββββββββ
β β Mailpit β β
β β (optional) β β β Only if mailpit.enabled: true
β βββββββββββββββ β
βββββββββββββββββββ
Message Types
| Type |
What it does |
Example providers |
| π§ Email |
Send emails with HTML, attachments |
Mailgun, SendGrid, AWS SES |
| π± SMS |
Send text messages to phones |
Twilio, Vonage |
| π Push |
Send notifications to apps |
Firebase, OneSignal |
| π¬ Chat |
Send messages on chat platforms |
WhatsApp, Telegram, Slack |
Quick Start
Option 1: Use as a Go Package
go get github.com/weprodev/wpd-message-gateway
package main
import (
"context"
"log"
"github.com/weprodev/wpd-message-gateway/pkg/contracts"
"github.com/weprodev/wpd-message-gateway/pkg/gateway"
)
func main() {
gw, _ := gateway.New(gateway.Config{
DefaultEmailProvider: "memory",
})
result, err := gw.SendEmail(context.Background(), &contracts.Email{
To: []string{"user@example.com"},
Subject: "Welcome!",
HTML: "<h1>Hello!</h1>",
})
if err != nil {
log.Fatal(err)
}
log.Printf("Sent! ID: %s", result.ID)
}
Option 2: Run as HTTP Server
# 1. Clone and configure
git clone https://github.com/weprodev/wpd-message-gateway.git
cd wpd-message-gateway
cp configs/local.example.yml configs/local.yml
# 2. Start everything (Gateway + DevBox UI)
make start
Open http://localhost:10104 to see all intercepted messages in the DevBox UI.
β See Usage Guide for more examples.
Configuration
Configure providers in configs/local.yml:
providers:
defaults:
email: mailgun # or: memory, sendgrid, ses
sms: memory # or: twilio, vonage
push: memory # or: firebase, onesignal
chat: memory # or: slack, telegram, whatsapp
email:
mailgun:
api_key: "your-api-key"
domain: "mg.yourdomain.com"
Or use environment variables for secrets:
MESSAGE_MAILGUN_API_KEY=key-xxxxx
MESSAGE_MAILGUN_DOMAIN=mg.example.com
Development Mode (DevBox)
During development, use the memory provider to capture all messages locally:
# configs/local.yml
providers:
defaults:
email: memory
sms: memory
push: memory
chat: memory
β See DevBox Documentation for details.
Mailpit Integration (Optional)
For realistic email preview with HTML rendering:
# 1. Start Mailpit
make mailpit
# 2. Enable in configs/local.yml:
mailpit:
enabled: true
# 3. Start server
make start
# View emails:
# - DevBox UI: http://localhost:10104 (all message types)
# - Mailpit: http://localhost:10103 (email preview)
E2E Testing in CI
Use the gateway to capture and verify all messages your app sends during tests. No mocks needed.
Benefits:
- β
Test real HTTP calls, not mocks
- β
Verify exact message content (subject, body, recipients)
- β
Test all channels: Email + SMS + Push + Chat
- β
Zero external dependencies (no Mailgun/Twilio accounts needed)
services:
gateway:
image: ghcr.io/weprodev/wpd-message-gateway:latest
ports:
- 10101:10101
steps:
- run: npm test # Your app sends to http://localhost:10101
- name: Verify welcome email
run: |
curl -s http://localhost:10101/api/v1/emails | \
jq -e '.emails[0].email.subject == "Welcome!"'
β See E2E Testing Guide for complete examples.
Provider Status
| Type |
Provider |
Status |
| π§ Email |
Mailgun |
β
Ready |
| π§ Email |
Memory (DevBox) |
β
Ready |
| π§ Email |
SendGrid |
π Planned |
| π± SMS |
Memory (DevBox) |
β
Ready |
| π± SMS |
Twilio |
π Planned |
| π Push |
Memory (DevBox) |
β
Ready |
| π Push |
Firebase |
π Planned |
| π¬ Chat |
Memory (DevBox) |
β
Ready |
| π¬ Chat |
WhatsApp |
π Planned |
Commands
make install # Install all dependencies
make start # Start development (Gateway + DevBox UI)
make test # Run tests
make audit # Full check: format + lint + test + security
make build # Build all packages
# Docker
make dev # Start Gateway via Docker
make dev-down # Stop Docker
# Optional (email preview)
make mailpit # Start Mailpit for HTML email preview
Project Structure
wpd-message-gateway/
βββ cmd/server/ # HTTP server entry point
βββ configs/ # YAML configuration files
βββ internal/ # Private application code
β βββ app/ # Configuration, wiring, validation
β βββ core/ # Business logic
β β βββ port/ # Interface definitions (contracts)
β β βββ service/ # Gateway service, registry
β βββ infrastructure/ # External integrations
β β βββ provider/ # Provider implementations
β β βββ mailgun/ # Mailgun email provider
β β βββ memory/ # In-memory provider (DevBox)
β βββ presentation/ # HTTP layer
β βββ handler/ # Request handlers
β βββ router.go # Route definitions
βββ pkg/ # Public packages for external use
β βββ contracts/ # Message types (Email, SMS, Push, Chat)
β βββ errors/ # Error types
β βββ gateway/ # Embedded SDK
βββ web/ # DevBox React UI
βββ tests/bruno/ # API test collection
Documentation
License
MIT