4 Solution Strategy¶
The fundamental decisions and strategies that serve FeeCheck's quality goals — testability, low framework lock-in and clear domain boundaries, stated in the quality requirements as ARC-Q4 and ARC-Q5 and enforced by the offline gate. Every module is built in onion rings with ports and adapters (4.1, drawn in 8.15.4), and modules meet through what they publish or through domain events on one event backbone (4.2, drawn in 8.16.3).
4.1 Architectural style — onion rings (ports and adapters)¶
The business logic stays independent of external technologies, stores and frameworks: every module is built in three rings — domain inside application inside infrastructure — the onion form of a ports-and-adapters (hexagonal) architecture. The domain declares a port for each thing it needs from outside, an adapter in the infrastructure ring implements it, and an inbound adapter turns a request into a call of the application ring; every dependency points inward. What each ring holds, how ports and adapters sit in the rings and how this is carried out in the code is in 8.15.
Rationale: the core is isolated from external change — upgrading a framework or switching a store or a provider does not change the business logic.
4.2 Modularization — a modulith of components¶
The code is one deployable organised as a modulith: each business capability is a module of its
own (intake, cases, consumer, extraction, kernel and the adapter-only mcp,
signin and webapp — 5.2.1), and each
module carries its own rings (4.1). Modules meet only through the parts a module publishes — its
public interfaces — or through asynchronous domain events, the one event backbone.
The FeeCheck case runs on a CMMN case engine, Flowable, inside the cases module: it orchestrates
the case's stages, and one task following another is the engine's own step. A stage's work is
handed to the stage module that owns it — intake, extraction, later reconciliation — as a
request event, answered by a reply event; the stage modules know neither the case nor the engine.
Facts that leave or enter a case, and facts between modules the engine does not run, are domain
events too. Every event is kept in an outbox in the transaction of the change it reports. Within
one deployable an event is delivered in memory; to another deployable it travels through a
message broker, chosen per installation like the rest of the infrastructure
(4.5) — Pub/Sub in production, a local Pub/Sub
emulator in the end-to-end tests, none in development. The queue's consumer has no place in
this design: its work belongs to the stage modules and to cases
(5.2.1).
| Kind | When it is used | Status |
|---|---|---|
| Published application service | a synchronous call, because the caller needs the answer now: the case converts through intake's upload application service and extracts through extraction's application service, and the queue's consumer does both | built; for a stage's work replaced by request and reply events |
| Published domain types | the values and ports a module needs from another one — intake's rendition and converter port, extraction's result, the case's store ports | built |
| Request and reply | a stage's work: the case sends a request event and waits, bounded by a reply deadline, for the stage module's reply or rejection; the stage module depends on nothing of the case | planned |
| Domain event | "something happened": the publisher does not wait, and other modules react once its work is done; also the way to turn round a dependency that would otherwise close a cycle | planned |
| Enforcement | the build checks the rings, that no cycle runs between modules and that a module uses only what another one publishes, and fails on a violation | built |
How modules, published interfaces, services and events are carried out in the code is in 8.16.
Rationale: a modulith gives the strict code boundaries of microservices without their operational cost — network latency, complex deployments, distributed transactions.
4.3 Key technology decisions¶
| Decision | In FeeCheck | Status |
|---|---|---|
| Language and platform | Java 25 and Spring Boot 4.1; Spring is used in the infrastructure ring and the wiring, the domain ring carries no Spring code except Spring Modulith's marker that publishes a package (8.16) — its types carry jMolecules annotations, and the parser uses Jackson (2.2) | built |
| Persistence | PostgreSQL holds the case, the case engine's tables and the outbox in one database, reached through Spring Data JDBC (ADR-0019 (docs/adr/adr-0019-spring-data-jdbc-for-the-relational-store.md)) and outbound ports (8.3) so that it stays switchable. The PDF stays in Cloud Storage |
built for the case, its pages and the outbox; the case engine's tables planned |
| Case engine | Flowable's CMMN engine runs the case from the start, inside cases, behind a thin port (6.1, 8.16) |
planned |
| Event backbone | Spring Modulith events with their outbox; carried to other deployables by Spring Cloud Stream, the broker chosen by binder and configuration (8.16.3) | planned |
| Enforcement | ArchUnit with jMolecules and Spring Modulith's module verification run in ./gradlew build, the gate of every pull request, and fail it on a ring violation or a forbidden dependency between modules (8.15) |
built |
4.4 Approaches and the goals they serve¶
| Approach | What it means | Serves | Status |
|---|---|---|---|
| One deployable | the backend is the only product artefact; components are packages inside it, not services (ADR-0003 (docs/adr/adr-0003-repository-module-boundaries.md)) |
ARC-Q6, C6 | built; further Gradle subprojects only when a component needs one |
| Ports with a stub and a real adapter | each module declares its ports in its domain ring, with a stub that needs no network, key or Docker and a real adapter behind each (8.13) | ARC-Q4, ARC-Q5, offline gate | built |
| Providers switched by configuration | settings and profiles choose the adapter, never a branch on the provider in domain code; the stub defines the contract (8.13) | ARC-Q4.2, ARC-Q5.2 | built |
| One validation boundary | every model answer passes the extraction's one parser and its re-ask before it reaches the domain (8.7) | REQ-Q2, SEC-Q3 | built |
| Derived confidence | confidence comes from checking the cited passage against the document, never from the model's own rating (8.7) | REQ-Q1, REQ-Q2 | built |
| Page-anchored text | the rendition carries FeeCheck's own page anchors, so evidence names its page whichever converter produced it (6.2.1) | REQ-Q1, ARC-Q5 | built |
| Offline, deterministic gate | ./gradlew build runs without network, key or Docker; paid and Docker-based tests have tasks of their own (8.4) |
ARC-Q4.1, ARC-Q6.2 | built |
| Architecture as code | the rings and the module boundaries are verified in the build, which fails on a violation (8.15, 8.16) | ARC-Q5.3, C2 | built |
| Long work through push | long work runs asynchronously behind a push queue that costs nothing while idle (ADR-0009 (docs/adr/adr-0009-async-intake-pubsub-bucket-firestore.md), 8.16.3) |
ARC-Q6 | built for the intake's job; the cloud resources and the job as a stage request planned |
| Deterministic rules first | in reconciliation, deterministic rules decide the unambiguous cases before any model call | REQ-Q2 | planned |
| Append-only audit trail | a relational audit trail with versions per finding | REQ-Q1 | planned |
| PII minimisation before the LLM call | guardrail G-2 under constraint C8 (8.2) | SEC-Q3 | planned |
| FeeCheck's own MCP server, read-only | the MCP server in the backend, read-only tools only (ADR-0011 (docs/adr/adr-0011-mcp-server-placement.md)) |
SEC-Q3 | built |
| MCP tools with minimal permissions | a findings tool serves released findings only (G-3, 8.2) | SEC-Q3 | planned |
4.5 Infrastructure is chosen per installation¶
No piece of infrastructure is a product decision: the identity provider, the hosting and runtime, the queue, the stores, the document conversion and the model provider are chosen per installation, and the architecture keeps each of them switchable, because the product must be installable in different scenarios for different customers (ARC-Q4). A new customer may want another one, so the choice stays with the installation.
This drives the choice of libraries: FeeCheck uses libraries that adapt to a wide range of infrastructure — one of the main reasons for Spring Boot, Spring AI and the Spring Cloud libraries — and avoids binding to one technology or AI provider wherever possible. Where no library abstracts a provider, FeeCheck writes its own port with adapters selected by configuration or Spring profile (8.13).
The proof of concept runs on one decided set: Google Cloud — Cloud Run, Firebase Hosting, Pub/Sub,
Cloud SQL for PostgreSQL, Cloud Storage and Google sign-in through OIDC — with Mistral or Gemini on
Vertex AI as the model and docling-serve for conversion. PostgreSQL keeps the case instead of the Firestore
store that ADR-0009 decided, and is authoritative for everything that belongs to a case; a document
database holds derived copies only (ADR-0018 (docs/adr/adr-0018-postgresql-authoritative-document-database-derived.md)). The driver for Google Cloud is cost
(ADR-0006 §4); the provider stays switchable.
4.6 Tenancy — not in the PoC, maybe later¶
The proof of concept is neither a multi-tenant cloud offering nor a cloud offering of isolated installations: the time available does not allow it. Given the confidential data the current use case processes and the customers it targets — banks and financial institutions — a cloud offering would be one isolated installation per customer; that is out of scope for the proof of concept. If the product is later adapted to other use cases or a less sensitive customer base, multi-tenancy can be reconsidered.
4.7 Regulatory regime — per installation¶
For the proof of concept the reference customer is a financial company with international
services, and the PoC is scoped to the EU. Only synthetic contracts are processed, so
no real contract reaches a model provider, and the EU providers that
ADR-0012 (docs/adr/adr-0012-model-provider-and-extraction-shape.md) admits suffice.
The product must support at least the most common financial places — the EU, the UK, Luxembourg, Switzerland, Singapore and the US — and be able to adapt to any regulatory regime, either by configuration or through adapters and patterns for future regulations. Whether an installation may send contract content to an external model provider, and where its data may be processed, is decided per installation under its regime, like the rest of its infrastructure (4.5); a customer-operated model is the always-available alternative (ARC-Q4.2).