# Architecture
Goal
Keep trim behavior stable and reusable by separating capability logic from React and UI composition.
Layered Flow

Player Implementation
↓
Player Contract
↓
Video Trim Manager
↓
React Hooks
↓
Video Trim Module
Ownership Boundary
| Layer | Owns | Must Not Own |
|---|---|---|
| Manager | State, validation, history, playback sync, behavior events | React lifecycle, rendering, backend workflow |
| Hooks | React bridge and state projection | Business-rule ownership, duplicate trim state |
| Module | Rendering, interaction wiring, UI composition | Core trim logic and state authority |
Dependency Rules
Allowed direction is strictly one-way:
Player -> Contract -> Manager -> Hooks -> Module
Forbidden direction examples:
- Module directly mutating manager internals
- Hooks re-implementing validation logic
- Manager importing React or Next runtime types
Why This Boundary Exists
- Behavior correctness is independent of UI churn
- Tests can validate core trim logic without browser rendering
- Contract adapters enable player replacement without touching manager behavior
- Future extraction into SDK/package remains possible