# Ads Analytics Service

> Microservice for advertising reporting, dashboards, and performance insights.

## Overview

Ads Analytics Service aggregates and analyzes advertising data:

- **Real-time Reporting** - Live metrics dashboard
- **Custom Reports** - Flexible report builder
- **Audience Insights** - Demographics analysis
- **Performance Insights** - Optimization recommendations

## Requirements

| Requirement | Version |
|-------------|---------|
| .NET SDK | 10.0.101+ |
| Docker | 24.0+ |
| ClickHouse | 23.8+ (recommended) |
| PostgreSQL | 15+ |

## Quick Start

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

## Project Structure

```
ads-analytics-service-net/
├── src/
│   ├── AdsAnalyticsService.API/
│   │   └── Controllers/
│   │       ├── MetricsController.cs
│   │       ├── ReportsController.cs
│   │       └── InsightsController.cs
│   │
│   ├── AdsAnalyticsService.Domain/
│   │   └── AggregatesModel/
│   │       ├── MetricsAggregate/
│   │       ├── ReportAggregate/
│   │       └── InsightAggregate/
│   │
│   └── AdsAnalyticsService.Infrastructure/
│
└── AdsAnalyticsService.slnx
```

## Metrics

| Metric | Description |
|--------|-------------|
| **Impressions** | Total views |
| **Clicks** | Total clicks |
| **CTR** | Click-through rate |
| **CPC** | Cost per click |
| **CPM** | Cost per 1000 impressions |
| **ROAS** | Return on ad spend |

## API Endpoints

### Metrics

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/v1/ads-analytics/campaigns/{id}/metrics` | Campaign metrics |
| `GET` | `/api/v1/ads-analytics/adsets/{id}/metrics` | Ad Set metrics |
| `GET` | `/api/v1/ads-analytics/ads/{id}/metrics` | Ad metrics |

### Reports

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/v1/ads-analytics/reports` | List reports |
| `POST` | `/api/v1/ads-analytics/reports` | Create custom report |
| `POST` | `/api/v1/ads-analytics/reports/schedule` | Schedule report |
| `GET` | `/api/v1/ads-analytics/reports/{id}/export` | Export report |

### Breakdown

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/v1/ads-analytics/campaigns/{id}/breakdown?by=age` | By age |
| `GET` | `/api/v1/ads-analytics/campaigns/{id}/breakdown?by=gender` | By gender |

## Integration

| Service | Integration |
|---------|-------------|
| **ads-serving-service** | Consume events |
| **ads-tracking-service** | Consume conversions |

## License

Proprietary - GoodGo Platform
