# Backend 1 handoff (content system, admin panel)

## What exists

- Content overlay: `App\Support\Content\ContentRepository` (API unchanged: `page()`, `global()`, `definition()`, `forget()`; added `overrides()`, `keys()`, `flush()`). DB overrides in `content_values`, SEO overrides in `page_meta` (surface through `PageContent::meta('title'|'description'|'og_image'|'robots'|'canonical')`). Falls back to file defaults when tables are missing.
- `setting()` reads `App\Support\Content\SettingsRepository` (bound as `site.settings`, method `get($key, $default)`, also `flush()`).
- Event `App\Events\ContentChanged($type, ?$pageKey)` fires after every save/delete of content values, page meta, settings, redirects and media. `$type` is one of `content`, `page_meta`, `setting`, `redirect`, `media`; `affectsAllPages()` is true for `_global` or null.
- `App\Models\Redirect`: `from_path` (normalised, leading slash), `to_url`, `status_code` (301/302/307/308/410), `is_active`, `hits`, plus `last_hit_at`, `note`. Helper `$redirect->recordHit()` increments `hits` without firing events or logging.
- Admin panel config: `config/admin.php` (new file, created by Backend 1, read it with `config('admin.path')` etc.).
- Commands: `php artisan site:create-admin` (interactive or `--name --email --password`, `--update` to reset an existing user), `php artisan site:media-sync` (registers existing `public/media` images/videos in the media library; safe to re-run).

## Requests

### Backend 2
1. Please add to `.env.example`:
   ```
   ADMIN_PATH=admin            # e.g. a less guessable path in production
   ADMIN_2FA_ENABLED=true
   ADMIN_2FA_REQUIRED=false    # set true in production once the owner has set up 2FA
   ADMIN_SESSION_TIMEOUT=30    # minutes of inactivity
   ADMIN_LOGIN_MAX_ATTEMPTS=5
   ADMIN_LOGIN_DECAY_MINUTES=15
   ADMIN_MAX_IMAGE_KB=5120
   ADMIN_MAX_VIDEO_KB=51200
   ```
2. `robots.txt` / any admin exclusions should use `config('admin.path')` (your middleware already does).
3. Admin uploads are written to `public/media/uploads/Y/m/` and served as `/media/uploads/...`; please make sure `.htaccess`/nginx never execute scripts in `public/media` (only images/videos are accepted, names and extensions are generated server-side, but defence in depth).
4. Tests that call public pages need absolute URLs or a `prepareUrlForRequest` override (the stock test client trims the trailing slash) — you already handle this in `UsesSeoFixtures`.

### Project manager (deployment and admin guide)
1. Deploy steps: `php artisan migrate --force`, then `php artisan site:create-admin`, then `php artisan site:media-sync`. `public/media/uploads` must be writable by the web server.
2. PHP limits for video uploads: `upload_max_filesize` and `post_max_size` of at least 55M (local PHP is 2M/8M, so local video uploads above 2 MB fail before reaching Laravel).
3. Admin guide points: Pages > Edit (fields grouped by section, "Edited" marker and "Reset to original" per field, SEO tab with length hints), Media library (upload, copy address), Site settings, Redirects, Users (Reset 2FA), Activity log (read-only), Profile (set up two-factor authentication). Saving an unchanged value or the original value stores nothing.

### Frontend 1 / Frontend 2
- `url` fields must hold a path starting with `/`, `#anchor`, `http(s)://...`, `mailto:` or `tel:`; anything else (e.g. `javascript:`) is refused when the owner saves. All current content files pass (checked by `tests/Feature/Admin/RealContentFilesTest.php`).
- `image`/`video` values must be `/media/...` paths or http(s) URLs.
- Rich text saved from the admin is sanitised to basic formatting and links (p, br, strong/b, em/i, u, s, sub, sup, lists, blockquote, h2-h6, hr, span, div, small, mark, code, a[href,title,target,rel]); classes and inline styles are removed. Style rich text through the wrapping element, not classes inside the HTML.
