# SOUND Server Routes

This document enumerates the main API endpoints for the SOUND server.

## Streaming Endpoints

All streaming routes are defined in `routes/streamingRoutes.ts` and mounted before auth middleware.

| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/stream/*` | Main streaming endpoint with adaptive transcoding |
| GET | `/stream?path=...` | Legacy streaming endpoint |
| GET | `/api/transcode/:id` | On-the-fly transcoding |
| GET | `/api/hardware-status` | Hardware acceleration status |
| GET | `/api/waveform/:id` | Waveform data for a track |
| GET | `/api/stream/mobile/*` | Mobile-optimized streaming (FLAC→MP3) |

## Auth/Pairing Endpoints

Defined in `streamlinePairingRoutes.ts` and `streamlineAuth.ts`.

| Method | Path | Description |
|--------|------|-------------|
| POST | `/api/pairing/pair` | Pair with Streamline account |
| GET | `/api/pairing/status` | Check pairing status |
| POST | `/api/pairing/unpair` | Remove pairing |
| POST | `/api/pairing/tunnel/start` | Start Cloudflare tunnel |
| POST | `/api/pairing/tunnel/stop` | Stop Cloudflare tunnel |
| GET | `/auth/streamline` | OAuth redirect to Streamline |
| GET | `/auth/callback` | OAuth callback handler |
| GET | `/api/streamline/status` | Streamline connection status |
| POST | `/api/streamline/unlink` | Unlink Streamline account |

## WebSocket Endpoints

Defined in `websocket.ts`, `playerWebSocket.ts`, and `websocketEvents.ts`.

| Path | Description |
|------|-------------|
| `/ws` | Main WebSocket connection for real-time updates |
| `/api/player/ws` | Player state synchronization |

## Key Route Files

- `routes/streamingRoutes.ts` - Audio streaming (AbortController, pipeline-based)
- `routes/playHistoryRoutes.ts` - Play history and analytics
- `routes/api/libraryRoutes.ts` - Library management
- `routes/api/tracksRoutes.ts` - Track CRUD operations
- `routes/healthRoutes.ts` - Health checks and status
- `streamlinePairingRoutes.ts` - Streamline pairing
- `websocket.ts` - WebSocket server setup
