Skip to content

prxssh/targeting-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Targeting Engine

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.

Quick Start

Docker (recommended)

cd devops/docker
docker compose up --build
  • App: http://localhost:6969
  • Prometheus: http://localhost:9090
  • Grafana: http://localhost:3000 (user/pass: admin)

Local

# Ensure Postgres + Redis are running locally, then
source dev.env
make run

API

Endpoints

  • GET /v1/delivery/ — returns eligible campaigns (query: app, os, country)
  • GET /ping — health check
  • GET /metrics — Prometheus metrics

Example

curl --location "http://localhost:6969/v1/delivery/?app=com.example.app&os=ios&country=US"

Monitoring

  • Prometheus scrapes the app’s /metrics endpoint (middleware instruments latency, counts, sizes).
  • Grafana is pre-provisioned with datasources and dashboards (see devops/grafana).

Approach

  • 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/NOTIFY watcher updates caches on data changes.

Development

make test     # unit + integration tests
make format   # formatting (golines, gofmt)
make run      # run the code

About

targeting engine poc

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages