Architecture overview
The shape of the whole, in one page: what runs, how the backend is assembled, what happens to a request, and where each part is described in depth. Every section ends in the document or decision record that owns the detail.
Derived from infrastructure/docker/docker-compose.prod.yml, infrastructure/docker/nginx/nginx.conf,
settings.gradle.kts, services/karyo-app/build.gradle.kts and
services/karyo-app/src/main/resources/application.yaml.
What runs
One installation is one host running three core containers under Compose, for one Company; the managed-identity profile runs Keycloak as a fourth (ADR 0022, ADR 0014).
One host, three core containers and optional managed Keycloak, with one published port; TLS is
yours and Loci is optional. The managed Keycloak edge also carries /resources/, listed in the
routing table below. Derived from
infrastructure/docker/docker-compose.prod.yml and infrastructure/docker/nginx/nginx.conf;
source docs/diagrams/05-deployment-topology.mmd.
| Container | What it is |
|---|---|
postgresql |
PostgreSQL 16. Karyo's karyo database and schema; Compose initialization also creates a separate keycloak database, used only by the managed profile (docker-compose.prod.yml, services.postgresql, services.keycloak.environment.KC_DB_URL) |
keycloak |
Optional Keycloak 26 managed-identity profile; external-provider mode leaves it stopped (ADR 0037) |
karyo-app |
The application: every module in one JVM, with Flyway migrating the schema at boot |
nginx |
Serves both front-end bundles, proxies the API and, in managed mode, Keycloak; the only container that publishes a port (docker-compose.prod.yml, services.nginx.ports) |
nginx routes by path (infrastructure/docker/nginx/nginx.conf, http.server.location blocks):
| Path | Goes to |
|---|---|
/api/internal/ |
An explicit 404. There is no HTTP between modules, and this prefix is closed so it can never be reached from outside |
/api/ |
The application |
/mcp and the two /.well-known/oauth-protected-resource paths |
The application, for agent sign-in and tools (connecting an agent). Every other child path is an explicit 404 |
/.well-known/oauth-authorization-server/auth/realms/<realm> and /.well-known/openid-configuration/auth/realms/<realm> |
Keycloak's own metadata for that realm, so an agent that inserts the well-known segment before the issuer's path finds it. Every other /.well-known/ path is an explicit 404, never the console |
exact /q/health/live |
Anonymous liveness without dependency detail; all other /q/ paths return 404 |
/auth/, /realms/, /resources/ |
Keycloak when the managed-identity profile is selected |
/m/ |
The floor app |
/ |
The desktop console |
There is no message broker, no cache server, no API gateway, no service mesh and no vector store (ADR 0055). A deploy replaces the only application instance, so a deploy is an outage. Runtime and configuration and deploying cover the stack in detail.
How the backend is assembled
The backend is one Quarkus application, :services:karyo-app, and every domain is a library inside
it (ADR 0001). The build is 53 Gradle subprojects:
| Kind | Count | Examples |
|---|---|---|
Shared libraries under libs/ |
6 | karyo-common (base entities, warehouse time zone), karyo-events (the outbox), karyo-security (tenant context and scope), karyo-license (the GET /api/v1/license compatibility bridge), karyo-documents, karyo-sequence |
-api modules |
21 | DTOs, SPI interfaces and the event payloads other modules observe, one per domain |
-core modules |
23 | Entities, repositories, services and REST resources: the thirteen domain cores, the nine engine modules (waves, crossdock, streaming, cartonization, document templates, monitors, forecasting, slotting, simulation) and the flow model |
| Leaves | 2 | karyo-demo, off unless enabled; karyo-inventory-ext-example, built but assembled only on request |
| The application | 1 | :services:karyo-app, which also owns application.yaml and every Flyway migration |
One JVM: both front ends call the same REST API, cores and engines meet through the -api seam
and one schema, and the outbox feeds webhooks out. Slotting may call Loci; identity protocol calls
go to the configured OIDC provider. Derived from the table above,
ADR 0006 and
ADR 0009; source
docs/diagrams/03-service-architecture.mmd.
A -core depends on -api modules, never on another module's -core, apart from two recorded
waivers (ADR 0006). When a dependency would point the wrong
way, the module that needs the answer declares an SPI and the module that has it implements it. The
Gradle graph is not the whole picture: modules also couple through the shared schema, through CDI
events bound by type, and through SPI implementations resolved at runtime.
Modules and boundaries maps all four.
The ten engine capabilities, in nine modules, are part of this repository
(ADR 0029). settings.gradle.kts includes their
-core modules unconditionally and services/karyo-app/build.gradle.kts adds them to the
application, so the assembled image is the complete product. Their -api modules, the seams
they implement, their migrations, their configuration keys and their screens are here too,
all Apache-2.0. The engine boundaries explains how they sit in the
one distribution.
A request, end to end
- nginx passes
/api/...to the application. - Quarkus OIDC validates signature, time, exact issuer, algorithm and API audience through the selected allowlisted provider profile.
PrincipalSecurityIdentityAugmentorresolves the exact issuer/subject binding and requires an active local principal. The stored principal kind and affiliation are authoritative: a token's kind and Business Unit claims may only confirm or narrow them, and its roles, groups and scopes are never read as authority (ADR 0048).TenantFilterfills a request-scopedTenantContextfrom that normalized actor: stable principal and binding ids, approved Business Unit, principal kind and display snapshots. It then requires the one catalogue action the resource method declares with@DeclaredAction, refuses a caller whose grants hold it nowhere (403action-not-granted), and scopes the request to the Business Units and Facilities where it is granted (services/karyo-app/src/main/kotlin/com/karyo/app/auth/TenantFilter.kt,TenantFilter.populateOrganizationScope,TenantFilter.resolveGrantedScope).- The resource calls a service. A
@Transactionalservice method is the unit of work: it reads and writes through repositories, calls other modules through injected SPIs, fires CDI events, writes outbox rows and inventory journal rows, all in one database transaction. readFacilityScope()orwriteFacilityScope()applies that boundary to operational rows.OrganizationLookupresolves their Business Unit from the stored Facility, not from a copied row column. Scope resolution owns grant-backed selection.- The response is the resource's DTO, or an RFC 7807 problem document on error (ADR 0017).
Identity and tenancy covers claims, scope and what enforces isolation; the HTTP API surface and the error contract cover the wire.
Transactions, events and the outbox
- Between modules, synchronous CDI events. A module fires a payload declared in its
-api, and every observer chooses its transaction phase: inside the firing transaction when the reaction must succeed or fail with the change, after success when it needs the committed state (ADR 0008). - Out of the process, a transactional outbox. A change that matters outside is written to
outbox_eventsin the same transaction. The webhook relay reads it (ADR 0009). - State is current rows, not events. Stock is updated in place and every change writes an immutable inventory journal row alongside it (ADR 0010).
Events and the outbox and webhooks and the event catalogue have the detail.
Persistence
One PostgreSQL database and one karyo schema serve every module
(ADR 0004). Flyway migrates it when the
application starts, from seventeen registered migration directories in per-module version bands,
out of order because the bands interleave; applied migrations are immutable, comments included
(ADR 0005). Modules refer to each other's rows by id,
never by foreign key (ADR 0007). Reporting reads
the operational tables directly through SQL views
(ADR 0011). An in-process Caffeine cache
holds reference data only; stock is never cached
(ADR 0012).
Data and persistence and the data model have
the tables.
Background work
Six scheduled jobs run in the build:
| Job | What it does | Interval |
|---|---|---|
WebhookFanoutScheduler |
Matches new outbox rows to webhook subscriptions | karyo.webhooks.poll-interval |
WebhookDeliveryScheduler |
Sends due webhook deliveries, with retries | karyo.webhooks.poll-interval |
KeycloakEventPoller |
In managed mode, copies sign-in events into the Company sign-in log, with no Facility audience; disabled for external providers | karyo.auth-audit.poll-interval |
StockPurgeScheduler |
Purges emptied stock units and unit loads | karyo.inventory.purge.interval |
ReplenishmentScheduler |
Runs the replenishment scan for every active Facility; off unless enabled | karyo.replenishment.scan-interval |
LocationFinderService.sweepExpiredReservations |
Renews putaway reservations of open transport orders and deletes expired ones | fixed, 60 seconds |
The first five use ConcurrentExecution.SKIP so a tick never overlaps the previous one in the same
JVM (for example .../webhooks/relay/WebhookFanoutScheduler.kt, WebhookFanoutScheduler.scheduled). A scheduled thread has no
request behind it, so jobs pass the goods owner or Facility explicitly rather than reading an
ambient context, which throws on a scheduler thread
(Identity and tenancy). Several of these jobs assume exactly one
application instance. Operating an installation covers
running them.
Configuration
services/karyo-app/src/main/resources/application.yaml is the one runtime configuration file.
Environment variables override it, and a runtime property store in the database overrides both for
the settings it knows: a goods owner's own row, then the Company layer's row (Business Unit 0), then configuration, then
the built-in default. Runtime and configuration and
the runtime configuration store describe the
ladder, and the configuration boundary says which
kind of change belongs where. Tunable warehouse behaviour is expressed through strategies
(ADR 0018).
Front ends
Two separate React and TypeScript applications, served from the API's own origin: the desktop
console for planners and administrators at /, and the floor app for operators at /m/
(ADR 0016). Route guards cover the administration
pages only; everything else is authorised at the API. The engine screens are ordinary pages in
their home sidebar groups; the console has no licence awareness and never calls
GET /api/v1/license, and a capability that still needs configuration says so on its own screen
(Front ends).
Observability
Structured JSON logs on standard output in production
(ADR 0026). Metrics exposed at /q/metrics inside the
network, with no collector shipped; tracing present and switched off
(ADR 0025). External probes use only
/q/health/live; containers read readiness on the internal application port. Admin Health reads
/api/v1/admin/health, guarded by settings.manage at the Company.
Extending it
Extensions implement SPIs from the -api modules, observe CDI events, set strategy properties or
subscribe to webhooks. They are compiled into the build before Quarkus augmentation; nothing is
uploaded into a running image (ADR 0019).
Extension SPIs and installation and the
implementer guide show how.
Where to go next
| To understand | Read |
|---|---|
| Why each of these choices was made | Decision records |
| The rules a change must not break | Architecture guide |
| What Karyo does in a warehouse | docs/README.md |
| How the tests are organised | Testing |
| How to run it locally | Developer onboarding |