# Absolute Checklist: Streaming Simplification (WebRTC-only)

## Backend

1. Add/confirm `SIMPLE_STREAMING` environment/config switch (default: true for new deployment profile).
2. In `Backend/routes/streams.ts`, update `POST /streams/request` to:
   - keep device role/link validation
   - create session with status `requested`
   - emit request event directly compatible with WebRTC-only flow
   - remove stream-provider payload assumptions from response
3. In `Backend/routes/streams.ts`, update `POST /streams/:id/accept` to:
   - validate camera ownership and state
   - set status to `streaming`
   - set `startedAt`
   - emit `stream:started`
   - remove or gate all publish/subscribe/media-provider dependency
4. In `Backend/routes/streams.ts`, update `POST /streams/:id/end` to:
   - require authorized participant (camera or requester)
   - set status to `ended`
   - set `endedAt`
   - emit `stream:ended`
   - stop any active SFU session only if explicitly still active and configured
5. In `Backend/routes/streams.ts`, remove any hard dependency on `mediaProvider.createSession` for live functionality.
6. Gate recording creation in stream end logic behind feature flag (default OFF) or remove endpoint path from phase-1 path.
7. In `Backend/routes/streams.ts`, return minimal deterministic payload for stream start/accept/end responses.
8. In `Backend/db/schema.ts`, mark legacy media fields as deprecated comments only (no schema migration required in phase 1).
9. In `Backend/media/service.ts`, make provider calls no-op for phase-1 streaming runtime or guard them behind non-simplified feature flag.
10. In `Backend/media/providers/mock.ts`, annotate mock provider methods as metadata-only and remove calls from request/accept/end flow.
11. In `Backend/media/sfu/service.ts` and `Backend/media/sfu/noop.ts`, ensure no required startup path is executed for default simplified mode.
12. In `Backend/routes/commands.ts`, document command-table deprecation for stream lifecycle command path; remove active usage if simplified mode is enabled.

## Realtime Gateway

13. In `Backend/realtime/gateway.ts`, remove `stream:frame` event listener and sender path.
14. In `Backend/realtime/gateway.ts`, remove frame-relay participant cache and related validation branch.
15. In `Backend/realtime/gateway.ts`, keep only validated `webrtc:signal` logic for offer/answer/candidate/hangup.
16. In `Backend/realtime/gateway.ts`, simplify signal forwarding so target validation is session ownership + same user context.
17. In `Backend/realtime/gateway.ts`, remove periodic command retry polling for stream commands when in simplified mode.
18. Keep `stream:started` and `stream:ended` emit paths with recipient resolution.
19. Ensure socket middleware still enforces device token auth and role identity checks.

## Web frontend

20. In `WebApp/src/lib/app/controller.js`, collapse stream state to `idle|connecting|active|ended`.
21. Remove fallback image mode, latest-frame state, and frame receiver logic from controller.
22. Ensure client side only uses WebRTC peer connection and `<video>` rendering path.
23. Simplify `ontrack` handling to set remote stream once and ignore duplicate tracks.
24. Add deterministic peer teardown on `stream:ended`, page unload, and navigation changes.
25. In `WebApp/src/routes/camera/+page.svelte`, remove preview-to-frame interval fallback sender.
26. In `WebApp/src/routes/camera/+page.svelte`, ensure camera-side stream path emits offer only and no JPEG payload.
27. In `WebApp/src/routes/camera/+page.svelte`, remove recording branch that depends on frame transport.
28. In `WebApp/src/routes/client/+page.svelte`, remove fallback image DOM branch and related status labels.

## Mobile frontend

29. In `MobileApp/src/app-context.tsx`, remove base64 frame stream state and timer lifecycle for frame relay.
30. In `MobileApp/src/app-context.tsx` and `MobileApp/app/(tabs)/index.tsx`, align stream lifecycle state transitions with web logic.
31. In `MobileApp/app/(tabs)/index.tsx`, remove capture+`stream:frame` emission loop.
32. In `MobileApp/app/(tabs)/index.tsx`, remove any image fallback UI path and render strategy for active stream.
33. In `MobileApp/src/api.ts`, remove calls to publish/subscribe credentials endpoints from simplified runtime flow.
34. Ensure mobile camera cleanup stops local media and closes RTCPeerConnection on end and unmount.

## Cross-cutting API/docs/config

35. In `Backend/docs/openapi.ts`, update documented streaming contract to only include:
   - request
   - accept
   - end
   - webrtc signal event behavior
   - remove references implying frame fallback as primary path
36. Update any internal docs or README sections describing mock media endpoints as runtime-critical.
37. Add migration notes to avoid breaking integrations (deprecation and rollback behavior).
38. Add explicit log markers for stream request/accept/offer/answer/end events with session id and participant ids.
39. Add compile/build compatibility checks for both apps after removing unused symbols/imports.
40. Add runtime rollback checklist for disabling `SIMPLE_STREAMING` and re-enabling legacy paths.
