# Task 012 — Campaigns Module

## Objective

Implement campaign CRUD, lifecycle states, and wizard UI connecting segments and templates.

## Scope

- Campaign model and API
- UI list, detail, new campaign wizard (segment + template + schedule)
- Status machine per `docs/06-campaign-system.md`
- n8n `N8N_WEBHOOK_CAMPAIGN_CREATED` on create

**Out of scope:** Actual SMTP send (Task 014).

## Requirements

1. Draft → scheduled → sending → sent/cancelled flows (sending may stub until 014).
2. Snapshot audience count at schedule time.
3. Campaign detail shows segment and template info.

## Files to create or modify

| Path | Action |
|------|--------|
| `src/app/campaigns/**` | Create |
| `src/app/api/campaigns/**` | Create |
| `src/services/campaign.service.ts` | Create |
| `docs/06-campaign-system.md` | Sync |
| `docs/16-changelog.md` | Entry |

## Acceptance criteria

- [ ] Create and schedule campaign in UI
- [ ] Status displayed correctly
- [ ] Webhook fires when env configured

## Documentation updates required

- `docs/06-campaign-system.md`
- `docs/09-n8n-integration.md`
- `docs/16-changelog.md`
