# Task 020 — Dashboard Analytics

## Objective

Provide leadership and BD dashboard with KPIs, pipeline summary, campaign performance, and activity feed.

## Scope

- Dashboard API `GET /api/dashboard/summary` and activity endpoint
- UI `/dashboard` with cards and charts (simple)
- Metrics: new leads (period), pipeline value, emails sent, open rate, inbox unread

**Out of scope:** Export to PDF, custom report builder.

## Requirements

1. Role-based visibility (viewer read-only).
2. Date range filter (7d, 30d, 90d).
3. Performance acceptable with aggregation indexes.

## Files to create or modify

| Path | Action |
|------|--------|
| `src/app/dashboard/**` | Create |
| `src/app/api/dashboard/**` | Create |
| `src/services/analytics.service.ts` | Create |
| `docs/04-ui-pages.md` | Dashboard |
| `docs/16-changelog.md` | Entry |

## Acceptance criteria

- [ ] Dashboard loads KPIs from live data
- [ ] Activity feed shows recent CRM events
- [ ] Charts match selected date range

## Documentation updates required

- `docs/04-ui-pages.md`
- `docs/03-api-specification.md`
- `docs/16-changelog.md`
