# ADR-0005: Injectable providers for external dependencies

**Status:** Accepted

## Context

Several routes depend on third-party services: OAuth identity providers
(Google/Apple/Facebook) and a weather data source. Early code "simulated" these
with `Math.random()`/hardcoded acceptance (e.g. accepting `google_test_<email>`)
— which is a stub: it neither does the real work in production nor lets tests
assert real behaviour. But calling live third-party APIs from unit/integration
tests is slow, flaky, and non-deterministic.

## Decision

Make every external dependency a **real implementation that is injected through
`buildServer()`**, defaulting to the production provider and overridable in
tests:

- `buildServer({ verifiers })` — OAuth token verifiers do genuine JWKS / Graph
  verification by default (`src/auth/oauth-verifiers.ts`, using `jose`); tests
  inject deterministic verifiers.
- `buildServer({ weather })` — the weather provider calls Open-Meteo by default
  (`src/weather/…`); tests inject a fixed provider.

The rule: **no `Math.random()`-simulated external calls**. If a dependency can't
be exercised in tests, wrap it behind an interface and inject a real default + a
test double — never fake the computation inline.

## Consequences

- **+** Production does the real work; tests are deterministic and offline.
- **+** Swapping a provider (e.g. a different weather source) is a one-line
  injection, not a route rewrite.
- **+** Eliminates a whole class of stub from the codebase.
- **−** Slightly more ceremony: each external dep needs an interface + a default
  wiring in the composition root.
