# Backend - Media Library Viewer API FastAPI backend serving the REST API for Jellyfin media browsing, SSH file inspection, and server monitoring. ## Setup ```bash cd backend python -m venv .venv source .venv/bin/activate pip install -e '.[dev]' ``` Or install dependencies directly: ```bash pip install fastapi uvicorn[standard] pydantic-settings paramiko requests python-dotenv pandas ``` ## Configuration Create a `.env` file in the project root (or set environment variables): ```bash JELLYFIN_URL=https://jellyfin.example.com JELLYFIN_API_KEY=your-api-key JELLYFIN_USER_ID= SSH_HOST=media-server.example.com SSH_USERNAME=username SSH_PORT=22 SSH_KEY_FILENAME=/home/username/.ssh/id_rsa SSH_PASSWORD= REMOTE_MEDIA_ROOT=/srv/media REMOTE_PATH_PREFIX= ``` ## Running ```bash cd backend uvicorn main:app --reload --port 8000 ``` API docs available at: http://localhost:8000/docs ## API Endpoints - `GET /api/dashboard/counts` — Movie/series/episode totals - `GET /api/dashboard/libraries` — Per-library breakdown - `GET /api/dashboard/now-playing` — Active playback sessions - `GET /api/monitoring/status` — Collector status - `GET /api/monitoring/metrics` — Resource samples - `GET /api/monitoring/disk` — Disk space - `POST /api/monitoring/start|stop|restart` — Collector controls - `GET /api/media/status` — Index status - `POST /api/media/build` — Rebuild index - `GET /api/media/query` — Query with filters/sort/pagination - `GET /api/files/list?path=` — Directory listing - `GET /api/files/ffprobe?path=` — ffprobe JSON - `GET /api/files/stat?path=` — stat output - `GET /api/files/resolve-path?path=` — Path resolution - `GET /api/jobs/templates` — Available jobs - `POST /api/jobs/run` — Execute a job