A small, fast targeting service that returns eligible campaigns for a given app/os/country. Backed by Postgres, cached in Redis, and instrumented with Prometheus + Grafana.
cd devops/docker
docker compose up --build- App:
http://localhost:6969 - Prometheus:
http://localhost:9090 - Grafana:
http://localhost:3000(user/pass: admin)
# Ensure Postgres + Redis are running locally, then
source dev.env
make run- GET
/v1/delivery/— returns eligible campaigns (query:app,os,country) - GET
/ping— health check - GET
/metrics— Prometheus metrics
curl --location "http://localhost:6969/v1/delivery/?app=com.example.app&os=ios&country=US"- Prometheus scrapes the app’s
/metricsendpoint (middleware instruments latency, counts, sizes). - Grafana is pre-provisioned with datasources and dashboards (see
devops/grafana).
- Postgres is the source of truth (SQLC repos in
internal/repository/sqlc). - Services (
internal/*/service):- Campaigns: load and cache campaign metadata.
- Targeting Rules: include/exclude rules by dimension.
- Delivery: computes matches and maintains a short-lived delivery cache.
- Redis stores campaign metadata, rule sets, and delivery results.
- A Postgres
LISTEN/NOTIFYwatcher updates caches on data changes.
make test # unit + integration tests
make format # formatting (golines, gofmt)
make run # run the code