2026-02-24 08:49:40 +01:00
# Architektur-Kompass
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
2026-03-25 19:15:53 +01:00
Letzte Aktualisierung: 2026-03-25
2026-03-04 15:56:58 +01:00
## Ziel
Verbindliche Kurzregeln für Architekturentscheidungen.
## Systembild
- Server-gerenderte Admin-App + REST-API unter `/api/v1` .
- Multi-Tenant-Isolation ist Standard.
- Autorisierung läuft zentral über Policies.
- Externe API-Verträge sind UUID-first.
2026-03-05 11:17:42 +01:00
## Schichtenübersicht
```mermaid
flowchart TD
Browser([Browser / API-Client])
2026-04-13 23:20:05 +02:00
subgraph APP["core/App/ — Composition Root"]
2026-03-05 11:17:42 +01:00
DI["AppContainer + Registrars"]
end
2026-04-13 23:20:05 +02:00
subgraph SVC["core/Service/"]
2026-03-05 11:17:42 +01:00
direction LR
FAC["Factory"]
SERVICE["Service"]
GW["Gateway"]
POL["Policy"]
end
2026-04-13 23:20:05 +02:00
subgraph REPO["core/Repository/"]
2026-03-05 11:17:42 +01:00
REP["Repository"]
end
subgraph pages["pages/**"]
ACT["Action (*.php)"]
VIEW["View (*.phtml)"]
end
subgraph TPL["templates/"]
LAY["Layouts & Partials"]
end
DB[(MariaDB)]
DI -->|"ruft zur Laufzeit"| FAC
FAC -->|"erzeugt"| SERVICE
FAC -->|"erzeugt"| GW
Browser --> ACT
ACT -->|"Input · AuthZ · Response"| SERVICE
ACT --> POL
ACT --> VIEW
VIEW --> LAY
SERVICE --> GW
GW --> REP
SERVICE --> REP
REP --> DB
```
2026-03-04 15:56:58 +01:00
## Request-Flow
1. `web/index.php` bootstrappt Routing/Konfiguration und initialisiert den `AppContainer` .
2. Guard/Firewall/Session/Locale greifen.
3. Action in `pages/**` nimmt Input an.
4. Action delegiert an Service.
5. Service nutzt Repository für Datenzugriff.
6. Response wird als HTML/JSON/Datei ausgegeben.
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
2026-02-24 08:49:40 +01:00
## Schichtregeln (MUSS)
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
2026-03-04 15:56:58 +01:00
- `pages/**` : Input, Auth/AuthZ, Orchestrierung, Response.
2026-04-13 23:20:05 +02:00
- `core/Service/**` : Fachlogik und Anwendungsfluss.
- `core/Repository/**` : SQL, Filter, Paging, Mapping.
2026-03-04 15:56:58 +01:00
- `templates/**` : Rendering ohne Business-Logik.
- Templates konsumieren nur vom Action-Layer vorbereitete View-Daten (`$viewAuth` , Form/ViewModel), keine direkten Permission-Helper.
- Service-Auflösung in Actions/Helpers nur über `app(Foo::class)` .
- In Actions bevorzugt direkte Klassen-Bindings (`app(Service::class)` ) statt Factory-Ketten.
- In `pages/admin/**` keine `Factory::class` -Referenzen.
- Request-Input in Actions nur über `requestInput()` lesen.
- Validierungsfehler über `FormErrors` führen und für APIs mit `ApiResponse::validationFromFormErrors(...)` ausgeben.
2026-03-05 08:26:51 +01:00
- In `pages/api/v1/**` kein direktes JSON-Body-Lesen über `ApiResponse::readJsonBody(...)` .
2026-03-04 15:56:58 +01:00
- `Flash` nur für Redirect-/Outcome-Meldungen verwenden, nicht als primäre Validation-Struktur.
- Listen-Endpoints in `pages/**/data().php` sind GET-only (`gridRequireGetRequest()` ).
2026-03-25 19:15:53 +01:00
- Query-Filter in `data().php` über `gridParseFiltersFromSchemaFile(...)` + `filter-schema.php` normalisieren (enthält `limit` , `offset` , `order` , `dir` im Ergebnis).
2026-03-04 15:56:58 +01:00
## Instanziierungsregeln (MUSS)
2026-04-13 23:20:05 +02:00
- Composition Root: `web/index.php` + `core/App/registerContainer.php`
2026-03-06 12:25:18 +01:00
(→ Details: `/docs/explanation-di-container.md` ).
2026-03-04 15:56:58 +01:00
- `new ...Factory()` nur im Composition Root und in `*Factory.php` .
2026-04-13 23:20:05 +02:00
- In `core/Service/**` außerhalb von `*Factory.php` keine direkten `new ...Factory()` .
- In `core/Service/**` außerhalb von `*Factory.php` keine direkten `new ...Service()` , `new ...Gateway()` oder `new ...Repository()` .
2026-03-04 15:56:58 +01:00
- Legacy-Helper (`accessServicesFactory()` , `userServicesFactory()` usw.) sind entfernt und werden nicht mehr genutzt.
## API- und Security-Regeln (MUSS)
- Tenant-Scope und Permission nur serverseitig erzwingen.
- Denials je Endpunkt als `403` oder `404` modellieren.
- API-Fehlerformat konsistent halten (`error` , optional `errors` ).
- OpenAPI bei API-Änderungen im selben Merge aktualisieren.
## RBAC-UI-Standard (MUSS)
- Ability-Entscheidungen laufen serverseitig über `AuthorizationService` .
- Für Layout/Partials werden globale Capabilities zentral über `UiAccessService::layoutCapabilities()` + `UiCapabilityMap::LAYOUT` bereitgestellt.
- Für einzelne Views setzen Actions explizit `$viewAuth['page']` (bevorzugt über `UiCapabilityMap` + `UiAccessService::pageCapabilities()` ).
- In `templates/**` keine direkten `can('...')` - oder Permission-Key-Checks.
2026-03-05 08:26:51 +01:00
## Frontend-Page-Module (MUSS)
- In `pages/**` und `templates/**` sind inline `<script type="module">...</script>` ohne `src` verboten.
- Seiteninitialisierung liegt in dedizierten ESM-Page-Modulen unter `web/js/pages/*` .
- Pro Seite wird Konfiguration per `<script type="application/json" id="page-config-<page-key>">...</script>` bereitgestellt und im Modul über `readPageConfig(...)` gelesen.
2026-04-29 09:57:22 +02:00
- In `pages/**` und `templates/**` müssen alle JS-`src` (eigene und Vendor) über `assetVersion('...js...')` laufen.
2026-03-05 08:26:51 +01:00
2026-03-04 15:56:58 +01:00
## Mindestchecks vor Merge
```bash
docker compose exec php vendor/bin/phpunit
docker compose exec php vendor/bin/phpstan analyse -c phpstan.neon --no-progress
```
Bei JS-Änderungen zusätzlich Browser-Smoke mit DevTools-Console (keine JS-Errors).
Struktur-Gates zusätzlich:
```bash
2026-04-13 23:20:05 +02:00
(rg 'new\s+[^\s(]+Factory\(' core/Service || true) | wc -l
(rg --glob '!**/*Factory.php' 'new\s+[^\s(]+(Service|Gateway|Repository)\(' core/Service || true) | wc -l
2026-04-14 07:54:02 +02:00
(rg "\b(accessServicesFactory|directoryServicesFactory|userServicesFactory|authServicesFactory|tenantServicesFactory|settingServicesFactory|userRepositoryFactory|authRepositoryFactory|authGatewayFactory)\(" pages core templates web || true) | wc -l
2026-03-04 15:56:58 +01:00
(rg -n 'new\s+[^\s(]+(Service|Gateway|Repository)\(' pages -g '*.php' || true) | wc -l
(rg -n '\bDB::' pages -g '*.php' || true) | wc -l
(rg -n 'app\([^\n]*Factory::class\)->create' pages/admin -g '*.php' || true) | wc -l
(rg -n 'Factory::class' pages/admin -g '*.php' || true) | wc -l
2026-03-05 08:26:51 +01:00
(rg -n 'ApiResponse::readJsonBody\(' pages/api/v1 -g '*.php' || true) | wc -l
2026-03-04 15:56:58 +01:00
```
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
2026-03-04 15:56:58 +01:00
Architektur-Contract:
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
2026-03-04 15:56:58 +01:00
```bash
docker compose exec php vendor/bin/phpunit tests/Architecture/CoreStarterkitContractTest.php
```
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
2026-03-04 15:56:58 +01:00
## Vertiefung
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
2026-04-13 23:20:05 +02:00
- `/docs/reference-core-standards.md`
2026-03-06 12:25:18 +01:00
- `/docs/explanation-sicherheitsmodell.md`
- `/docs/howto-rbac-permissions-playbook.md`