5 Building Block View¶
5.1 Whitebox Overall System¶
FeeCheck's containers and the people and systems around them. The table names each one's responsibility in one line; its Level 2 section in 5.2 says how it is built and what it must achieve. How they are deployed is in 7.1 Infrastructure Level 1.
flowchart LR
visitor["Visitor<br/>[Person]"]
person["Signed-in person<br/>[Person]"]
subgraph fc["FeeCheck"]
gw["API gateway<br/>Spring Cloud Gateway"]
site["Public website<br/>React · pre-rendered"]
web["Web app<br/>React SPA"]
be["Backend<br/>Spring Boot"]
dl["docling-serve<br/>container"]
q[["Event broker<br/>Pub/Sub"]]
ds[("Document store<br/>Cloud Storage")]
db[("Case database<br/>PostgreSQL + pgvector")]
end
llm["LLM provider<br/>[External system]"]
idp["Google<br/>[External system]"]
mcpc["MCP clients<br/>[External system]"]
sd["Master-data system<br/>mock"]
inv["Fee calculation and invoicing<br/>[Existing system]"]
visitor -- "HTTPS" --> site
site -- "Login link" --> web
person -- "HTTPS" --> web
person -. "HTTPS" .-> gw
gw -. "token relay" .-> be
web -- "HTTPS" --> be
be -- "HTTP" --> dl
be -. "publish" .-> q
q -. "push" .-> be
be -. "PDF" .-> ds
be -- "case, engine, outbox" --> db
be -- "HTTPS" --> llm
be -- "OIDC" --> idp
mcpc -- "MCP" --> be
be -. "REST" .-> sd
be -. "REST" .-> inv
classDef person fill:#ffe8b0,stroke:#9a6b00,color:#000
classDef built fill:#b7e4c7,stroke:#2d6a4f,color:#000
classDef planned fill:#c6dcff,stroke:#1168bd,stroke-dasharray:4 3,color:#000
classDef external fill:#e6e6e6,stroke:#6b6b6b,color:#000
class visitor,person person
class site,web,be,dl,db,ds built
class gw,q,sd planned
class llm,idp,mcpc,inv external
style fc fill:none,stroke:#666
| Colour | Meaning |
|---|---|
| green | built |
| blue, dashed border; dotted arrows | planned — the Status column says how far each one is |
| grey | external system |
| light orange | person |
| Name | Responsibility | Interfaces | Code (directory) | Status |
|---|---|---|---|---|
| Visitor | Reads what FeeCheck is before signing in | the public website | — | — |
| Signed-in person | Works on cases: uploads documents, follows them, reviews and releases findings | the web app | — | — |
| Web app | The user interface for working on cases | the backend's API | frontend/app |
built |
| Public website | Tells a visitor what FeeCheck does and leads to the sign-in (ADR-0005 (docs/adr/adr-0005-second-frontend-public-website.md)) |
none at run time | frontend/site |
built |
| API gateway | The single public entry: sign-in, session, routing to the backend (ADR-0010 (docs/adr/adr-0010-api-gateway-and-api-contract.md)) |
the whole public origin | — | planned |
| Backend | FeeCheck's business logic: the case and its engine, the stages, the sign-in, the MCP server; serves the web app | the endpoints of 5.1.1 | backend/app |
built |
| docling-serve | Turns a document into page-anchored markdown (ADR-0004 (docs/adr/adr-0004-document-conversion-docling.md), ADR-0006 (docs/adr/adr-0006-services-on-google-cloud.md)) |
HTTP | — | built |
| Event broker | Carries domain events between deployables and to downstream systems (ADR-0009 (docs/adr/adr-0009-async-intake-pubsub-bucket-firestore.md)) |
publish; push to the backend | — | planned |
| Document store | Keeps an uploaded document while the case needs it (ADR-0009 (docs/adr/adr-0009-async-intake-pubsub-bucket-firestore.md)) |
object storage | — | built |
| Case database | Keeps the case, its results and history, the case engine's state and the outbox | SQL | — | built for the case, its pages and the outbox; the case engine's tables planned |
| LLM provider | The language model the backend asks (ADR-0012 (docs/adr/adr-0012-model-provider-and-extraction-shape.md)) |
HTTPS | — | external |
The identity provider of the PoC's sign-in (ADR-0008 (docs/adr/adr-0008-google-sign-in-and-backend-on-cloud-run.md)) |
OIDC | — | external | |
| MCP clients | AI integrations that use FeeCheck's results (3.2) | MCP | — | external |
| Master-data system (mock) | The source a contract is checked against (3.2) | REST, read-only | — | planned (KF-2) |
| Fee calculation and invoicing system | Calculates fees and creates the invoice (3.1) | REST | — | external; not in the PoC |
How each container is built, what it must achieve and where it is decided is in its Level 2 section (5.2).
5.1.1 Important interfaces¶
The backend's HTTP endpoints (read off the backend's controllers and its application configuration; which class serves which endpoint is in 8.13):
| Interface | Caller | Built in |
|---|---|---|
POST /api/cases, GET /api/cases/{id}, GET /api/cases/{id}/pages — the case API, contract the generated api/openapi.yaml; what is specified and not built, in spec 339's OpenAPI draft (docs/specs/339-case-api.openapi.yaml) |
web app | cases — the case endpoints (spec 339 (docs/specs/339-case-api.md)) |
POST and GET /api/cases/{id}/extraction — a case's extraction stage |
web app | cases — the extraction-stage endpoints |
POST /api/intake/jobs/push, POST /api/intake/jobs/dead-letter — the queue's push, with an OIDC push token |
Pub/Sub | consumer — the push endpoints and their push-token check |
GET /api/intake/converter — the converter's status |
web app | intake — the converter-status endpoint |
GET /api/intake/limits — the upload's page and size limits, without asking the converter (spec 360 (docs/specs/360-pdf-upload-limits.md)) |
web app | intake — the limits endpoint |
GET /api/intake/settings — the intake's configured converter and models (spec 367 (docs/specs/367-contract-gate.md) R-11) |
web app | intake — the settings endpoint |
GET /api/me — the signed-in person |
web app | signin — the signed-in person's endpoint |
/mcp — two read-only tools over Streamable HTTP, MCP profile only |
MCP clients | mcp — the MCP server and its tools (ADR-0011 (docs/adr/adr-0011-mcp-server-placement.md)) |
GET /website — back to the public website, a 302 from the sign-in pages |
web app | signin — the signed-in person's endpoint |
/oauth2/authorization/google, /login/oauth2/code/google — the OIDC sign-in, Spring Security's paths |
browser | signin — the sign-in configuration |
/actuator/health (with liveness and readiness probes, used by Cloud Run's startup and liveness probes; the database is part of readiness and never of liveness, 8.14), /actuator/info and /actuator/modulith |
Cloud Run, the uptime check, developers | the application configuration, which exposes these three actuator endpoints; without a session /actuator/health shows the status only, a signed-in person sees each component |
POST /v1/convert/source and GET /health on docling-serve |
backend | intake — the docling adapter, through docling-java (ADR-0004) |
5.2 Level 2¶
The white box of the backend (5.2.1) and the module cuts the documents
draw (5.2.2), then each other container of 5.1 as a
black box in arc42's form — what it is responsible for, its interfaces, what it must achieve, the
decisions behind it and its status — as a summary. The detailed view of each block is a page of
its own in blocks/ (docs/architecture/blocks/).
5.2.1 White Box Backend¶
The one product deployable (ARC-Q6.1,
NFR-12): a Spring Boot application, one Spring Modulith module per business capability. It serves the web app, the endpoints of
5.1.1, the sign-in and, under the MCP profile, the MCP server, and
embeds the case engine in its cases module; the same image can run a second time as the worker
that takes the stage requests off the event broker, by configuration
(8.16.3). Details: blocks/backend.md; the
planned components of the backend: blocks/full-product-scope.md.
The modules and the dependencies between them, read off the imports between the module
packages, each package's declaration and the build's architecture and modularity tests
(8.4). An arrow points from the module that uses to the module it uses; intake
knows nothing downstream, and kernel depends on nothing. Each element carries its UML
stereotype: «module» is a Spring Modulith application module (8.16),
«shared kernel» the module of shared value types
(ADR-0007 (docs/adr/adr-0007-shared-kernel-of-value-types.md)), «deployable» the backend as the one
deployable, and «container» and «external system» an element of 5.1.
flowchart LR
subgraph app["«deployable» Backend"]
webapp["«module»<br/>webapp"]
signin["«module»<br/>signin"]
mcp["«module»<br/>mcp"]
consumer["«module»<br/>consumer"]
cases["«module»<br/>cases"]
extraction["«module»<br/>extraction"]
intake["«module»<br/>intake"]
kernel["«module» «shared kernel»<br/>kernel"]
recon["«module»<br/>reconciliation"]
end
dl["«container»<br/>docling-serve"]
llm["«external system»<br/>LLM provider"]
google["«external system»<br/>Google"]
consumer --> cases
consumer --> extraction
consumer --> intake
cases --> extraction
cases --> intake
extraction --> intake
mcp --> extraction
cases -. "requests" .-> recon
intake -- "HTTP" --> dl
intake -- "HTTPS" --> llm
extraction -- "HTTPS" --> llm
signin -- "OIDC" --> google
classDef person fill:#ffe8b0,stroke:#9a6b00,color:#000
classDef built fill:#b7e4c7,stroke:#2d6a4f,color:#000
classDef planned fill:#c6dcff,stroke:#1168bd,stroke-dasharray:4 3,color:#000
classDef external fill:#e6e6e6,stroke:#6b6b6b,color:#000
class webapp,signin,mcp,consumer,cases,extraction,intake,kernel built
class recon planned
class dl,llm,google external
style app fill:none,stroke:#666
| Colour | Meaning |
|---|---|
| green | built |
| blue, dashed border; dotted arrows | planned |
| grey | outside the backend (a container of 5.1 or an external system) |
Every module is a directory below the root package net.lauper.feecheck — the table's Code
column — with its rings as subdirectories domain/, application/ and infrastructure/
(8.15); the root package holds only the application's
bootstrap.
| Name | Responsibility | Interfaces | Code (directory) | Status |
|---|---|---|---|---|
«module» intake |
Makes a received document readable and checks that it may be processed: integrity checks, OCR, and the conversion into a page-anchored rendition that every later stage reads; a failure is a result with a reason, a caller error is thrown (spec 7 (docs/specs/7-docling-intake.md), ADR-0004 (docs/adr/adr-0004-document-conversion-docling.md)). Classifies the document (8.19.2) and checks that a converted document is a contract — the contract gate (spec 367 (docs/specs/367-contract-gate.md)) — and recognises its language (spec 377 (docs/specs/377-document-language.md)); runtime in 6.2.1 |
the converter port; adapters: stub (prepared pages), Docling (docling-serve); the contract-gate port; adapters: stub, model; the translator port (spec 368 (docs/specs/368-translation-port.md)); adapters: stub, model; the language detector, one adapter: Apache OpenNLP (8.13.1); the requests DocumentCheckRequested, ClassificationRequested and ConversionRequested and their replies (6.2, 8.16.3) |
backend/app/src/main/java/net/lauper/feecheck/intake |
built for the conversion of a contract PDF — markdown per page, in order, empty pages kept — the page limit, the contract gate and the language recognition; the integrity check with the first-page OCR, the classification, and the requests and replies, planned |
«module» extraction |
Reads the contract data the target schema requires out of a rendition, each value with the passage it was read from; validates the answer, checks every citation against the document, derives confidence and completeness, and falls back instead of throwing; owns the model adapters and their guardrails (extraction guide (docs/guides/structured-llm-response.md), 8.7) |
the extractor port; adapters: stub (prepared raw JSON), Mistral and Gemini on Vertex AI (Spring AI's chat client); the request ExtractionRequested and its replies (6.2, 8.16.3) |
backend/app/src/main/java/net/lauper/feecheck/extraction |
built for the two contract partners — name, partner number, e-mail and addresses — and the contract ID; the further attributes of the target schema, normalisation and mapping, and the request and its replies planned |
«module» cases |
Owns the FeeCheck case: opens a case for every received document, keeps its state, its results and its history, runs it through its stages and child cases, and puts the decisions a person must take in front of that person (6.1). A component of its own, not part of intake: extraction already depends on intake, so a case port inside intake would close a cycle (8.15) | the queue, case-store and document-store ports; /api/cases and the extraction stage's endpoints; publishes its domain ring; the case port — start a case, read it, complete a human task, retry a task — the Event Registry bridge and the inbound push adapter (6.1, 8.16.3) |
backend/app/src/main/java/net/lauper/feecheck/cases |
built for the intake stage (ADR-0009 (docs/adr/adr-0009-async-intake-pubsub-bucket-firestore.md), spec 263 (docs/specs/263-intake-job.md)) and the extraction stage, converting in the call by default and queuing when a queue is configured — on the stubs and on the Google adapters; the stubs, like intake's and extraction's, sit in the production sources (TD-1); container view 7.1.2.2; the case engine (Flowable), the case port, the bridge and the inbound push adapter planned; the case kept in PostgreSQL under the database profiles |
«module» consumer |
The queue's consumer (ADR-0009 (docs/adr/adr-0009-async-intake-pubsub-bucket-firestore.md) §5): runs a queued case's waiting stage when the queue delivers it. It reaches the other modules only through what they publish, so it can become a worker deployable without a change of code (8.15) |
inbound: the push endpoints (/api/intake/jobs/push, /api/intake/jobs/dead-letter) with their push-token check — the consumer's inbound adapters |
backend/app/src/main/java/net/lauper/feecheck/consumer |
built; dissolves with the event backbone — its stage runs become the stage modules' request listeners, its push endpoints the inbound adapter of cases, and the worker deployable a configuration of the same image |
«module» reconciliation |
Checks the recorded contract against the master data and the references and turns the result into findings a person can review — assignment, reconciliation, cross-check and the findings, as use cases; case-agnostic, like intake and extraction. The child case Fee reconciliation runs in the case's engine, and its human tasks belong to the case (6.3) | the request ReconciliationRequested and its replies (6.3); the master-data adapters |
— | planned |
«module» «shared kernel» kernel |
Shared value types (ADR-0007 (docs/adr/adr-0007-shared-kernel-of-value-types.md)) |
— | backend/app/src/main/java/net/lauper/feecheck/kernel |
built, empty so far |
«module» mcp |
Offers FeeCheck's results to AI integrations through FeeCheck's own MCP server (ADR-0011 (docs/adr/adr-0011-mcp-server-placement.md)); an adapter and nothing else, so it has only its infrastructure ring (8.15.7) |
/mcp, MCP profile only |
backend/app/src/main/java/net/lauper/feecheck/mcp |
built |
«module» signin |
Signs a person in through the installation's identity provider — Google through OIDC in the PoC (ADR-0008 (docs/adr/adr-0008-google-sign-in-and-backend-on-cloud-run.md)); an adapter and nothing else, infrastructure ring only (8.15.7) |
GET /api/me |
backend/app/src/main/java/net/lauper/feecheck/signin |
built |
«module» webapp |
Serves the web app as static resources; an adapter and nothing else, infrastructure ring only (8.15.7) | — | backend/app/src/main/java/net/lauper/feecheck/webapp |
built |
| «container» docling-serve | Turns a document into page-anchored markdown for intake's docling adapter (5.2.6) | HTTP | — | built |
| «external system» LLM provider | The language model extraction and intake ask (5.1) | HTTPS | — | external |
| «external system» Google | The identity provider of the PoC's sign-in (5.1) | OIDC | — | external |
Extraction reads intake's rendition through its port, and its application service
takes the rendition the case component holds (the case's extraction service); the intake runs in the
case component and the consumer, not in the extraction. A confirmed value carries the page of its
passage (spec 8 (docs/specs/8-intake-into-extraction.md)). Intake does not know extraction.
The page is extraction's page reference. It is the first candidate for kernel, the shared kernel
of small value types that more than one module uses
(ADR-0007 (docs/adr/adr-0007-shared-kernel-of-value-types.md)), and moves there when verification
uses it. A module reaches another only through its published types; which rings are published,
and how the build enforces it, is in 8.15 and
8.16.
The module view is also generated: the build's modularity test writes a component diagram
and one canvas per module into the backend's build output
(ADR-0009 (docs/adr/adr-0009-async-intake-pubsub-bucket-firestore.md) §3 point 10;
8.4). The hand-drawn views beside it are Mermaid in
these chapters (README, "Diagrams").
5.2.2 Module cut¶
The code has eight Spring Modulith modules — cases, consumer, extraction, intake,
kernel, mcp, signin, webapp — verified by Spring Modulith's module verification in the
build (8.16; adopted by ADR-0009 (docs/adr/adr-0009-async-intake-pubsub-bucket-firestore.md) §3 point 10).
ADR-0003 §2.3, the cut the imported ADR proposes, is outdated
(TD-10). Which cut is the target, and with it
ARC-Q6.1's "three", is open; the cuts the documents draw are listed with the question
(OQ-11).
5.2.3 Web app¶
| Responsibility | The user interface for working on cases: upload a contract, follow its case, read the extracted values with their evidence; later review and release findings |
| Interfaces | the backend's API under /api, through the committed OpenAPI contract (8.9) |
| Must achieve | one origin with the backend, no CORS; works through the edge login and through the API gateway |
| Decided by | ADR-0008 (docs/adr/adr-0008-google-sign-in-and-backend-on-cloud-run.md); the design in docs/frontend/design.md |
| Status | built: the intake screen, behind the edge login; the review screens and the way through the API gateway planned |
Details: blocks/web-app.md.
5.2.4 Public website¶
| Responsibility | Tells a visitor what FeeCheck does and the case's path, and leads to the sign-in |
| Interfaces | none at run time; one link into the web app, set when the site is built |
| Must achieve | no business data, no session, no form; served as static files from any web server |
| Decided by | ADR-0005 (docs/adr/adr-0005-second-frontend-public-website.md), spec 98 (docs/specs/98-public-website.md) |
| Status | built |
Details: blocks/public-website.md.
5.2.5 API gateway¶
| Responsibility | The single public entry in front of the whole origin: sign-in, session, routing to the backend with the token relayed |
| Interfaces | the web app's files, /api/** and the sign-in paths; the backend behind it as a resource server |
| Must achieve | the only public service; the backend stays reachable through it alone (8.8) |
| Decided by | ADR-0010 (docs/adr/adr-0010-api-gateway-and-api-contract.md) |
| Status | planned |
Details: blocks/api-gateway.md.
5.2.6 docling-serve¶
| Responsibility | Turns a document into page-anchored markdown, with OCR where a page has no text layer |
| Interfaces | HTTP, reached by intake's docling adapter only |
| Must achieve | no document leaves the installation's control; a pinned image; scale to zero |
| Decided by | ADR-0004 (docs/adr/adr-0004-document-conversion-docling.md), ADR-0006 (docs/adr/adr-0006-services-on-google-cloud.md), spec 7 (docs/specs/7-docling-intake.md) |
| Status | built |
Details: blocks/docling-serve.md.
5.2.7 Event broker¶
| Responsibility | Carries the externalized domain events — a stage's requests and replies, facts out of a case — between deployables and to downstream systems |
| Interfaces | publish through Spring Cloud Stream; push into the backend |
| Must achieve | at-least-once delivery with a dead letter per subscription; one case's events in order; nothing of a contract's content on the wire; costs nothing while idle |
| Decided by | ADR-0009 (docs/adr/adr-0009-async-intake-pubsub-bucket-firestore.md) (8.16.3) |
| Status | the intake's queue adapter built; the event backbone and the cloud resources planned |
Details: blocks/event-broker.md.
5.2.8 Document store¶
| Responsibility | Keeps an uploaded document for as long as its case exists, so a person can read it from the case |
| Interfaces | object storage, behind the case's document-store port |
| Must achieve | private; the document removed when its case is deleted or its conversion fails, and kept otherwise (8.3) |
| Decided by | spec 339 (docs/specs/339-case-api.md) R-10, CA-24, which replaces the one-day retention of ADR-0009 (docs/adr/adr-0009-async-intake-pubsub-bucket-firestore.md) §3 point 5 |
| Status | built; the bucket on Google Cloud has no lifecycle rule |
Details: blocks/document-store.md.
5.2.9 Case database¶
| Responsibility | Keeps the case, its results and its history, the case engine's state and the outbox of the event backbone; later the attribute values, findings, audit trail and embeddings |
| Interfaces | SQL, from the backend only |
| Must achieve | a case's change, the engine's step and the event that reports it commit in one transaction; switchable and available on-premise |
| Decided by | 8.3; ADR-0018 (docs/adr/adr-0018-postgresql-authoritative-document-database-derived.md): authoritative for everything that belongs to a case, replacing the Firestore case store of ADR-0009 |
| Status | built for the case, its pages and the outbox; the case engine's tables planned |
Details: blocks/case-database.md.