Files

48 lines
7.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Architectural decisions
2026-10-13. Functional US-01–US-15 behaviour is binding. User clarification `3` permits all topology alternatives and explicit US-16 revision. Decisions are proposed designs, not statements about existing source.
## Alternatives and drivers
Drivers: atomic profile/account lifecycle; actual-owner and assigned read-only access; current selected calculations; complete context; public guidance; installability; reproducibility; synthetic prototype scope; energy overhead at idle and per request. Workload, hardware, team size, availability target and numerical assessment expense are unknown. Assume modest interactive use for selection, not a measured production load.
| Feasible under clarified scope | Strengths | Weaknesses / energy hypothesis | Selection |
| --- | --- | --- | --- |
| Five independent services, gateway-routed calls, separate databases, optionally colocated | Directly preserves US-16; per-feature deployment/scaling; process isolation; clear physical owners | Multiple runtimes/listeners/pools; gateway callback serialization/network/TLS; aggregate failure chains. Colocation and one PostgreSQL server can reduce host overhead. Independent scale can outperform consolidation under skewed load | Feasible baseline; rejected for default because prototype requirements do not justify its operational/call overhead |
| Reduced service topology: one API/profile/observation service, one analytics/overview service; direct private HTTPS with trusted identity delegation; one shared PostgreSQL server with owned databases | Keeps expensive assessment isolation/scaling; fewer hops than baseline; separates transactional writes from CPU-heavy reads | Still needs inter-process authorization/delegation, certificates, contract versioning and freshness handling; duplicates idle runtime and transports selected series | Feasible alternative; retain as reconsideration option if analytics workload/isolation becomes a driver |
| Modular monolith with owned schemas in one database | In-process composition; single deployment; atomic association; shared snapshots; no internal serialization; one app runtime/pool | Whole-app deployment/failure/scaling; logical module ownership does not isolate compromise; loss of original US-16 service installation | Selected conditionally on modest workload, clarified topology freedom and prototype scope |
An unstructured monolith would lose useful ownership/replaceability without another topology benefit. Event-driven projections, CQRS stores or scheduled precomputation add a broker/state/refresh mechanism to satisfy freshness already achieved by direct reads; unsupported for this workload. Serverless could reduce application idle runtime on a compatible platform, but introduces platform constraints/cold starts/DB connection behaviour unsupported by the documented Linux installation setting. These are rejected options, not asserted impossible designs.
## ADR-01 — Consolidate runtime, retain logical modules
Decision: single application process with API/access, Profile, Observations, Analytics, Overview and Guidance modules. Alternative comparison above determines selection independently of similarity to baseline. Consequences: simplify deployment and calls; whole-process failure and co-scaling; retain module interfaces/private repositories. Revisiting independent rollout, sustained analytics dominance or mandatory isolation can favour either service alternative. US-16 changes are explicit in [revision](us16-revision.md).
## ADR-02 — One database, module-owned schemas
Choose PostgreSQL for continuity with the installer constraint and transactional lifecycle, not because a particular version is required. Use profile/observations schemas and controlled FK with restricted deletion; runtime DML role and separate migration ownership. Separate DBs remain viable for future extraction but complicate consistent overview snapshots and add pool/configuration management. No generic shared clinical repository. Logical ownership does not equal security isolation. One PostgreSQL server with two databases could already share server idle overhead; merging databases alone promises no significant energy effect.
## ADR-03 — Durable association in the Profile aggregate
Unique account ID and profile information commit atomically; retry after lost success reports existing profile. Alternatives: an access-store mapping or saga requires coordination/recovery state; external static mapping cannot satisfy initial lifecycle. Profile-less accounts retain login/create access. No response reports creation before commit.
## ADR-04 — Logical API edge and framework tokens
Retain standardized ASP.NET Core normalized identities/policies and established password hashing; choose framework-protected opaque tickets with persistent keys and configurable 30-minute default. No separate gateway process or identity server. JWT is feasible but brings issuer/audience/signing contract that no external token consumer requires here; server-held sessions add state/restart coordination. No bespoke crypto. Actual ownership/assignments are evaluated separately on each protected request and never trusted from a caller/header/token patient identifier.
## ADR-05 — Current data, bounded snapshot lifetime, no result cache
Capture authorized current immutable source values in a repeatable-read snapshot, including overview's distinct latest/insight bases; close DB transaction before calculation/transfer. No generated-result persistence or asynchronous invalidation. Alternatives: independent read-committed queries can interleave edits; versioned caching could help highly repetitive expensive queries but needs freshness/access/content-version keys. Current selected data and simple correctness outweigh unproven cache benefit. No silent history truncation.
## ADR-06 — Keep analytics and clinical interpretation separate
Versioned deterministic mathematical policy uses full-period evidence and temporal sufficiency; ClinicalPolicy requires reviewed claim-specific references; Guidance owns public reference provenance. Do not inherit a specific baseline trend formula solely from as-built documentation. No diagnostic score or arbitrary clinical variation cutoff. Missing irrelevant preparation does not suppress a supported reference comparison. Content review and reproducible method details are future implementation acceptance obligations.
## ADR-07 — Context is an observation-owned value
Flatten optional context within the observation record; clear means Unknown, omission preserves. Keep independent selection dimensions and original text/note. Separate context tables/entities would add lifecycle/joins without an independent domain need. Do not infer structured context from ambiguous historical prose. Preserve conflicting evidence and expose interpretation limits.
## ADR-08 — Simple native Linux deployment
One systemd application service; optional remote PostgreSQL; transient provisioning tool. Auto-provision credentials/certificates/configuration and verify representative operations. No containers/orchestration required. Existing five-process rollout and Windows/macOS implementations are inputs, not mandatory default targets. Hardware sharing and colocation may reduce overhead but have failure/contention effects. No measurement procedure or claimed saving is specified.