# Task 021 — AI Insights

## Objective

Generate periodic narrative insights and recommendations for leadership using CRM and campaign data.

## Scope

- Insights API and UI section on dashboard or `/analytics`
- OpenAI summarization over aggregated stats (not raw bulk export)
- Cached insights document with `generatedAt`
- Admin trigger to regenerate

**Out of scope:** Real-time chat assistant.

## Requirements

1. Prompt uses anonymized aggregates where possible.
2. Cache insights for 24h unless refresh requested.
3. Clear disclaimer that insights are AI-generated.

## Files to create or modify

| Path | Action |
|------|--------|
| `src/services/insights.service.ts` | Create |
| `src/app/analytics/**` or dashboard section | Create |
| `docs/08-ai-classification.md` | Insights section |
| `docs/16-changelog.md` | Entry |

## Acceptance criteria

- [ ] Generate insight summary from staging data
- [ ] Cached result served on subsequent loads
- [ ] Error state when OpenAI unavailable

## Documentation updates required

- `docs/08-ai-classification.md`
- `docs/04-ui-pages.md`
- `docs/16-changelog.md`
