# Ads Manager Service

> Enterprise-grade microservice for managing advertising campaigns, ad sets, and ads following Meta Ads 3-tier structure.

## Overview

Ads Manager Service is the control center of GoodGo advertising system, enabling advertisers to:

- **Create and manage Campaigns** - Set objectives (Awareness, Traffic, Conversion)
- **Configure Ad Sets** - Targeting, budget, schedule, placements
- **Design Ads** - Upload creatives, write copy, select CTAs
- **Manage Audiences** - Custom Audiences, Lookalike Audiences

## Requirements

| Requirement | Version |
|-------------|---------|
| .NET SDK | 10.0.101+ |
| Docker | 24.0+ |
| PostgreSQL | 15+ |

## Quick Start

### Run with Docker

```bash
cd services/ads-manager-service-net
docker-compose up -d
```

### Run Locally

```bash
dotnet restore
dotnet build
dotnet run --project src/AdsManagerService.API
```

## Project Structure

```
ads-manager-service-net/
├── src/
│   ├── AdsManagerService.API/           # Presentation layer
│   │   ├── Controllers/
│   │   │   ├── CampaignsController.cs
│   │   │   ├── AdSetsController.cs
│   │   │   ├── AdsController.cs
│   │   │   └── AudiencesController.cs
│   │   └── Application/                 # CQRS Commands/Queries
│   │
│   ├── AdsManagerService.Domain/        # Business logic
│   │   └── AggregatesModel/
│   │       ├── AdvertiserAggregate/
│   │       ├── CampaignAggregate/
│   │       ├── AdSetAggregate/
│   │       ├── AdAggregate/
│   │       └── AudienceAggregate/
│   │
│   └── AdsManagerService.Infrastructure/
│
├── tests/
├── docs/
├── Dockerfile
└── AdsManagerService.slnx
```

## Domain Model

### 3-Tier Structure

```
Campaign
    ├── Objective (Awareness/Traffic/Conversion)
    ├── Status (Draft/Active/Paused/Completed)
    └── Budget
        │
        ├── AdSet 1
        │   ├── Targeting
        │   ├── Placement
        │   ├── Schedule
        │   └── BidStrategy
        │       ├── Ad 1 (Creative + Headline + CTA)
        │       └── Ad 2
        │
        └── AdSet 2
```

## API Endpoints

### Campaigns

| Method | Endpoint | Description |
|--------|----------|-------------|
| `POST` | `/api/v1/ads-manager/campaigns` | Create campaign |
| `GET` | `/api/v1/ads-manager/campaigns` | List campaigns |
| `GET` | `/api/v1/ads-manager/campaigns/{id}` | Get campaign |
| `PATCH` | `/api/v1/ads-manager/campaigns/{id}` | Update campaign |
| `DELETE` | `/api/v1/ads-manager/campaigns/{id}` | Delete campaign |

### Ad Sets

| Method | Endpoint | Description |
|--------|----------|-------------|
| `POST` | `/api/v1/ads-manager/campaigns/{campaignId}/adsets` | Create ad set |
| `GET` | `/api/v1/ads-manager/adsets/{id}` | Get ad set |
| `PATCH` | `/api/v1/ads-manager/adsets/{id}` | Update ad set |

### Ads

| Method | Endpoint | Description |
|--------|----------|-------------|
| `POST` | `/api/v1/ads-manager/adsets/{adSetId}/ads` | Create ad |
| `GET` | `/api/v1/ads-manager/ads/{id}` | Get ad |
| `PATCH` | `/api/v1/ads-manager/ads/{id}` | Update ad |
| `POST` | `/api/v1/ads-manager/ads/{id}/submit-review` | Submit for review |

### Audiences

| Method | Endpoint | Description |
|--------|----------|-------------|
| `POST` | `/api/v1/ads-manager/audiences/custom` | Create custom audience |
| `POST` | `/api/v1/ads-manager/audiences/lookalike` | Create lookalike |
| `GET` | `/api/v1/ads-manager/audiences` | List audiences |

## Integration

### Related Services

| Service | Integration |
|---------|-------------|
| **IAM Service** | Advertiser authentication |
| **Storage Service** | Creative assets |
| **ads-billing-service** | Budget validation |
| **ads-serving-service** | Publish active ads |

## Configuration

| Variable | Description |
|----------|-------------|
| `DATABASE_URL` | PostgreSQL connection |
| `REDIS_URL` | Redis connection |
| `STORAGE_SERVICE_URL` | Storage Service URL |
| `IAM_SERVICE_URL` | IAM Service URL |

## Testing

```bash
dotnet test
```

## Deployment

```bash
docker build -t ads-manager-service:latest .
docker run -p 5000:8080 --env-file .env ads-manager-service:latest
```

## License

Proprietary - GoodGo Platform
