Architecture
Registry consists of two deliverables — a reactive Kotlin backend and an Angular SPA — that talk over a versioned REST API, with an external OIDC provider and a single PostgreSQL database behind the backend. This page describes the internal shape of each service and the end-to-end path of a request.
Backend — hexagonal, reactive
The backend follows hexagonal architecture (ports and adapters). The domain is at the center: it depends neither on the adapters (infrastructure/) nor on the wiring (config/), and it is the periphery that speaks HTTP, SQL and OIDC. The dependency rules are not a convention — they are checked by an ArchUnit test run with the test suite (ADR 001).
Layers
domain/— the core:model/(business models, exceptions, pagination),port/(interfaces of the outbound ports the domain depends on),service/split intocore/(a resource's rules),usecase/(orchestrations that span several resources) andsupport/(audit, translation, cache, features),helper/(reusable rules), plusenumeration/,constant/and theextension/reactive helpers. The domain depends on no web adapter (org.springframework.web,http.server,security.web— forbidden by ArchUnit), but it is not Spring-independent: its services are beans (@Service,@Component), its writes go throughTransactionalOperator, its signatures areMono/Flux(Reactor),RegistryExceptioncarries anHttpStatus, and the principal (CurrentUserModel) relies on Spring Security types.infrastructure/driving/— the REST API (the "driving" side, facing outwards — called by the outside world), the security chain (filters, limiters, read auditing) and the scheduler. Controllers are contract-first: the REST semantics — path mapping,@PreAuthorize, OpenAPI tags, validation,@AuthenticationPrincipal CurrentUserModel— live on an interface (I…V2Controller); the@RestControllerimplementation only delegates to a domain UseCase, or directly to asupport/service. Acore/service never calls anothercore/service or a UseCase, and a UseCase is only called by controllers. Incoming writer DTOs and outgoing reader DTOs are mapped to/from the domain models, and API-specific validation constraints live here.infrastructure/driven/— the outbound adapters that serve the domain (called by the application):postgres/(R2DBC repositories implementing the domain ports, entities, entity mappers) andidp/(the OIDC provider adapter).config/— Spring wiring only (security, CORS, documentation, R2DBC, i18n, Swagger, logging, JWT decoder, clock, features).
Reactive top to bottom
Every layer is non-blocking: WebFlux controllers return Mono/Flux, repositories use the reactive R2DBC driver, and writes run in reactive transactions (TransactionalOperator) with programmatic R2DBC auditing. Schema management is the only exception — Flyway migrates the database over a JDBC connection at startup, so the backend opens two connections to the same database: an R2DBC pool for the runtime and JDBC for migrations (ADR 002). Repositories write SQL by hand via Spring Data's @Query, composing reusable fragments (join clauses, visibility/project filters) to stay DRY, and assemble PageModel results from a count query and a page query.
Cross-cutting concerns
- Errors — a
RegistryControllerAdviceturnsRegistryException, validation failures and framework exceptions into a localizedErrorDto(status, code, i18n title/message). - Validation — Jakarta Bean Validation with per-field length and size bounds on every writer DTO and every request parameter, plus a family of custom cross-field constraints (
@StartBeforeEnd,@MinUpperMax,@MovementReason,@BothCannotBeDefined,@AtLeastOneIsDefined,@MovementGuestContent,@DateDefinedForTime,@ProjectOptionDependencies,@ProfileAcceptOrReject), evaluated by a reflection-basedGenericValidatorthat lives with the API layer. - i18n — the request locale, from the
Accept-Languageheader, drives themessages/errorsbundles (English by default, French supported). - Pagination — the API takes
page(≥ 0, 0 by default) andsize(bounded 1–200, 20 by default) withqandsort, mapped to the domain'sPageableModel(offset, limit); aPageModel(content + page metadata) comes back, assembled from a count query and a page query. - Concurrency —
ETag/If-Matchplus row locks protect concurrent edits and "last administrator"-style invariants (ADR 016). - Scheduling — an internal
PurgeSchedulerruns the five nightly retention sweeps (ADR 010). - Traceability — a filter traces reads of personal data and exports in an audit log written in the background (ADR 019); log-type items are versioned on every change (ADR 018).
- Observability — Spring Actuator with a Micrometer/Prometheus endpoint, enabled by feature flag per environment.
Frontend — zoneless Angular, signal stores
The frontend is an Angular SPA bootstrapped by bootstrapApplication on a standalone root component, with zoneless change detection driven by signals (provideZonelessChangeDetection). The interface relies on the @sgdf/ui design system and Tailwind CSS. See Frontend for the full picture.
- Bootstrap and runtime configuration. Before the application bootstraps, an initializer fetches two JSON files —
settings/config.json(application identity, languages, notification durations) andsettings/env.json(backend URL, production flag, unauthenticated paths, hosting provider).config.jsonis versioned;env.jsonis not and is injected per environment (config.jsoncan be too), so a single built image serves any environment (ADR 007). - Folder taxonomy.
core/contains what the application cannot run without (configuration, authentication, layout, routing, session state);pages/contains one folder per routed page with its owndata/(api, store, facade, DTOs);shared/contains directives, helpers, mappers, models and reusable UI. - State management.
@ngrx/signalssignal stores behind facades —component → facade → store → api(ADR 013). Core stores are root singletons; page stores are provided by their routes and reset on a profile change. The "active project" is the route's:projectId, not a stored preference. - HTTP and authentication. A single functional interceptor sends every backend request with
withCredentials(theHttpOnlyauthentication cookies travel automatically, except on public metadata lookups), relays theX-XSRF-TOKENheader captured on the previous authenticated response, addsAccept-Language, refreshes the token once on401then replays the request, and normalizes transport errors into user-facing messages. - Routing and guards. Each page is loaded on demand behind an
authGuard;userAuthorityGuardprotects the user directory; aprojectContextGuardselects the:projectIdproject (and answers a single generic "not found" when the user has no access to it), andprojectOptionGuard(option)mirrors the backend's per-project option authorities for the vehicle, activity and alert modules. - Freshness. A
RefreshServicereloads the displayed data in the background at an interval set by the user's refresh mode (OFF/ECO/NORMAL/FAST); optimistic concurrency usesETag/If-Match(ADR 016).
End-to-end path of a request
The Security page details the JWT → user mapping and how the per-project permission check runs on every call.
Deployment topology
Four cooperating tiers:
- PostgreSQL — the single source of truth; schema managed by Flyway.
- OIDC provider — issues and signs JWTs; configured generically (see ADR 004).
- Backend — distroless Java image, non-root, exposing
/api/v2/**on:8081(authenticated by JWT/cookie, CORS restricted to a configured allowlist) and, on a separate, unauthenticated management port:8082, health, Prometheus metrics and (optionally) OpenAPI — see Security → Network exposure. - Frontend — the static bundle served by an unprivileged nginx on
:8080, with SPA fallback and hardening headers; configured per environment through the two runtime JSON files.
Both services are versioned by semantic-release and published as container images with a retention policy of 5 (ADR 009).