# Campaigns App

Communication campaign management for Dexxy.

## Purpose

This app handles outbound communications to community members, including announcements and email campaigns. Campaigns follow a draft-schedule-send lifecycle.

## Models

### Campaign

Represents a communication campaign.

| Field | Type | Description |
|-------|------|-------------|
| `workspace` | ForeignKey | Workspace scope |
| `name` | CharField | Campaign name |
| `channel` | CharField | Delivery channel |
| `content` | TextField | Campaign content/body |
| `status` | CharField | Lifecycle state |
| `send_at` | DateTimeField | Scheduled send time (optional) |

**Channels:**
- `announcement` - In-app or community announcements
- `email` - Email campaigns

**Status Values:**
- `draft` - Being composed
- `scheduled` - Ready to send at `send_at`
- `sent` - Delivered

## GraphQL API

### Queries

- `campaigns(workspace_id, status?)` - List campaigns with optional status filter
- `campaign(id)` - Get a specific campaign

### Mutations

- `createCampaign(input)` - Create a new campaign (starts as draft)
- `updateCampaign(id, input)` - Update campaign content or schedule
- `deleteCampaign(id)` - Delete a campaign

## Key Patterns

1. **Lifecycle Management**: Clear draft → scheduled → sent progression
2. **Channel Abstraction**: Same model handles multiple delivery methods
3. **Scheduled Delivery**: Background jobs process campaigns at `send_at`

## Dependencies

- `accounts.Workspace`
- Background task queue for scheduled sends

## File Structure

```
campaigns/
├── models.py      # Campaign model
├── graphql.py     # GraphQL types, queries, mutations
├── apps.py        # Django app config
└── migrations/    # Database migrations
```
