Skip to content

kumarraja2k05/targeting-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎯 Targeting Engine – Greedy Games Backend Assignment

πŸ“Œ Overview

This project is a Go microservice that routes the right campaigns to the right delivery requests based on targeting rules.
It exposes an HTTP endpoint /v1/delivery which matches active campaigns against request parameters (app, country, os) and returns the campaigns that qualify.


πŸ—‚οΈ Project Structure

targeting-engine/
β”œβ”€β”€ cmd/
β”‚ └── server/
β”‚ └── main.go # App entrypoint
β”œβ”€β”€ internal/
β”‚ β”œβ”€β”€ delivery/
β”‚ β”‚ β”œβ”€β”€ handler.go # Delivery HTTP handler
β”‚ β”‚ └── handler_test.go # Unit tests for delivery
β”‚ β”œβ”€β”€ campaign/
β”‚ β”‚ β”œβ”€β”€ matcher.go # Rule-matching logic
β”‚ β”‚ └── matcher_test.go # Unit tests for matcher
β”‚ β”œβ”€β”€ db/
β”‚ β”‚ └── store.go # In-memory campaigns + rules (later DB/Redis)
β”‚ └── models/
β”‚ └── types.go # Struct definitions
β”œβ”€β”€ migrations/ # (optional) SQL schema for Postgres
β”œβ”€β”€ go.mod / go.sum
└── docker-compose.yml # (optional) Postgres/Redis setup

Campaign

type Campaign struct {
    ID     string `json:"cid"`
    Name   string
    Image  string `json:"img"`
    CTA    string `json:"cta"`
    Status string // "ACTIVE" or "INACTIVE"
}

Targeting Rule

type TargetingRule struct {
    CampaignID       string
    IncludeApps      []string
    ExcludeApps      []string
    IncludeCountries []string
    ExcludeCountries []string
    IncludeOS        []string
    ExcludeOS        []string
}

API Usage

Delivery Endpoint

Request

GET /v1/delivery?app=com.gametion.ludokinggame&country=us&os=android

Response (200 OK)

[
  {
    "cid": "spotify",
    "img": "https://somelink",
    "cta": "Download"
  },
  {
    "cid": "subwaysurfer",
    "img": "https://somelink3",
    "cta": "Play"
  }
]

Response (204 No Content)

(no body)

Response (400 Bad Request)

{ "error": "missing app param" }

πŸ§ͺ Testing

Run all tests:

go test ./...

Test cases cover: Rule matching logic (inclusion/exclusion). Delivery endpoint behavior (200, 204, 400).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages