ADR 0001: Karyo is one deployable modular monolith
Status: Accepted
Context
Karyo runs one instance per operating company (ADR 0014), on a single host under Compose (ADR 0022). The unit that scales is the customer installation, not a domain module: one company's warehouse traffic lands on one host whatever the internal architecture.
Every module is built, versioned and released together. There is one version for the whole build
(build.gradle.kts, allprojects.version), so no part of the backend has a release cadence of its own to exploit.
The domain is highly transactional. Receiving, reserving, picking, moving and shipping stock each touch several domain areas - inventory, orders, fulfillment, tasks, layout - in one logical operation. Spread across processes, each of those needs a distributed protocol with compensation for partial failure. Inside one process it is one database transaction.
The domain still has real internal boundaries - inventory, product, layout, orders, tasks, fulfillment, replenishment, stocktaking, work, webhooks, reporting, identity - and they are worth holding as contracts even with no network between them.
Decision
- The backend is one Quarkus application,
:services:karyo-app. It depends on every domain module as an ordinary library and is the only backend process that runs (services/karyo-app/build.gradle.kts,dependencies). It declares the union of Quarkus extensions explicitly so that the aggregator is the single source of truth for the assembled image (services/karyo-app/build.gradle.kts,dependencies (Quarkus extension union)). - Each domain stays its own pair of Gradle modules,
-apiand-core, under the rules in ADR 0006. - Modules call each other through SPI beans injected by CDI and notify each other with synchronous
CDI events (ADR 0008). There is no HTTP between
modules; nginx answers
/api/internal/with 404 (infrastructure/docker/nginx/nginx.conf,location /api/internal/). - All modules persist into one PostgreSQL schema (ADR 0004) through one Flyway history (ADR 0005), and refer to one another's rows by id only (ADR 0007).
- The engine modules join the same process as further modules (ADR 0029). They are not separate services.
Consequences
- A multi-module operation is a single transaction. There are no sagas, no compensation logic and no eventual consistency on the operational path.
- Cross-module contracts are checked by the compiler. A broken contract is a build failure, not a failed request.
- One image, one datasource, one migration history, one log stream. Local development is one
quarkusDev. - No module can be deployed or scaled on its own; every release ships everything.
- One process is one blast radius. A leak or a runaway query in any module degrades all of them.
- A deploy replaces the only instance, so every deploy is an outage (
scripts/deploy-server.sh,header outage warning, Stage 6: Start infrastructure; see Deploying). - The supported deployment runs exactly one application instance, and at least the webhook relay depends on that (ADR 0009).
- The boundaries are held by the Gradle graph and by review, not by a network, and nothing mechanical checks the graph (ADR 0006).
- A
-coremodule is not a bootable application on its own, so backend tests run against the assembled application: almost all backend test files live inservices/karyo-app/src/test(Testing). - Every module whose beans the application must discover carries a
META-INF/beans.xml. Without it Quarkus does not index the module's beans, and the application starts with that module's endpoints and services silently missing. - The seams an extraction would need exist -
-apicontracts, id-only references, the outbox - but so do couplings that would have to be undone first: reporting reads other modules' tables directly (ADR 0011), and three modules depend on foreign cores (ADR 0006).
Alternatives considered
- Independently deployed services, one per domain, each with its own database, coordinated over REST and a message broker behind an API gateway on Kubernetes. Rejected. It puts a fixed operating cost - a service per domain, a database per service, a broker cluster, a gateway, service-to-service security - on every installation for the life of the product, when an installation is one company on one host. Its main benefit, independent deployment, has no use when every module is built and released together. And it charges a distribution tax - HTTP clients, retries, circuit breakers, contract tests, saga compensation - on operations that are one transaction in one process.
- Fewer, larger services. Rejected: it keeps the whole distribution tax while giving up most of the independence that would justify it.
- One application with no internal module structure. Rejected: it discards the domain
boundaries and makes extracting a module impossible later, while the
-api/-coresplit costs little. - Functions or serverless. Rejected: a stateful, transactional, self-hosted system with interactive response-time needs is close to the worst fit for a functions runtime.
Evidence
settings.gradle.kts,include- the module graph;settings.gradle.kts,include(":services:karyo-app")includes the aggregatorservices/karyo-app/build.gradle.kts,dependencies- every core aggregated as a libraryservices/karyo-app/build.gradle.kts,dependencies (Quarkus extension union)- the aggregator as the single source of truth for the imageservices/karyo-app/src/main/resources/application.yaml,quarkus.datasource- one datasource for every moduleinfrastructure/docker/docker-compose.prod.yml- PostgreSQL, application and nginx core services, plus the optional managed-Keycloak profileinfrastructure/docker/nginx/nginx.conf,location /api/internal/- no internal HTTP routescripts/deploy-server.sh,header outage warning, Stage 6: Start infrastructure- a deploy recreates the stack- Modules and boundaries, Overview