# Component Dependencies — Master CMS Module ## Package-Level Dependency Diagram ```mermaid graph TD Api["SlpModularCms.Api\n(shell)"] Master["SlpModularCms.Modules.Master\n(NEW)"] Availability["SlpModularCms.Modules.Availability\n(EXTENDED)"] Core["SlpModularCms.Core\n(unchanged)"] Frontend["Frontend\n(EXTENDED)"] SlaveCms["Slave CMS\n(another SlpModularCms instance)"] Api --> Master Api --> Availability Api --> Core Master --> Core Availability --> Core Frontend -->|"REST /api/v1/*"| Api Master -->|"HTTP slave API calls"| SlaveCms SlaveCms -->|"HTTP pull master status"| Master classDef new fill:#9ae6b4,stroke:#2f855a,stroke-width:2px,color:#000 classDef extended fill:#FFC107,stroke:#F57F17,stroke-width:2px,color:#000 classDef unchanged fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000 classDef external fill:#FC8181,stroke:#C53030,stroke-width:2px,color:#000 class Master new class Availability,Frontend extended class Api,Core unchanged class SlaveCms external ``` Text alternative: Master and Availability modules both depend on Core; Api depends on all three; Frontend calls Api REST; Master calls Slave CMS via HTTP and Slave pulls back. --- ## Master-Backend Component Dependencies ```mermaid graph TD Ctrl["CmsInstanceController"] Svc["CmsInstanceService"] Repo["CmsInstanceRepository"] DbCtx["MasterDbContext"] SlaveClient["SlaveApiClient"] BgSvc["IntegrityCheckBackgroundService"] Opts["MasterModuleOptions\n(IOptions)"] CmsEntity["CmsInstance\n(entity)"] Ctrl --> Svc Svc --> Repo Svc --> SlaveClient Svc --> Opts Repo --> DbCtx Repo --> CmsEntity DbCtx --> CmsEntity BgSvc --> Svc BgSvc --> Opts classDef controller fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000 classDef service fill:#9ae6b4,stroke:#2f855a,stroke-width:2px,color:#000 classDef data fill:#FFC107,stroke:#F57F17,stroke-width:2px,color:#000 classDef infra fill:#CE93D8,stroke:#6A1B9A,stroke-width:1px,color:#000 class Ctrl controller class Svc,SlaveClient service class Repo,DbCtx,CmsEntity data class BgSvc,Opts infra ``` Text alternative: Controller depends on Service; Service depends on Repository, SlaveApiClient, and Options; Repository owns DbContext and entity; BackgroundService depends on Service and Options. --- ## Slave-Availability-Extension Component Dependencies ```mermaid graph TD Middleware["AvailabilityMiddleware\n(EXTENDED)"] LocalSvc["IAvailabilityService\n(existing)"] MasterSvc["MasterAvailabilityService\n(NEW)"] AvailDb["AvailabilityDbContext\n(NEW)"] MasterRegEntity["MasterRegistration\n(entity)"] HttpFactory["IHttpClientFactory"] Opts["MasterModuleOptions\n(IOptions)"] AvailCtrl["AvailabilityController\n(EXTENDED)"] MasterCms["Master CMS\n(HTTP endpoint)"] Middleware --> LocalSvc Middleware --> MasterSvc MasterSvc --> AvailDb MasterSvc --> HttpFactory MasterSvc --> Opts AvailDb --> MasterRegEntity AvailCtrl --> AvailDb AvailCtrl --> Opts HttpFactory -->|"HTTP GET status"| MasterCms classDef middleware fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000 classDef service fill:#9ae6b4,stroke:#2f855a,stroke-width:2px,color:#000 classDef data fill:#FFC107,stroke:#F57F17,stroke-width:2px,color:#000 classDef infra fill:#CE93D8,stroke:#6A1B9A,stroke-width:1px,color:#000 classDef external fill:#FC8181,stroke:#C53030,stroke-width:2px,color:#000 class Middleware middleware class MasterSvc,LocalSvc service class AvailDb,MasterRegEntity,AvailCtrl data class HttpFactory,Opts infra class MasterCms external ``` Text alternative: Extended middleware calls both MasterAvailabilityService and existing IAvailabilityService; MasterAvailabilityService reads DB for registration and pulls from master via HTTP; AvailabilityController handles registration writes. --- ## Frontend Component Dependencies ```mermaid graph TD CmsPage["CmsPage\n(/cms route)"] List["CmsInstanceList"] AddDialog["AddCmsInstanceDialog"] StatusDialog["SetStatusDialog"] HookList["useCmsInstances"] HookAdd["useAddCmsInstance"] HookStatus["useUpdateCmsInstanceStatus"] ApiTypes["CmsInstance types\nCmsInstanceStatus enum"] MasterApi["Master CMS REST API\n/api/v1/CmsInstances"] CmsPage --> List CmsPage --> AddDialog CmsPage --> StatusDialog List --> HookList AddDialog --> HookAdd StatusDialog --> HookStatus HookList --> ApiTypes HookAdd --> ApiTypes HookStatus --> ApiTypes HookList -->|"GET"| MasterApi HookAdd -->|"POST"| MasterApi HookStatus -->|"PUT"| MasterApi classDef page fill:#63b3ed,stroke:#2b6cb0,stroke-width:2px,color:#000 classDef component fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000 classDef hook fill:#FFC107,stroke:#F57F17,stroke-width:1px,color:#000 classDef types fill:#CE93D8,stroke:#6A1B9A,stroke-width:1px,color:#000 classDef api fill:#FC8181,stroke:#C53030,stroke-width:2px,color:#000 class CmsPage page class List,AddDialog,StatusDialog component class HookList,HookAdd,HookStatus hook class ApiTypes types class MasterApi api ``` Text alternative: CmsPage renders List + dialogs; List uses useCmsInstances; dialogs use mutation hooks; all hooks use shared API types and call Master REST API. --- ## Dependency Matrix | Component | Depends On | Used By | |-----------|-----------|---------| | `CmsInstanceController` | `ICmsInstanceService` | `SlpModularCms.Api` (module registration) | | `CmsInstanceService` | `ICmsInstanceRepository`, `ISlaveApiClient`, `IOptions` | `CmsInstanceController`, `IntegrityCheckBackgroundService` | | `CmsInstanceRepository` | `MasterDbContext` | `CmsInstanceService` | | `MasterDbContext` | EF Core, `CmsInstance` entity | `CmsInstanceRepository` | | `SlaveApiClient` | `HttpClient` (via `IHttpClientFactory`) | `CmsInstanceService` | | `IntegrityCheckBackgroundService` | `IServiceScopeFactory`, `ICmsInstanceService`, `IOptions` | `IHostedService` (framework) | | `AvailabilityMiddleware` (ext.) | `IAvailabilityService`, `IMasterAvailabilityService` | ASP.NET Core pipeline | | `MasterAvailabilityService` | `AvailabilityDbContext`, `IHttpClientFactory`, `IOptions` | `AvailabilityMiddleware` | | `AvailabilityDbContext` | EF Core, `MasterRegistration` entity | `MasterAvailabilityService`, `AvailabilityController` | | `AvailabilityController` (ext.) | `IAvailabilityService`, `AvailabilityDbContext`, `IOptions` | `SlpModularCms.Api` | | `CmsPage` | `CmsInstanceList`, `AddCmsInstanceDialog`, `SetStatusDialog` | React Router | | `useCmsInstances` | TanStack Query, API types | `CmsInstanceList` | | `useAddCmsInstance` | TanStack Query, API types | `AddCmsInstanceDialog` | | `useUpdateCmsInstanceStatus` | TanStack Query, API types | `SetStatusDialog` | --- ## Cross-Cutting Concerns | Concern | Mechanism | |---------|-----------| | Authentication (API) | JWT Bearer on all master endpoints; `[Authorize(Policy = "OwnerOnly")]` on `CmsInstanceController` | | Authentication (Slave internal) | `X-Master-Api-Key` header validated against `MasterModuleOptions.ApiKey` | | API key secrecy | `ApiKey` never included in `CmsInstanceDto`; only in `CreateCmsInstanceRequest` input | | Fail-open | `MasterAvailabilityService` returns cached status (default `Available`) on HTTP failure | | Per-module migrations | `MasterDbContext` in `Modules.Master`; `AvailabilityDbContext` in `Modules.Availability`; applied at startup in `UseModule` | | Configuration | `MasterModuleOptions` via `IOptions`; section `"MasterModule"` in `appsettings.json` |