# projects/ — Project CRUD, Stats, Config

See @../../CLAUDE.md for project-wide patterns.

## MCP Tools (2 only)
`create_project` (idempotent — falls back to GET on 409), `get_project`. All other operations are REST-only.

## Config Endpoints
Two JSON configs stored as TEXT columns on the projects table:
- **K8sConfig**: Kubernetes monitoring (namespace, Loki URL, error/noise patterns)
- **DeployConfig**: GitHub Actions workflow dispatch settings

Config GET endpoints return **defaults** if stored JSON is empty — never null.

## Stats Endpoint (`GET /api/projects/{id}/stats`)
Returns feature_counts, task_counts, task_priority_counts, total_logs, recent_logs (10), duration_stats (avg/min/max in **seconds**), performance_stats (total lines/tokens).

## Activity Endpoint (`GET /api/projects/{id}/activity?hours=8`)
Returns hourly task completion time series. Generates complete series backwards from now, filling missing hours with zero counts.

## Gotchas
- Project `id` is TEXT (repo name), not autoincrement — it's the primary key
- Create strips whitespace from id, path, and github_url
- Project relations: self-links blocked, both projects must exist, UNIQUE constraint on pairs
