A unified web UI for a self-hosted media stack — one dashboard for Sonarr, Radarr, Whisparr, Emby, Seerr, Prowlarr, SABnzbd, and Bazarr, with cross-service orchestration, real-time updates, and an approval workflow for destructive actions.
MediaManager ingests webhooks from every service, normalises them into an activity feed, and dispatches follow-up actions across services (e.g. deleting a series in Emby can cue a matching delete in Sonarr, gated by approval). It ships with browse/add/remove UIs for TV and movies, a Seerr request console, a seasonal-anime browser, a Subtitle Center backed by Bazarr, an SABnzbd download queue, Emby Now Playing + watch history, a live service-health board, a statistics dashboard, per-user notifications (including ntfy push), and an optional multi-agent AI layer that drives the same approval pipeline — from a chat assistant to autonomous subtitle repair and media-file replacement.
- Sonarr — browse, add, and delete TV series; see watch/download activity
- Radarr — browse, add, and delete movies; same activity feed
- Whisparr — adult content management (v2 Eros and v3 supported) via the AI assistant and action pipeline; no dedicated browse UI
- Emby — Now Playing widget, per-user watch history, Emby-to-local user linking
- Seerr — list media requests, approve / decline / retry / delete (admin only for the last two)
- Prowlarr — indexer search from the unified Search page, per-indexer test + stats on the connection admin page
- SABnzbd — live download queue ("Downloads" page): pause/resume globally or per item, delete, reprioritise; history polling and sidebar badges
- Bazarr — full Subtitle Center (Overview / Missing / Library / History / Escalations tabs) plus opt-in automated subtitle repair (see below)
- Seasonal Anime — browse a broadcast season from AniList or Jikan/MAL, overlaid with owned/requested state, and request titles through Seerr (id mapping via the Fribb anime-lists dataset, with user-confirmable fuzzy matches)
- Webhook ingest — token-authenticated endpoints for every service, payload stored as
WebhookEventand processed asynchronously - Action pipeline —
ActionRequeststate machine (pending → approved → executing → completed/failed) with per-type approval rules (24 seeded action types) - Cross-service orchestration — Emby delete cascades to Sonarr/Radarr; *arr downloads/deletes trigger Emby library scans; Seerr "media available" refreshes Emby
- Media replacement — grab-before-delete replacement of an already-imported episode/movie with a better release, verified end-to-end via webhooks (see Media replacement)
- Subtitle automation — Bazarr-driven subtitle cases with grace periods, probes, and AI-advisor escalation
- Real-time dashboard — Reverb + Echo private channels for service health, Emby playback, action requests, downloads, subtitles, and dashboard stats
- Notifications — per-user, per-severity channel matrix (in-app, broadcast, mail, ntfy push) with a notification inbox
- Statistics — pre-aggregated rollups powering a user statistics page (plays, watch hours, downloads, request funnel, leaderboards) and an admin operations view (webhooks, actions, queue depth, disk, AI cost); optional Prometheus scrape endpoint
- Scheduled monitoring — health pings every 5 minutes; daily upstream GitHub release checks for "update available" badges; nightly retention pruning
- Authentication — local email/password via Fortify (with 2FA), optional Authentik SSO, optional Emby-credential login, plus an invite flow with password set on first visit
- Role model —
admin/member/viewerwith hierarchical checks (isAtLeast) - Optional AI layer — chat assistant, autonomous per-webhook decision agent, subtitle advisor, and price-verification agent, all routed through the same approval pipeline, with cost accounting, budgets, and a maintained model-price catalog
- Docker + Docker Compose (Sail handles PHP 8.5, Postgres 18, Valkey, Mailpit, Typesense, Reverb)
- Any combination of the external services you want to manage: Sonarr, Radarr, Whisparr, Emby, Seerr, Prowlarr, SABnzbd, Bazarr (none are required to boot)
- Optional: an Authentik instance for SSO
- Optional: an API key for at least one AI provider (OpenAI is the default; Anthropic, Gemini, Groq, Mistral, and others are supported via
laravel/ai)
git clone <your-fork-url> MediaManager
cd MediaManager
cp .env.example .env
# start containers
vendor/bin/sail up -d
# install PHP + JS deps (first run only)
vendor/bin/sail composer install
vendor/bin/sail pnpm install
# Laravel bootstrap
vendor/bin/sail artisan key:generate
vendor/bin/sail artisan migrate --seed
# build the frontend
vendor/bin/sail pnpm run build
# visit http://localhost:${APP_PORT}
vendor/bin/sail openIn local/testing environments, the default seed creates an admin user test@example.com (password from the User factory — check it via vendor/bin/sail artisan tinker if you need it, or create one directly with vendor/bin/sail artisan users:create). In non-local environments it skips that fixed user. It always seeds the ActionTypeConfig rows (add/delete/monitor/quality-profile for Sonarr+Radarr, Seerr cleanup/approve/decline, Emby library scan, media replacement, stuck-import resolution, and the nine bazarr_* subtitle operations) and, if any *_URL / *_API_KEY env vars are set, the matching ServiceConnection rows.
During development you probably want the Vite dev server running instead of pnpm run build:
vendor/bin/sail pnpm run devThe production stack lives in docker/production and runs the published application image as separate web (Octane), queue, queue-ai, scheduler, Reverb, migration, and Inertia SSR services, alongside Postgres, Valkey, and Typesense containers. The SSR service uses the same image as the web service, so both processes always run the same application release and frontend bundle.
For a new deployment, create the production environment file and fill in the required application, database, Reverb, Typesense, and service credentials:
cd docker/production
cp .env.example .envKeep these SSR settings in .env:
INERTIA_SSR_ENABLED=true
INERTIA_SSR_RUNTIME=node
INERTIA_SSR_ENSURE_RUNTIME_EXISTS=true
INERTIA_SSR_URL=http://ssr:13714
INERTIA_SSR_ENSURE_BUNDLE_EXISTS=true
INERTIA_SSR_THROW_ON_ERROR=falsePull and start the stack from docker/production:
docker compose --env-file .env pull
docker compose --env-file .env up -d
docker compose --env-file .env psThe normal image build creates both the browser bundle and bootstrap/ssr/ssr.js. The ssr container runs that bundle with Node.js on the private Compose network; port 13714 is not exposed publicly. TLS is terminated by your reverse proxy in front of the web and reverb ports.
MediaManager expects a reverse proxy (Traefik, Caddy, nginx) in front of the web and reverb ports to terminate TLS. Set TRUSTED_PROXIES in docker/production/.env to that proxy's exact address, for example TRUSTED_PROXIES=192.168.1.10. The app then honors the proxy's X-Forwarded-For / X-Forwarded-Proto headers, so login throttling keys on the real client IP and signed invite and verification links validate.
Leave it empty (the default) when nothing sits in front of the app: no forwarded header is trusted. Do not list whole private ranges such as 192.168.0.0/16. Compose publishes WEB_PORT on every interface, so any host inside a trusted range could send a forged X-Forwarded-For and dodge the login and Emby-login throttles. The app logs a warning (at most once a day) while TRUSTED_PROXIES contains * or a range wider than /24 (IPv6: /64). Where you can, also firewall WEB_PORT and REVERB_BIND_PORT so only the proxy host reaches them.
Every page carries X-Frame-Options: SAMEORIGIN and Content-Security-Policy: frame-ancestors 'self', so a dashboard on another host or port shows an empty or refused iframe. This is deliberate: it stops another site from loading MediaManager invisibly and tricking a signed-in admin into clicking approve, delete or save (clickjacking). Chat attachment downloads send their own, stricter sandboxing CSP (default-src 'none'; sandbox), which the substring replace below leaves intact.
-
Recommended: add MediaManager to Homarr, Organizr or a similar dashboard as a link or app tile that opens it in its own tab.
-
Embedding from a sibling subdomain (a dashboard at
dash.example.comframingmedia.example.com) needs your reverse proxy to replace both headers on MediaManager's responses: dropX-Frame-Options(it cannot name another origin) and widenContent-Security-Policy'sframe-ancestorsto include the dashboard's origin. The listed origin can then frame MediaManager, and so could clickjack it: list only a dashboard you control, behind the same login. A Caddy example (MediaManager'swebport published as8080on192.168.1.20), using a substring replace so a response with a different Content-Security-Policy is left alone:media.example.com { reverse_proxy 192.168.1.20:8080 { header_down -X-Frame-Options header_down Content-Security-Policy "frame-ancestors 'self'" "frame-ancestors 'self' https://dash.example.com" } }
header_down -X-Frame-Optionsalso drops that header from chat attachment downloads, whose CSP names noframe-ancestors. Another page could then frame an attachment, but itssandboxCSP keeps it inert (no scripts, forms or same-origin access), only its uploader can open it, and a cross-site frame gets no session cookie, so the redirect to the login page is refused too. -
Embedding from another site (a different registrable domain) still fails after that: the session cookie is
SameSite=Lax, so the browser does not send it inside a cross-site frame and the frame stays on the login page.
Jobs run on five named queues. The queue service drains actions (approved actions), webhooks (inbound webhook processing) and default (everything else), in that priority order; the queue-ai service drains ai (decision agent, subtitle advisor, embeddings, conversation titles, price refresh) then maintenance (long housekeeping — bulk Seerr request clears, search index reconcile, anime mapping sync) so a slow model call or a long-running job never holds up an approved action or a webhook. Both use the same image and a 300-second job timeout. If you run an older compose.yaml without the queue-ai service, the queue service drains all five queues by default — add the queue-ai service to split them.
Each worker container runs one job at a time and holds about 100 MB. Scale them with QUEUE_REPLICAS and QUEUE_AI_REPLICAS in .env (both default to 1); raise QUEUE_AI_REPLICAS when several model calls should wait in parallel. The web container's Octane worker count is OCTANE_WORKERS (default 8, about 10 MB each); a streaming AI chat holds one worker for its whole turn.
web:GET /upanswers 200 only when Postgres and the Valkey connections the app uses (cache and queue) respond. Upstream media services are not part of it.queue,queue-ai,scheduler: the scheduler records a heartbeat every minute and queues a heartbeat job on every queue; each worker records the queues it drains. The containers report unhealthy when their heartbeat is older than 10 minutes (queues) or 3 minutes (scheduler); override withHEARTBEAT_MAX_AGE(seconds). Because the scheduler queues the worker heartbeats, a stopped scheduler turnsqueueandqueue-aiunhealthy too — check the scheduler first. Check by hand withdocker compose --env-file .env exec queue php artisan ops:check-heartbeat --queue=actions,webhooks,default.
Back up
APP_KEYtogether with the database. Every stored credential is encrypted with it: service connection API keys and webhook tokens, users' Discord/webhook URLs and webhook secrets, notification destination settings, and two-factor secrets. A database restored under a differentAPP_KEYboots, but none of those values decrypt — every service connection and notification destination must be re-entered and every user must re-enrol 2FA. Keep a copy ofdocker/production/.env(it holdsAPP_KEY) somewhere other than the backup disk. To rotate the key, put the old one inAPP_PREVIOUS_KEYSfirst.
| What | Why | How |
|---|---|---|
Postgres (pgsql-data) |
all application state | pg_dump (below) — never copy the live data directory |
docker/production/.env |
APP_KEY and every credential |
copy the file |
app-storage volume (includes app-public-storage) |
chat attachments, staged subtitle uploads, public files | tar through the app image (below) |
Not needed: valkey-data (cache, queues and locks — queued jobs are lost, which only delays work) and typesense-data (rebuilt from Postgres after a restore).
Nightly database dump from the host's crontab, run from docker/production, keeping 14 days:
15 2 * * * cd /opt/media-manager/docker/production && docker compose --env-file .env exec -T pgsql sh -c 'pg_dump -U "$POSTGRES_USER" -d "$POSTGRES_DB" -Fc' > backups/media-manager-$(date +\%F).dump && find backups -name 'media-manager-*.dump' -mtime +14 -deleteFiles:
docker compose --env-file .env run --rm --no-deps -T web tar czf - -C /app/storage app > backups/app-storage-$(date +%F).tgzRestore (same or newer image, the original .env):
cd docker/production
docker compose --env-file .env stop web queue queue-ai scheduler reverb ssr
docker compose --env-file .env up -d pgsql valkey typesense
docker compose --env-file .env exec -T pgsql sh -c 'pg_restore -U "$POSTGRES_USER" -d "$POSTGRES_DB" --clean --if-exists --no-owner' < backups/media-manager-YYYY-MM-DD.dump
docker compose --env-file .env run --rm --no-deps -T web tar xzf - -C /app/storage < backups/app-storage-YYYY-MM-DD.tgz
docker compose --env-file .env up -d
docker compose --env-file .env exec web php artisan scout:import 'App\Models\IndexedSeries'
docker compose --env-file .env exec web php artisan scout:import 'App\Models\IndexedMovie'up -d runs the migrate service first, so a dump from an older release is migrated forward automatically.
docker compose --env-file .env ps ssr
docker compose --env-file .env exec ssr php artisan inertia:check-ssrThe Artisan command should print Inertia SSR server is running. You can also confirm that an initial Inertia response contains server-rendered markup; replace the URL with the deployment's public login URL:
curl -fsSL https://media.example.com/login | grep 'data-server-rendered="true"'The web service deliberately does not depend on SSR health. If the renderer is starting, restarting, or unavailable, Inertia logs the rendering failure and falls back to the normal client-rendered application.
Set INERTIA_SSR_ENABLED=false in docker/production/.env, recreate the web container so its cached configuration uses the new value, and stop the renderer:
docker compose --env-file .env up -d --force-recreate web
docker compose --env-file .env stop ssr| Variable | Purpose |
|---|---|
APP_KEY |
Generated by artisan key:generate. Encrypts every stored credential — back it up with the database (see Backups and restore) |
APP_URL |
Public URL — webhook URLs are built from this |
APP_PORT |
Host port Sail binds to (default 81) |
DB_* |
Postgres (Sail-managed) |
REVERB_APP_ID / REVERB_APP_KEY / REVERB_APP_SECRET |
WebSocket server credentials |
VITE_REVERB_* |
Mirrored to the browser (already defined as ${REVERB_*} in .env.example) |
The dev stack also forwards: FORWARD_DB_PORT (Postgres, default 5433), FORWARD_VALKEY_PORT (6380), FORWARD_MAILPIT_PORT (1026), FORWARD_MAILPIT_DASHBOARD_PORT (8026), FORWARD_TYPESENSE_PORT (8109).
Two ways to configure — pick whichever fits. The admin UI is the normal path for production; env+seeder is faster for local dev and CI.
Set any subset in .env. Each service follows the same four-variable pattern:
SONARR_URL=https://sonarr.example.com
SONARR_API_KEY=...
SONARR_WEBHOOK_TOKEN= # optional — auto-generated if blank
SONARR_NAME= # optional — defaults to "Sonarr"Supported prefixes: SONARR, RADARR, BAZARR, EMBY, SEERR, PROWLARR, SABNZBD. (Whisparr is not covered by the seeder — add it through the admin UI.)
Then seed:
vendor/bin/sail artisan db:seed --class=ServiceConnectionSeeder.env is authoritative: if a connection of the same type already exists, the seeder updates it to match the env values (so a stale factory row can't outvote your config). Services with no URL/API_KEY set are skipped. The seeder uses getenv() (not env()) so putenv()-style overrides from tests propagate.
Sign in as admin → Admin → Connections → Add Connection. Hit "Test" before saving to verify the URL + API key, then save. The edit form shows the per-connection webhook token (rotate it by clearing the field and saving) and per-type extras:
- Sonarr/Radarr — subtitle-check tags and (Sonarr) per-root-folder library types (
anime/tv), used by media replacement - Whisparr — version select (
v2Eros/series-based orv3movie-based) - Bazarr — mapping to the Sonarr/Radarr connections it manages (required for subtitle cases)
- SABnzbd — hidden categories, plus a generated notification script (see Webhooks)
- Prowlarr — read-only indexer list with per-indexer test buttons
Connections can also set an external_url, used when the UI links out to the service.
For Sonarr, Radarr, Prowlarr, and Whisparr, the Configure webhook button registers MediaManager's webhook endpoint in the remote service automatically.
Three sign-in paths are available. Enable whichever combination you want:
- Local email/password (Fortify, with optional two-factor auth) — always available. Self-registration (
/register) is only open for the bootstrap admin (no users yet); afterwards it 404s unlessMEDIAMANAGER_REGISTRATION_ENABLED=true. Users can be created via the invite flow (admin → Users → Invite) which emails a signed/invite/{user}/acceptlink; the invitee sets a password on their first sign-in via thepassword.setmiddleware gate.artisan users:createcreates a user directly. - Authentik SSO — set
AUTHENTIK_CLIENT_ID,AUTHENTIK_CLIENT_SECRET,AUTHENTIK_BASE_URL, and (usually) leaveAUTHENTIK_REDIRECT_URIas the default${APP_URL}/auth/authentik/callback. - Emby credentials — set
EMBY_URL+EMBY_API_KEY(via the connection form or seeder). Users sign in with their Emby username/password; MediaManager brokers the auth via the Emby connection.
Role model (see App\Enums\UserRole):
| Role | Access |
|---|---|
admin |
Full access: connections, approval rules, user management, AI chat and settings |
member |
Browse + edit media, approve action requests, request subtitle operations |
viewer |
Read-only dashboard, sees only their own Emby activity |
Checks are hierarchical via UserRole::isAtLeast() — a route gated by role:member also admits admins.
Every notification resolves its delivery per user across four channels: database (in-app inbox), broadcast (live toast), mail, and ntfy (push). Defaults are database + broadcast on, mail + ntfy off; users tune a channel × severity matrix per notification type under Settings → Notifications (service warnings, AI budget warnings, service updates, media-replacement outcomes), with a test-send button. The inbox lives at /notifications.
For ntfy, set the server and optional access token:
NTFY_SERVER=https://ntfy.sh # or your self-hosted instance
NTFY_TOKEN=Each user sets their own topic on the preferences page. Delivery is best-effort — failures are logged, never thrown.
Gated behind MEDIAMANAGER_AI_ENABLED. When disabled, /ai/* routes 403, all AI pages are hidden, and the autonomous agents no-op. Providers are configured through laravel/ai (config/ai.php) — set an API key for whichever you use (OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, GROQ_API_KEY, MISTRAL_API_KEY, …). Defaults:
MEDIAMANAGER_AI_ENABLED=true
MEDIAMANAGER_AI_MODE=executive # or 'advisory'
MEDIAMANAGER_AI_MODEL=gpt-5-mini # any configured provider model
MEDIAMANAGER_AI_TITLE_MODEL=gpt-5.4-nano # cheap model for chat titles ('auto' = provider's cheapest)
MEDIAMANAGER_AI_CHAT_TIMEOUT=120
MEDIAMANAGER_AI_CHAT_MAX_ATTACHMENTS=3 # files per chat message and per benchmark case turn (1-10)
OPENAI_API_KEY=sk-...Env vars are only the boot defaults — mode, model, budgets, reasoning level, failover provider chain, and more are editable at runtime under Admin → AI Settings (stored in app_settings).
Four agents live under app/Ai/Agents/:
MediaAgent— the interactive chat assistant (admin-only,/ai/chat). ~45 tools acrossapp/Ai/Tools/{Arr,Bazarr,Emby,Seerr,Prowlarr,System,Tmdb,Trakt,Workflow,PriceFetcher}/; Sonarr/Radarr/Whisparr share theArrtools via aserviceparameter. Prowlarr/Bazarr/TMDB/Trakt tools are only exposed when the matching connection or API key exists.DecisionAgent— optional autonomous agent that runs once per inbound webhook event (opt-in viaMEDIAMANAGER_DECISION_AGENT_ENABLED+ Admin → Decision Agent). It can propose actions and resolve stuck imports; every proposal is anActionRequestand each run is recorded as anAgentDecisionaudit row. A run is bounded by the admin's run time limit (30–210 s, default 210): each step is cut to the time left, and a run that reaches the limit is recorded as failed.PriceFetcherAgent— re-verifies model prices against first-party pricing pages.TitleAgent— names chat conversations.
Subtitle escalations are decided in code, not by an agent: SubtitleAdvisorDecider (see subtitle automation) queues the case's unique automatic replacement candidate when one exists, at no model cost.
Every tool declares a Risk tier:
Read/SafeWrite— execute directly and return their result as JSON.Destructive— in executive mode they're routed throughActionOrchestratorand queued as anActionRequest(the agent cannot bypassrequires_approval); in advisory mode they're refused with an error envelope, and every otherActionRequestqueues as Pending regardless of config.
For multi-step intents the chat agent calls ProposeWorkflowTool to write an AiProposedWorkflow row instead of firing each step individually. The chat UI surfaces an Approve/Decline confirm card; on approval the agent executes the steps as a batch (each step still funnels through the same approval rules).
TMDB and Trakt integrations are optional. Set TMDB_API_KEY (v4 Read Access Token) and TRAKT_CLIENT_ID (just the OAuth client id — no full OAuth flow) to enable the recommendation tools. When unset, the agent falls back to Seerr discovery.
Conversation history is healed automatically before each request — orphaned tool calls (e.g. from an interrupted prior turn) get stub results inserted so providers don't 400 on the malformed transcript.
Every agent invocation is recorded as an AiUsageRecord (tokens, snapshot of the model's per-Mtok rates, tool-call count) and surfaced under Admin → AI Usage (with CSV export). Supporting machinery, all managed in the admin UI:
- Budgets — soft/hard monthly USD caps. The soft cap notifies admins once per month; the hard cap makes agents refuse to run.
- Model price catalog —
ai_model_pricesrows per provider+model, refreshed weekly from the Models.dev feed (opt-in:AI_PRICING_MODELS_DEV_ENABLED=true) and re-verified monthly byPriceFetcherAgentagainst first-party pricing pages, with anomaly guards and per-row price locks. Manual run:artisan ai:refresh-prices [--verify] [--dry-run]. - Free usage pools — named daily/weekly/monthly token quotas shared by models (e.g. a provider's free tier), subtracted from reported cost; configurable overflow behaviour.
- Rate limits — per-model request/token limits per minute/hour/day, shown as used-vs-limit on the usage page (reporting only, not enforced).
When AI is enabled, library items are embedded (256-dim vectors from the configured embeddings provider — OpenAI's text-embedding-3-small by default) and stored in Typesense for meaning-based search via the chat assistant, with optional reranking when a reranking provider (Cohere, Jina) is configured. New/changed items embed automatically through a queued job; backfill an existing library with:
php artisan ai:embed-library --missing-onlyMediaManager can replace an already-imported episode or movie with a better release — primarily to fix missing or wrong subtitles — using a grab-before-delete pipeline that suspends the *arr's own monitoring, grabs the chosen release, only then deletes and blocklists the old file, sweeps any competing grab the *arr queued in parallel, and verifies the import via webhooks. Every replacement is an ActionRequest of type replace_media_file (requires approval by default) and a durable MediaReplacementAttempt row; stalled attempts are flagged needs_attention by an hourly reconciler and notify admins.
Three things can propose a replacement:
- The AI chat assistant — inspect a file, list ranked candidates, replace (manually picked or automatic candidate).
- The automatic subtitle check — on every Sonarr/Radarr import webhook, items carrying a configured *arr tag are audited against the required subtitle languages; a miss dispatches a replacement request. Configure under Admin → AI Settings → Media replacement (global + per-scope languages, confidence threshold, season-pack policy, attempt limits/cooldown, per-scope guidance rules like "this release group guarantees subs") and per-connection (subtitle-check tags, Sonarr root-folder scopes for anime/tv classification).
- The subtitle advisor — see below.
Bazarr subtitle cases close the loop for media whose subtitles Bazarr should be able to fetch. Opt-in under Subtitles → Admin → Subtitle automation (enabled is off by default). The reconciler (every 5 minutes, plus Bazarr Apprise notifications for instant nudges) discovers media missing required subtitles and tracks each as a SubtitleCase: a grace period first (Bazarr usually fixes things itself), then spaced provider probes that queue bazarr_download_best action requests for eligible candidates, and — after repeated empty probes — escalation to SubtitleAdvisorDecider, which inspects the case and queues a media replacement when the automatic-selection rules offer a unique candidate, or parks the case as needs_review and notifies admins. Cycle sizes, grace hours per scope, probe spacing, escalation thresholds, and advisor concurrency are all tunable on the same page.
The Subtitle Center (/subtitles, sidebar "Subtitles") is viewer-visible: Overview, Missing, Library, and History tabs project Bazarr's inventory; the Escalations tab lists cases (members can re-run the advisor; admins can filter by status). Members can request manual subtitle operations (download best/exact, upload, delete, sync, translate, scan) — each becomes a bazarr_* action request gated by Action Rules and by Bazarr's advertised capabilities, and carries a file fingerprint so a stale page can't act on a replaced file.
Slow reads to Sonarr / Radarr / Whisparr / Bazarr / Seerr / Prowlarr / SABnzbd / TMDB / Trakt / anime sources pass through app/Cache/Services/{Service}Cache.php, backed by Valkey (Redis-compatible) with tagged invalidation. TTLs are configurable via MEDIAMANAGER_CACHE_TTL_{LIST,ENTITY,METADATA} (defaults: 300s / 600s / 1800s; seasonal-anime data has its own longer TTLs). Webhook handlers and local action executors call bustAll() to evict per-connection tags so writes feel immediate; TTL alone covers third-party providers (TMDB/Trakt) which we cannot invalidate on demand. A presence-aware warmer (services:warm-caches, every minute) refreshes near-expiry entries while users are active and no-ops otherwise (browser heartbeat → MEDIAMANAGER_PRESENCE_*). Cache driver is set via MEDIAMANAGER_CACHE_STORE (default redis) — independent of Laravel's global CACHE_STORE. Tests use the array driver via tests/Pest.php.
Point each service's outbound webhook at:
POST {APP_URL}/api/webhooks/{service}/{connection_id}
Header: X-Webhook-Token: {token}
Replace {service} with sonarr, radarr, whisparr, prowlarr, sabnzbd, emby, or seerr, and {connection_id} with the numeric ID from the Connections admin page. The token is per-connection (visible in the Edit form). The VerifyWebhookToken middleware rejects any request with a missing/mismatched token or a service-type that doesn't match the connection. For Sonarr, Radarr, Whisparr, and Prowlarr the admin UI can register the webhook automatically ("Configure webhook").
Two services deliver differently:
- SABnzbd has no native HTTP webhook — the connection edit page generates a Python notification script (stdlib only, token embedded) to drop into SABnzbd's
scripts/folder and select under Settings → Notifications. - Bazarr posts to a dedicated endpoint (
POST {APP_URL}/webhooks/bazarr/{connection_id}) via Apprise — the Subtitles → Admin page shows the exactjson://config URI to paste into Bazarr's notification settings. These events are treated as reconciliation hints rather than a typed event vocabulary.
Webhook delivery is logged as a WebhookEvent (browseable under Admin → Webhook Log, with a 5-minute payload dedupe), then processed asynchronously by ProcessWebhookEvent (requires the queue worker — in dev, the Sail queue service or vendor/bin/sail artisan queue:listen --queue=actions,webhooks,default,ai,maintenance). Each client IP may deliver up to MEDIAMANAGER_WEBHOOK_RATE_LIMIT webhooks per minute (default 300) and bodies above MEDIAMANAGER_WEBHOOK_MAX_PAYLOAD_KB (default 1024) are refused with 413. The 5-minute dedupe also holds when webhook capture is off. A ?token= query parameter is never stored with the event.
Sonarr — Test, Grab, Download, Rename, SeriesAdd, SeriesDelete, EpisodeFileDelete, ManualInteractionRequired, Health, HealthRestored, ApplicationUpdate
Radarr — Test, Grab, Download, Rename, MovieAdded, MovieDelete, MovieFileDelete, ManualInteractionRequired, Health, HealthRestored, ApplicationUpdate
Whisparr — the union of the Sonarr and Radarr sets (handles both v2 series-shaped and v3 movie-shaped payloads)
Prowlarr — Test, Health, HealthRestored, ApplicationUpdate
SABnzbd (from the notification script) — complete, failed, startup, pause, resume, queue_done, warning, error, disk_full
Emby — playback.start, playback.unpause, playback.pause, playback.stop, item.markplayed, library.deleted
Seerr — TEST_NOTIFICATION, MEDIA_PENDING, MEDIA_APPROVED, MEDIA_AUTO_APPROVED, MEDIA_DECLINED, MEDIA_AVAILABLE, MEDIA_FAILED, ISSUE_CREATED, ISSUE_COMMENT, ISSUE_RESOLVED, ISSUE_REOPENED
Unknown event types are logged and skipped — they don't error out the webhook call.
Some webhook events dispatch ActionRequests via ActionOrchestrator:
| Trigger | Target action | Default behaviour |
|---|---|---|
Emby library.deleted on a Series (payload has ProviderIds.SonarrSeriesId) |
delete_series on Sonarr |
Requires approval |
Emby library.deleted on a Movie (payload has ProviderIds.RadarrMovieId) |
delete_movie on Radarr |
Requires approval |
Sonarr Download / SeriesDelete |
emby_library_scan |
Auto-execute |
Radarr Download / MovieDelete |
emby_library_scan |
Auto-execute |
Seerr MEDIA_AVAILABLE |
emby_library_scan |
Auto-execute |
Other webhook side effects: Sonarr/Radarr Download also queues the automatic subtitle check; ManualInteractionRequired feeds the stuck-import counter (sidebar badge) and, if the decision agent is enabled, can lead to resolve_manual_import / remove_stuck_download proposals; SABnzbd events refresh download counts; Bazarr notifications trigger subtitle-case reconciliation.
Approval behaviour is editable at /actions/rules (admin only). Rows come from ActionTypeConfigSeeder; toggle requires_approval / is_enabled per type. In advisory AI mode every request queues as Pending regardless of these flags.
The scheduler runs as its own container in both the dev and production stacks (schedule:work) — no host cron needed. Registered schedules (see routes/console.php; all withoutOverlapping with an explicit lock expiry, and the scheduler container clears stale locks when it starts):
| Cadence | Task |
|---|---|
| every minute | services:warm-caches — presence-aware external-API cache warmer |
| every 5 min | services:check-health, dashboard:broadcast-stats, bazarr:reconcile, sabnzbd:poll-history, sabnzbd:refresh-download-counts, library:refresh-intervention-count, statistics:collect-gauges |
| hourly | media-replacement:reconcile, actions:reconcile-stuck, statistics:aggregate (at :05), prune expired subtitle uploads |
| daily | services:check-versions, app:check-version, ai:prune-proposed-workflows, statistics:prune (04:30), retention pruning (03:00) for webhook events / activity logs / Emby activity / AI usage + tool invocations / agent decisions / price-refresh runs / replacement attempts / resolved+superseded subtitle cases / terminal action requests, failed-job (03:10) and job-batch (03:20) pruning, notification pruning, search-index reconciliation (03:30), daily library gauge snapshot (04:00), ai:prune-conversations (03:15; conversation retention is opt-in, the orphaned-attachment sweep always runs) |
| weekly | ai:refresh-prices (Models.dev sync), anime id-mapping sync |
| monthly | ai:refresh-prices --verify (first-party price re-verification) |
Retention windows are configurable via MEDIAMANAGER_RETENTION_*_DAYS (0 disables pruning for that table): webhook events 90, activity logs 180, audit log 365, Emby activity 365, notifications 90, AI usage 400, AI tool invocations 90, agent decisions 180, replacement attempts 90, action requests 180, subtitle cases 180, price-refresh runs 90, failed jobs 30, job batches 7, agent conversations 0 (kept). Only finished rows are pruned; an action request is kept while a subtitle case, attempt, upload or replacement attempt still refers to it, and dismissed/handled subtitle cases are never pruned. The audit log (admin changes shown in the Activity log's Audit category, admins only) prunes on its own window, MEDIAMANAGER_RETENTION_AUDIT_LOGS_DAYS, independently of ordinary activity.
Upstream version checks map service types to GitHub repos: Sonarr → Sonarr/Sonarr, Radarr → Radarr/Radarr, Whisparr → Whisparr/Whisparr, Prowlarr → Prowlarr/Prowlarr, Bazarr → morpheus65535/bazarr, Seerr → seerr-team/seerr, Emby → MediaBrowser/Emby.Releases (closed-source; canonical release mirror). SABnzbd has no version check.
statistics:aggregate rolls durable event tables into pre-aggregated stat_rollups buckets (hour + day granularity); statistics:collect-gauges samples live state (disk, queue depth, sessions, subtitle cases). The Statistics page (all roles) shows plays, finishes, watch hours, downloads, the request funnel, watch leaderboards, top titles, and an hour heatmap over a selectable window; Admin → Statistics adds webhooks, action/approval rates, agent decisions, disk-free and queue-depth series, and AI cost. Backfill history from existing tables with artisan statistics:backfill.
A Prometheus scrape endpoint is available at /metrics, gated by a bearer token:
METRICS_ENABLED=true
METRICS_TOKEN= # empty = deny all
METRICS_ALLOWED_IPS=Operational gauges for alerting:
| Gauge | Meaning |
|---|---|
mediamanager_failed_jobs{queue} |
failed jobs per queue (pruned after 30 days); a queue name outside actions/webhooks/default/ai is folded into queue="other" to keep the label bounded |
mediamanager_job_queue_size{queue,state} |
pending / delayed / reserved jobs on actions, webhooks, default, ai |
mediamanager_heartbeat_age_seconds{component} |
seconds since scheduler / queue:<lane> last reported; absent until the first heartbeat |
mediamanager_webhook_oldest_pending_age_seconds |
age of the oldest webhook not yet processed (0 when none); backed by a partial index on webhook_events(created_at) WHERE processed_at IS NULL |
Each gauge's value closure is isolated: if its dependency (Redis, cache, DB) throws, that gauge exports no series for the scrape and the failure is logged, instead of 500ing the whole endpoint.
- alert: MediaManagerWorkerStalled
expr: mediamanager_heartbeat_age_seconds > 600 or absent(mediamanager_heartbeat_age_seconds{component="scheduler"})
for: 5m
- alert: MediaManagerWebhookBacklog
expr: mediamanager_webhook_oldest_pending_age_seconds > 900
for: 5mFixtures live at database/fixtures/webhooks/{service}/{event}.json. The webhook:simulate command posts them at your own webhook endpoint using the active connection's token.
# list available fixtures
vendor/bin/sail artisan webhook:simulate --list
# fire an Emby playback-start against the first active Emby connection
vendor/bin/sail artisan webhook:simulate emby playback.start
# dry-run: print payload + target URL without sending
vendor/bin/sail artisan webhook:simulate sonarr download --dry-run
# override a payload field with dot-notation
vendor/bin/sail artisan webhook:simulate emby library.deleted \
--set 'Item.ProviderIds.SonarrSeriesId=42'
# target a specific connection id
vendor/bin/sail artisan webhook:simulate emby playback.stop --connection=3After firing, the command prints the resulting WebhookEvent and any ActionRequests that were created. Add your own fixtures under database/fixtures/webhooks/{service}/{event}.json — shipped fixtures cover a subset of events; extend as needed.
vendor/bin/sail artisan demo:fake-webhooks # curated fake webhooks across services (demo the realtime UI)
vendor/bin/sail artisan demo:fake-actions # fake ActionRequests in various states
vendor/bin/sail artisan emby:debug-sessions # what Emby /Sessions returns (--raw, --query-auth)
vendor/bin/sail artisan emby:backfill-history # import historical Emby watch data
vendor/bin/sail artisan typesense:seed # seed the search index from Sonarr/Radarr
vendor/bin/sail artisan users:create # create a user with a chosen roleRun the full local gate before every commit. It runs Pint, Rector (dry run), Larastan, Vite+ check (Oxfmt and Oxlint), vue-tsc and the Unit and Feature suites in parallel, the same checks as CI apart from the browser suite:
vendor/bin/sail composer testRun single suites or filters directly:
vendor/bin/sail artisan test --compact
vendor/bin/sail artisan test --compact --filter='Media\\Series'The suite covers auth flows, media controllers, webhook ingest and handlers, the action orchestrator + executor, media replacement, the Bazarr subtitle pipeline, real-time events, AI tools and agents, scheduled commands, and model behaviour. Browser tests run with composer test:browser (boots Inertia SSR first); pass Pest flags after --, e.g. composer test:browser -- --shard=1/4 or --filter=Calendar.
Order matters — rector first (structural refactors), then pint (formatting):
vendor/bin/sail bin rector
vendor/bin/sail bin pint --dirty --format agentStatic analysis (Larastan, level 7, no baseline: every error is fixed in code; CI runs it with rector --dry-run in the PHP static analysis job):
vendor/bin/sail composer analyseOther useful checks:
vendor/bin/sail pnpm run check:fix # vp check --fix: Oxfmt, then Oxlint fixes
vendor/bin/sail pnpm run check # vp check: format check and lint
vendor/bin/sail pnpm run types:check # vue-tsc --noEmit
vendor/bin/sail pnpm run build # vp build && vp build --ssrRegenerate frontend typings after changing Laravel routes, models, enums, or form requests:
vendor/bin/sail artisan wayfinder:generate --with-form
vendor/bin/sail artisan typefinder:generateresources/js/actions/, resources/js/routes/, and resources/js/typefinder/ are all auto-generated — don't edit by hand. Wayfinder's folders are gitignored. resources/js/typefinder/ is committed: regenerate it in the same commit as the backend change, and tests/Feature/GeneratedTypesTest.php fails when it is stale or when generation warns (a skipped class has no type).
Data flow for an incoming webhook:
External service (Sonarr / Radarr / Whisparr / Prowlarr / SABnzbd / Emby / Seerr)
| POST /api/webhooks/{service}/{connection_id}
v
VerifyWebhookToken middleware (rejects on token mismatch / wrong service type)
|
v
WebhookController::handle (persists WebhookEvent, dedupes, dispatches ProcessWebhookEvent)
|
v [queue]
ProcessWebhookEvent job (resolves the right handler)
|
v
{Service}WebhookHandler (writes ActivityLog, calls ActionOrchestrator, feeds trackers)
|
v
ActionRequest (pending -> approved -> executing -> completed/failed)
|
v [queue]
ExecuteActionRequest job (delegates to ActionExecutor)
|
v
{Service}Actions class (typed HTTP client wrapper -> {Service}Client)
(Bazarr notifications take a parallel path: POST /webhooks/bazarr/{connection_id} → BazarrNotificationController → subtitle-case reconciliation jobs.)
Real-time fan-out is via Laravel Reverb on private channels (see routes/channels.php):
| Channel | Who | Carries |
|---|---|---|
App.Models.User.{id} |
own user | per-user notifications |
services |
member+ | service health / connection / version events |
members.actions |
member+ | action request created/status changed |
members.sabnzbd |
member+ | download finished |
emby.activity |
authenticated | Emby playback updates |
dashboard |
authenticated | dashboard stats, webhook activity, download counts, intervention + subtitle-case changes |
activity |
authenticated | activity log entries |
admin.ai-prices |
admin | price-refresh progress |
ai-chat.{userId}.{conversationId} |
owner | streaming agent steps |
Frontend composables in resources/js/composables/ subscribe to these (useServiceHealth, useEmbyActivity, useDashboardStats, useNotifications, useNavCounts, useAiChat, …) on top of the lower-level useWebSocket.
| Path | Contents |
|---|---|
app/Http/Controllers/{Admin,Auth,Media,Emby,Bazarr,Library,Prowlarr,Sabnzbd,Monitoring,Actions,AI,Settings,Webhooks}/ |
Feature-scoped controllers |
app/Services/{Arr,Sonarr,Radarr,Whisparr,Emby,Seerr,Prowlarr,Sabnzbd,Bazarr,Anime,Tmdb,Trakt}/ |
Typed HTTP clients + per-service webhook handlers + Actions classes |
app/Services/Actions/ |
ActionOrchestrator (dispatch) and ActionExecutor (run) |
app/Services/MediaReplacement/ |
Replacement pipeline: inspector, candidate finder/ranker, tracker, sweeper, subtitle auditor |
app/Services/{Statistics,ServiceMetrics,DashboardMetrics,Dashboard}/ |
Rollup aggregation + dashboard/stats repositories |
app/Services/{Notifications,Search,Library,AiBudget,AiUsage,GitHub,Webhook}/ |
Notification routing, semantic search, intervention counter, AI cost machinery, release checks |
app/Ai/{Agents,Tools,Decision,SubtitleAdvisor,Storage}/ |
Agents, their bound tools, and conversation storage |
app/Settings/ |
Typed runtime settings objects backed by the app_settings table |
app/Cache/Services/ |
Per-service external-API caches |
app/Jobs/ |
Queue jobs (webhook processing, action execution, reconciliation, sweeps, embedding, …) |
app/Events/ / app/Notifications/ |
Broadcast events and user notifications (incl. the ntfy channel) |
app/Http/Resources/ |
Typed API resources (picked up by typefinder) |
app/Enums/ |
Roles, service types, action/health/AI/subtitle/replacement enums |
resources/js/pages/ |
Inertia Vue pages, subdirs mirror controller namespaces |
resources/js/composables/ |
Echo subscriptions + shared client state |
resources/js/typefinder/ |
Auto-generated TS types |
resources/js/{actions,routes}/ |
Auto-generated Wayfinder route helpers |
database/fixtures/webhooks/ |
JSON fixtures for webhook:simulate |
- Follow existing patterns — check sibling files before inventing new structure
- Every change needs a test (Pest feature tests preferred); run the suite before committing
- Run
rectorthenpint --dirtybefore committing PHP changes - Regenerate Wayfinder + Typefinder output after backend changes that touch routes, models, enums, or form requests
- Don't edit
resources/js/actions/,resources/js/routes/, orresources/js/typefinder/by hand — regenerate them; commit the regeneratedresources/js/typefinder/with the change
MIT — see composer.json.