# Phase 5: DNS Records Page

**Status:** ⬜ Not Started
**Parent plan:** [PLAN.md](./PLAN.md)
**Domain:** fullstack

## Objective
Create a dedicated DNS Records page that lists all managed DNS records with filtering,
consumer mapping, and sync status visibility.

## Tasks

- [ ] Task 1: Add backend endpoint `GET /api/dns/records`
  - Returns merged view: local dns_records + Cloudflare actual records
  - Each record: fqdn, type, value (IP), consumer_type, consumer_name, status (synced/orphaned/missing)
  - Orphaned = exists in Cloudflare but no local consumer
  - Missing = local consumer exists but no Cloudflare record
- [ ] Task 2: Add API handler in `internal/api/dns.go`
  - New handler file for DNS-related endpoints
  - Register routes in router.go
- [ ] Task 3: Add frontend API function `getDnsRecords()` in `api.ts`
- [ ] Task 4: Create DNS Records page at `web/src/routes/dns/+page.svelte`
  - Table with columns: FQDN, Type, Value, Consumer, Status
  - Consumer column shows: instance name (project/stage) or standalone proxy name
  - Status badges: synced (green), orphaned (yellow), missing (red)
  - Search filter (by FQDN substring)
  - Filter by consumer type: all / managed / standalone
  - Filter by status: all / synced / orphaned / missing
  - Manual sync button (calls POST /api/dns/sync — Phase 6)
  - Refresh button to re-fetch from Cloudflare
- [ ] Task 5: Add navigation link to DNS page
  - Only visible when wildcard DNS is disabled
  - Add to sidebar/nav under Settings or as top-level
- [ ] Task 6: Add i18n keys for DNS records page

## Files to Modify/Create
- `internal/api/dns.go` — new handler file
- `internal/api/router.go` — register DNS routes
- `web/src/lib/api.ts` — add DNS records API function
- `web/src/routes/dns/+page.svelte` — new page
- `web/src/routes/dns/+page.ts` — optional load function
- Navigation component — add DNS link
- Locale files — add i18n keys

## Acceptance Criteria
- DNS Records page accessible at /dns
- Table shows all records with correct status
- Filtering works: search text, consumer type, sync status
- Only accessible/visible when wildcard DNS is disabled
- Consumer names resolve correctly (project/stage for managed, proxy name for standalone)

## Notes
- Status computation: compare local dns_records table with Cloudflare ListRecords response
- Cache Cloudflare response for a few seconds to avoid rate limiting on page load
- Navigation link visibility tied to settings (may need a store or settings check)

## Review Checklist
- [ ] All tasks completed
- [ ] Code follows project conventions
- [ ] No unintended side effects
- [ ] Build passes
- [ ] Tests pass (new + existing)

## Handoff to Next Phase
<!-- Filled in after completion -->
