A simple SMS gateway service written in Go.
- Users can top up a balance and send SMS.
- Messages are enqueued and processed by worker processes.
- Fair scheduling with least-recently-served (LRS) ordering prevents whales from starving smaller users.
- REST API for user and message operations.
- Background workers claim and deliver messages.
- Prometheus metrics and health endpoints.
- Go 1.22+
- PostgreSQL 16+
-
Run migrations:
make migrate
-
Start the API server:
go run ./cmd/api
It will listen on
:8080. -
Start the worker:
go run ./cmd/worker
It will process queued messages.
POST /users— create userPOST /users/{id}/topup— add balanceGET /users/{id}/balance— get balancePOST /messages— enqueue SMS (requiresX-User-IDheader)GET /messages— list messagesGET /messages/{id}— get message
- API:
/healthzand/metricson port8080. - Worker:
/healthzand/metricson port9090.