# S06 Research: Admin UI — Multi-Source Pipeline Management

## Depth: Light Research

This is straightforward admin UI work using established patterns already in the codebase. The AdminPipeline page (1500+ lines) is a mature component with video list, event logs, chunking inspector, bulk actions, and run history. The data model (S03) and compose logic (S04) are complete. The needed API surface mostly exists already.

## Summary

The roadmap demo: "Admin view for multi-source page shows source dropdown, composition history, per-video chunking inspection."

Three capabilities are needed:

1. **Multi-source technique page list** — Admin needs a view of technique pages showing which source videos contributed to each, grouped/filterable by creator. No such admin endpoint or page exists yet.

2. **Composition history** — Version history showing what was composed when. The `TechniquePageVersion` model and `/{slug}/versions` API endpoint already exist. The frontend `TechniquePage.tsx` already has version switching. What's missing is surfacing this from an admin management perspective (which pages have multiple sources, which were composed vs created fresh).

3. **Per-video chunking inspection** — Already exists as `ChunkingInspector` component in `AdminPipeline.tsx` and the `GET /admin/pipeline/chunking/{video_id}` backend endpoint. This is done.

## Implementation Landscape

### What Exists

**Backend:**
- `GET /techniques` — list with category/creator filter, pagination, sort
- `GET /techniques/{slug}` — detail with `source_videos` and `version_count`
- `GET /techniques/{slug}/versions` — version list with `pipeline_metadata`
- `GET /techniques/{slug}/versions/{n}` — version detail with `content_snapshot`
- `GET /admin/pipeline/chunking/{video_id}` — full chunking data
- `TechniquePageVideo` association table tracking page↔video links with `added_at`
- `TechniquePageVersion` with `pipeline_metadata` JSONB (stores prompt hashes, model config)

**Frontend:**
- `AdminPipeline.tsx` — 1500-line page with video management, chunking inspector, bulk actions
- `TechniquePage.tsx` — version switcher already built
- `public-client.ts` — types for `SourceVideoSummary`, `TechniquePageVersionSummary`, fetchers for techniques/versions
- Route: `/admin/pipeline` (video management), no technique admin page yet

**Schemas:**
- `SourceVideoSummary`: id, filename, content_type, added_at
- `TechniquePageVersionSummary`: version_number, created_at, pipeline_metadata
- `TechniquePageDetail` already includes `source_videos[]` and `version_count`

### What's Needed

**New backend endpoint:**
- `GET /admin/pipeline/technique-pages` — Admin-focused technique page list with source video counts, body_sections_format, version counts, and latest composition date. Needs joins to `technique_page_videos` and `technique_page_versions`. Filterable by multi-source (>1 video) and by creator.

**New frontend page or section:**
- Either a new page at `/admin/techniques` or a new tab/section in `AdminPipeline.tsx`. Given that AdminPipeline is already 1500 lines, a separate page makes more sense.
- Shows technique pages in a table: title, creator, source video count, format (v1/v2), version count, last updated
- Expandable row showing source videos list (from existing `/techniques/{slug}` response) and link to version history
- Filter: "Multi-source only" toggle, creator dropdown
- Link to pipeline admin filtered by video ID (already supported via `?video=` query param)

**Frontend wiring:**
- New route `/admin/techniques`
- Entry in `AdminDropdown` component
- New fetch function in `public-client.ts`

### Natural Seams

1. **T01: Backend endpoint** — `GET /admin/pipeline/technique-pages` with multi-source filtering. Small, self-contained.
2. **T02: Frontend page** — New `AdminTechniquePages.tsx` with table, expand/collapse for source videos and composition history, filters. Uses existing API fetchers for version detail.
3. **T03: Integration** — Route, dropdown entry, cross-links between pipeline admin ↔ technique admin.

### Constraints

- The existing `GET /techniques` endpoint returns paginated public data. The admin endpoint needs additional fields (source video count, format, version count) without modifying the public response — so a separate admin endpoint is cleaner.
- `AdminPipeline.tsx` already links to pipeline admin via `?video=` — the technique admin should link back using the same pattern.
- ChunkingInspector already exists in AdminPipeline — the technique admin page should link to it rather than duplicate it.

## Recommendation

Build a lightweight admin technique pages endpoint and a new frontend page. ~3 tasks: backend endpoint, frontend page, integration wiring. The heaviest task is the frontend page, but it follows the exact same patterns as AdminPipeline (table with expandable rows, filters, badges).
