# Watch Finished Web Interface

A modern Next.js web application providing a complete UI for managing the Watch Finished video processing system.

## Application Structure

```mermaid
graph TB
    subgraph "Pages (App Router)"
        DASH[Dashboard<br/>page.tsx]
        FILES[Files<br/>files/page.tsx]
        TASKS[Tasks<br/>tasks/page.tsx]
        SETTINGS[Settings<br/>settings/page.tsx]
    end

    subgraph "Components"
        NAV[Navigation<br/>components/Nav.tsx]
        WSOCK[WebSocketProvider<br/>providers/WebSocketProvider.tsx]
        QUERY[QueryProvider<br/>providers/QueryProvider.tsx]
    end

    subgraph "File Management"
        FLIST[FileList<br/>components/files/FileList.tsx]
        FFORM[FileForm<br/>components/files/FileForm.tsx]
        FMAINT[MaintenanceTools<br/>components/files/MaintenanceTools.tsx]
    end

    subgraph "Task Management"
        TLIST[TaskList<br/>components/tasks/TaskList.tsx]
        TPROGRESS[TaskProgress<br/>components/tasks/TaskProgress.tsx]
    end

    subgraph "Settings"
        DSET[DatasetSettings<br/>components/settings/DatasetSettings.tsx]
        SYSSET[SystemSettings<br/>components/settings/SystemSettings.tsx]
    end

    subgraph "API Integration"
        API[API Client<br/>lib/api.ts]
        WS[WebSocket Client<br/>lib/websocket.ts]
    end

    DASH --> NAV
    FILES --> FLIST
    FILES --> FFORM
    FILES --> FMAINT
    TASKS --> TLIST
    TASKS --> TPROGRESS
    SETTINGS --> DSET
    SETTINGS --> SYSSET

    FLIST --> API
    FFORM --> API
    FMAINT --> API
    TLIST --> API
    TPROGRESS --> WS
    DSET --> API
    SYSSET --> API

    WSOCK --> WS
    QUERY --> API

    style DASH fill:#e3f2fd
    style API fill:#e8f5e8
    style WSOCK fill:#f3e5f5
```

## Features

- **Dashboard**: Real-time watcher status, task monitoring, and system statistics
- **File Management**: Browse, add, edit, and delete processed video files by dataset
- **Task Queue**: View processing tasks, monitor progress, and manage the queue
- **Settings Management**: Configure datasets, watcher settings, and system preferences
- **Maintenance Tools**: Cleanup, purge, and prune operations with easy-to-use forms
- **Real-time Updates**: WebSocket integration for live status updates

## Tech Stack

- **Framework**: Next.js 14 with App Router
- **UI**: React with TypeScript
- **Styling**: Tailwind CSS
- **State Management**: TanStack Query for server state
- **Real-time**: Socket.IO client for WebSocket communication
- **Forms**: React Hook Form with validation
- **Icons**: Heroicons

## Main Pages

- `/` - Dashboard with system overview and active tasks
- `/files` - File management with CRUD operations and maintenance tools
- `/tasks` - Task queue monitoring and management
- `/settings` - Configuration management for datasets and system settings

## Development

```bash
# Install dependencies
pnpm install

# Run development server
pnpm run dev

# Run tests
pnpm run test

# Build for production
pnpm run build
```

## Environment Variables

- `NEXT_PUBLIC_WATCH_FINISHED_API` - API service URL (default: http://localhost:3001)

## Key Components

- **ClientHomeWidgets**: Dashboard widgets for watcher status and API health
- **FileList**: Table view of processed files with actions
- **FileCrud**: Form component for file management
- **MaintenanceDropdown**: Dropdown with cleanup, purge, and prune operations
- **TaskList**: Task queue display with progress indicators
- **SettingsCrud**: Configuration management interface

## Real-time Features

The web app connects to the API service via WebSocket to receive live updates:

- Task progress updates
- File processing status changes
- Watcher start/stop events
- Maintenance operation results

```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
```
