# H2 Hero module backend: code summary Built 2026-11-16 on `feature/hero-module`. The whole CI solution filter is green (Core 912, Hero 100, Offerings 212, Availability 171, Identity 145, Api 46, Contact 349, Master 61); Api and Contact tests ran against MariaDB, so the new migration is proven on a real database and `HasPendingModelChanges` is false. | Area | What | |---|---| | Project | `SlpModularCms.Modules.Hero` (+ `.Tests`), in `SlpModularCms.sln` (Application/Modules and Tests/Modules) and `SlpModularCms.Ci.slnf`; referenced by `Api`, `Api.SlpSoftware` and `Api.AndreaSlopFotografie` (not the slave); `SiteContractTests` updated | | Data | `HeroDbContext` with `Heroes`, `HeroSlides`, `HeroImages`, `HeroRetiredFiles`; migration `InitialCreate` generated with the EF tools; slides restrict deletion of an image in use; variants stored as a JSON list | | Rules | `HeroSaveRequest.Validate` (title 200 characters and 5 lines, tagline 120, lead 600, display, 0 to 2 buttons both-or-neither with label 50 and target 500, schedule order, slides with an image and alt text or the decorative flag; no administrator limit on slides), `ButtonTargetValidator` (anchor, path or https only), `HeroText.Clean` (plain text, control characters and U+2028/9 removed) | | Services | `HeroService` (whole-hero save in one transaction, stable slide ids, cache invalidation), `PublicHeroService` + `HeroMapping` (live when switched on, inside the schedule and with a title; only active slides with an image and alt text or decorative; ordered; safety ceiling `Hero:MaxPublishedSlides` 50; `src` is the largest wide WebP), `HeroImageService` (upload: guard, SHA-256 identity so the same photo is one image, metadata removed from the stored original, all variants cut around the focus, atomic set write; focus change: new set and addresses, old set retired; delete refused while in use; room check on size and free space), `HeroMediaCleanup` + `HeroMediaCleanupService` (daily: unused images, retired files after 7 days unless used again, unknown old sets) | | API | `GET /api/v1/hero` (anonymous, public-site endpoint, `hero-public` limit, 204 when none, `max-age=60`), `GET /hero/all` and `PUT /hero` (AdminOnly), `POST /hero/images` (multipart, 12 MB body limit, `hero-upload` per user, rejection codes mapped to 400, 413, 429, 503), `PUT /hero/images/{id}/focus`, `DELETE /hero/images/{id}` (409 while in use) | | Texts | `HeroTexts` and `Texts/nl.json`, `en.json` (validation, rejection and storage messages), audited by `TextAudit` | | Registration | `HeroModule` adds the DbContext, texts, options, `AddCmsMediaArea("hero")`, `AddMagickImageProcessor`, services and the clean-up service; runs its migration at start-up | | Tests | validators and rules (including property tests for the target validator and text cleaning), mapping (schedule matrix, ceiling, decorative, order, focus per ratio, JSON shape), the image service on the real library and a temporary media directory (variants, no upscaling, metadata, duplicates, focus cuts the chosen side, retire, delete rules, refused and truncated uploads store nothing, full storage), the service (create, replace keeping slide ids, reorder, decorative and inactive, bad references, plain text, text-only hero with two buttons, schedule by clock, ceiling), the clean-up (retention, reuse, unattached, in use, unknown sets) and, on the master host with MariaDB, capabilities, 204, authorisation of all management routes, 404 of the media endpoint and migration-matches-model | | OpenAPI | `openapi/slpsoftware.v1.json` regenerated (new Hero paths and schemas) | | Publish | a self-contained win-x64 publish of the ASF host contains only `Magick.Native-Q8-x64.dll` and the Hero assemblies | ## Notes - A hero without slides is valid and live (the SLS hero is text only); the HTML region for ASF is empty without a usable slide (their rule), so the baked hero stays. - `Media:Directory` is not committed anywhere; each host sets it in its environment (see the infrastructure design). - Not yet: the HTML injection and the data block (H4), the admin screens (H5), the seed, docs and smoke test (H6).