|
| 1 | +# ADR 0008: WebAPI backend blend controlled via `Config.global` |
| 2 | + |
| 3 | +## Status |
| 4 | + |
| 5 | +Accepted (2026-05-03) |
| 6 | + |
| 7 | +## Context |
| 8 | + |
| 9 | +The WebAPI process wires several replaceable infrastructure pieces: where |
| 10 | +domain data lives, how telemetry is exported, which implementation backs search |
| 11 | +queries, and whether CRM side effects run against a real provider. Operators |
| 12 | +need a single, explicit place to choose that **blend** per deployment, without |
| 13 | +scattering ad hoc rules across `env`, hosting flags, and implicit defaults. |
| 14 | + |
| 15 | +## Decision |
| 16 | + |
| 17 | +1. **Control surface** |
| 18 | + Four environment variables live in `src/Config.global` (loaded with other |
| 19 | + universe-wide settings when building global configuration). Each variable |
| 20 | + selects one implementation for that concern. Together they define the |
| 21 | + **backend blend** for the WebAPI (and any other backend components that share |
| 22 | + the same top-level wiring and configuration load in that process). |
| 23 | + |
| 24 | +2. **Global scope** |
| 25 | + The chosen values apply to **all** backend composition for that run: one |
| 26 | + blend per process, not per workspace, user, or request. |
| 27 | + |
| 28 | +3. **Variables and allowed values** |
| 29 | + |
| 30 | + | Variable | Allowed values | Meaning | |
| 31 | + <!-- markdownlint-disable MD013 --> |
| 32 | + | -------- | -------------- | ------- | |
| 33 | + | `WEBAPI_STORAGE_ENGINE` | `sqlite`, `postgres` | Primary domain persistence engine | |
| 34 | + | `WEBAPI_TELEMETRY` | `sentry`, `local` | Telemetry sink (e.g. Sentry vs local/no-op style) | |
| 35 | + | `WEBAPI_SEARCH` | `sql`, `algolia` | Search query / document storage engine for search | |
| 36 | + | `WEBAPI_CRM` | `wix`, `noop` | CRM integration vs no-op | |
| 37 | + <!-- markdownlint-enable MD013 --> |
| 38 | + |
| 39 | + Values are lowercase string tokens. Invalid or missing values should be |
| 40 | + rejected at startup with a clear error once wiring reads these variables. |
| 41 | + |
| 42 | +4. **Credentials and URLs** |
| 43 | + Provider-specific secrets and connection strings remain in service-level |
| 44 | + config (for example `src/webapi/Config.project` and related env). The |
| 45 | + `WEBAPI_*` flags only choose **which** implementation to construct; they do |
| 46 | + not replace DSNs, API keys, or database URLs. |
| 47 | + |
| 48 | +## Conventions by universe |
| 49 | + |
| 50 | +- **Thrive** (`UNIVERSE=thrive`): use the hosted-style blend—`postgres`, |
| 51 | + `sentry`, `algolia`, and `wix` for the four `WEBAPI_*` variables respectively. |
| 52 | +- **Other universes** (not thrive): use the local-first blend—`sqlite`, `local`, |
| 53 | + `sql`, and `noop`. |
| 54 | +- **Dev** (`UNIVERSE=dev`): no fixed convention; teams may set any valid |
| 55 | + combination while developing or testing. |
| 56 | + |
| 57 | +## Consequences |
| 58 | + |
| 59 | +- Operators set the four `WEBAPI_*` entries in `Config.global` (or equivalent |
| 60 | + injected env) for each deployment’s intended blend. |
| 61 | +- Composition code in the WebAPI entrypoint should branch on these settings (or |
| 62 | + on typed values derived from them) so behavior stays aligned with the declared |
| 63 | + configuration instead of re-deriving the same choices from unrelated signals. |
0 commit comments