# Documentation Roadmap

## Purpose

This roadmap defines the work required to bring `weatherapi` documentation into compliance with `docs/policy/documentation.md` and the current implementation. It is a planning document only; implementation agents should update the target documentation files in later stages and must continue to document only implemented behavior outside `docs/roadmap/`.

## Repository Documentation Inventory

- `README.md`: keep and rewrite. It currently identifies the project and lists routes, but it does not provide the policy-required shortest useful command, operational prerequisites, or links to canonical docs.
- `docs/api.md`: keep and rewrite. It is the canonical public HTTP API home, but it needs correction and tightening against route binders, presenters, feedapi rendering, and tests.
- `docs/policy/documentation.md`: keep and lightly update only if future policy gaps are found. It is the controlling policy and already covers HTTP API services.
- `docs/policy/architecture.md`: keep and lightly update only when architecture or public integration boundaries change. It accurately describes the current read-only hexagonal structure.
- `docs/roadmap/outlook.md`: keep. It is roadmap-only material for unimplemented outlook support and must not be promoted into current-behavior docs until implemented.
- `docs/roadmap/documentation.md`: create. This file is the staged plan for the documentation refresh.
- `config.yml`: keep as the checked-in local sample runtime config, but do not treat it as the full canonical configuration reference. Link from future config docs and avoid copying local credentials into production examples.
- `templates/*.txt.tmpl`: keep. These are implemented text rendering assets and should be referenced from API/internal docs where relevant.
- `examples/`: create new. No maintained examples directory exists, but policy recommends validated examples for this config-driven HTTP service.
- `docs/config.md`: create new. Required because `weatherapi` is config-driven.
- `docs/cli.md`: create new. Required because `weatherapi` has an executable CLI surface.
- `docs/operations.md`: create new. Required because `weatherapi` is an operator-facing HTTP service.
- `docs/troubleshooting.md`: create new. Recommended for operator-facing services and useful for query/config/database failure modes present in the code.
- `docs/policy/development.md`: create new. Required for developers and LLM coding agents.
- `docs/internal/`: create new. Required for the modular HTTP/app/repository/presenter architecture.
- `docs/integrations/`: create new. Recommended because `weatherapi` depends on feedapi runtime behavior, PostgreSQL, and weatherfeeder-owned table contracts.
- `docs/consumers/`: do not create in the first migration. `docs/api.md` should be the authoritative HTTP contract; add task-oriented consumer guides later only if concrete integration workflows are needed.

## Policy Compliance Assessment

Required documents currently missing:

- `docs/cli.md` for the `cmd/weatherapi` executable and `-config` flag.
- `docs/config.md` for feedapi YAML configuration used by `weatherapi`.
- `docs/operations.md` for deployment, startup, shutdown, database, and template operations.
- `docs/internal/` for implemented internal component boundaries.
- `docs/policy/development.md` for contributor and LLM-agent workflow.

Recommended documents currently missing:

- `docs/troubleshooting.md` for common startup, database, query, rendering, and no-data cases.
- `docs/integrations/` entries for feedapi runtime/config/render behavior and the weatherfeeder/Postgres storage contract.
- `examples/` with maintained config and request examples.

Existing docs that need correction or relocation:

- `README.md` duplicates endpoint inventory better owned by `docs/api.md` and lacks quickstart guidance.
- `docs/api.md` should remain in place, but it should be rewritten as a normative HTTP contract with exact implemented behavior.
- `docs/roadmap/outlook.md` is correctly located; do not link it from user quickstarts as current functionality.

Likely stale or inaccurate current-behavior claims to fix during the API rewrite:

- `docs/api.md` describes discussion section fields as `title` and `narrative`; implemented model/presenter fields are `qualifier`, `issuedAt`, and `text`.
- `docs/api.md` examples should not imply a discussion product value of `discussion`; current code/tests use the weatherfeeder AFD product value.
- `docs/api.md` says current conditions are synthesized from latest observation/forecast data; implemented SQL aggregates recent `observations` rows only.
- `docs/api.md` says `tz` and `TZ` must match exactly; implemented validation allows case-insensitive equality via `strings.EqualFold`.
- `docs/api.md` says error fields may vary; feedapi exposes a stable error envelope with `error.code` and `error.message` for implemented API errors.
- Existing docs should clarify that `precision` is accepted only on observations, current conditions, and forecast routes; it is rejected on alerts, discussion, and weather stories.
- Existing docs should clarify that `tz` / `TZ` is accepted only on forecast, discussion, and weather story routes; it is rejected elsewhere.
- Existing docs should clarify that JSON is the default format, but format negotiation is `format` query parameter first, then `Accept` header, then configured default.

Examples and links:

- There is no `examples/` directory, so examples are missing rather than stale.
- Existing docs have few links. Future links should be checked after creating the target docs.
- Avoid example secrets. The checked-in `config.yml` contains local `weatherdb` credentials and should not be copied as production guidance without placeholders and secrets notes.

## Target Documentation Set

### `README.md`

- Audience: users, administrators, operators.
- Purpose: concise project orientation and shortest useful startup path.
- Canonical scope: what `weatherapi` is, core prerequisite that weatherfeeder-populated Postgres tables must exist, shortest useful command, and links to detailed docs.
- Recommended outline: description, short pitch, prerequisites, shortest useful command, endpoint family summary, documentation links.
- Source of truth: `cmd/weatherapi/main.go`, `config.yml`, `docs/api.md`, `docs/config.md`, `docs/cli.md`, `docs/operations.md`.
- Acceptance criteria: short enough to scan, no full endpoint reference, no unimplemented outlook endpoints, links to canonical docs.

### `docs/api.md`

- Audience: external HTTP API consumers and integrating developers/LLM agents.
- Purpose: normative public HTTP API contract.
- Canonical scope: routes, query parameters, content negotiation, response envelope, payload fields, nullability, units, precision, timezone behavior, errors, and compact examples.
- Recommended outline: base URL, authentication behavior, response envelope, media types and negotiation, shared query rules, errors, endpoint families, field definitions, examples.
- Source of truth: `internal/adapters/inbound/httpapi/*_endpoint.go`, `query_bind.go`, `query_normalize.go`, `query_timezone.go`, `internal/adapters/inbound/httpapi/presenter`, `templates/`, `internal/adapters/inbound/httpapi/endpoints_test.go`, feedapi `render`, `response`, and `errors` packages.
- Acceptance criteria: documents only implemented routes; discussion/current-conditions/query/error semantics match code and tests; marks optional forecast `conditionCode`; states no auth, pagination, cache headers, or rate limiting are implemented by `weatherapi` if those remain true.

### `docs/cli.md`

- Audience: users, administrators, operators.
- Purpose: canonical CLI reference for the executable.
- Canonical scope: `weatherapi` command invocation, `-config`, `WEATHERAPI_CONFIG`, default `config.yml`, signal/shutdown behavior at a high level.
- Recommended outline: synopsis, flags, environment variables, config precedence, exit/startup failures, examples.
- Source of truth: `cmd/weatherapi/main.go`, `Dockerfile`, feedapi app startup behavior.
- Acceptance criteria: does not duplicate config field reference; includes the real flag and env var only; examples are copyable.

### `docs/config.md`

- Audience: administrators, operators, advanced users.
- Purpose: canonical YAML configuration reference.
- Canonical scope: config file discovery, minimal config, production-oriented config, full field reference, defaults, validation, template directory, database ordering, secrets handling.
- Recommended outline: discovery precedence, minimal config, production config, server fields, database fields, template fields, validation/defaults, examples.
- Source of truth: `cmd/weatherapi/main.go`, `config.yml`, feedapi `config` package, feedapi `db` package, feedapi `app.defaultRenderers`.
- Acceptance criteria: states first configured database is primary for weather reads; states feedapi defaults for listen/read/write/idle/default format; does not claim strict unknown-field rejection unless implemented; links to examples.

### `docs/operations.md`

- Audience: administrators and operators.
- Purpose: run, deploy, and recover the service.
- Canonical scope: runtime prerequisites, Postgres/schema dependency, templates, Docker image behavior, startup/shutdown, logs, no migrations, no ingestion.
- Recommended outline: runtime model, prerequisites, local run, container run, database dependency, templates and text output, graceful shutdown, health/verification, backup/recovery boundaries.
- Source of truth: `cmd/weatherapi/main.go`, `Dockerfile`, `.woodpecker/build-image.yml`, feedapi `app`, feedapi middleware, repository packages.
- Acceptance criteria: clear that weather data and schema are produced by weatherfeeder; does not document provider polling; includes practical checks without inventing health endpoints.

### `docs/troubleshooting.md`

- Audience: users, operators, support engineers.
- Purpose: diagnose common failures and surprising responses.
- Canonical scope: startup config failures, DB connection failures, missing tables, missing templates/text format, unsupported format, invalid query params, timezone errors, `data: null`, precision validation.
- Recommended outline: startup failures, database failures, API request errors, rendering/text issues, no-data responses, timezone and precision issues.
- Source of truth: `cmd/weatherapi/main.go`, feedapi `errors`, feedapi `render`, query binders, endpoint tests, repository read methods.
- Acceptance criteria: action-oriented; avoids repeating full API/config references; links to `docs/api.md`, `docs/config.md`, and `docs/operations.md`.

### `docs/policy/development.md`

- Audience: developers and LLM coding agents.
- Purpose: contributor workflow and safe-change checklist.
- Canonical scope: repository layout, build/test commands, how to add endpoints, config fields, repository reads, presenters, templates, docs, and examples.
- Recommended outline: layout, local setup, test commands, endpoint change workflow, adapter boundaries, dependency policy, docs checklist.
- Source of truth: `docs/policy/architecture.md`, `go.mod`, internal packages, existing endpoint/repository/presenter tests.
- Acceptance criteria: reinforces architecture invariants; gives concrete package/test paths; no current-behavior user reference duplication.

### `docs/internal/runtime.md`

- Audience: developers and LLM coding agents.
- Purpose: explain implemented runtime composition.
- Canonical scope: config load, DB registry, primary DB selection, service/repo construction, endpoint registration, feedapi server startup, graceful shutdown.
- Recommended outline: composition root, feedapi responsibilities, database registry, renderers/templates, shutdown/errors, tests to inspect.
- Source of truth: `cmd/weatherapi/main.go`, feedapi `app`, feedapi `db`, feedapi `templates`.
- Acceptance criteria: development-facing only; no deployment manual duplication; captures boundaries around `cmd`.

### `docs/internal/http-adapter.md`

- Audience: developers and LLM coding agents.
- Purpose: explain route definitions, query binding, and handler conventions.
- Canonical scope: endpoint definition pattern, strict query rejection, supported route families, forecast day-slice filtering, timezone parsing.
- Recommended outline: route registry, binder types, endpoint families, validation rules, day-slice filtering, tests to inspect.
- Source of truth: `internal/adapters/inbound/httpapi`, `endpoints_test.go`.
- Acceptance criteria: enough guidance to add a route safely; does not duplicate full public endpoint field reference.

### `docs/internal/presenters.md`

- Audience: developers and LLM coding agents.
- Purpose: explain payload shaping and presentation responsibilities.
- Canonical scope: metric/US conversion, rounding, timezone conversion, nil/optional handling, copy semantics, text-template interaction.
- Recommended outline: presenter responsibilities, unit conversion, precision, timezone, optional fields, text templates, tests to inspect.
- Source of truth: `internal/adapters/inbound/httpapi/presenter`, `templates/`, `presenter/payload_test.go`.
- Acceptance criteria: prevents conversion logic from moving into handlers or repository; documents current pointer/omitempty behavior.

### `docs/internal/postgres-repository.md`

- Audience: developers and LLM coding agents.
- Purpose: explain outbound read adapter behavior.
- Canonical scope: query organization, latest-row selection, child loading, row mapping, null handling, UTC normalization, no-data semantics.
- Recommended outline: repository contract, route-to-query mapping, row mappers, null/timestamp policy, no migrations, tests to inspect.
- Source of truth: `internal/adapters/outbound/postgres`, `repository_test.go`, `docs/integrations/weatherfeeder-postgres.md`.
- Acceptance criteria: distinguishes storage contract from public HTTP contract; no schema creation instructions beyond integration notes.

### `docs/integrations/weatherfeeder-postgres.md`

- Audience: operators, developers, LLM coding agents integrating with stored data.
- Purpose: document `weatherapi`'s dependency on weatherfeeder-owned Postgres tables.
- Canonical scope: required table families, read assumptions, latest ordering, nullable field expectations, weatherfeeder version compatibility, no migration ownership.
- Recommended outline: integration boundary, supported weatherfeeder version, table families read, ordering assumptions, nullability assumptions, operational requirements.
- Source of truth: `go.mod`, `internal/adapters/outbound/postgres/*_queries.go`, `*_rows.go`, `*_mapper.go`, weatherfeeder model dependency.
- Acceptance criteria: does not duplicate weatherfeeder's full schema docs; documents only tables/columns read by `weatherapi`.

### `docs/integrations/feedapi.md`

- Audience: developers and LLM coding agents.
- Purpose: document framework/runtime behavior that shapes `weatherapi` externally.
- Canonical scope: config loading/defaults, renderer registration, content negotiation, success/error envelopes, middleware, graceful shutdown.
- Recommended outline: dependency version, config ownership, render negotiation, error mapping, middleware, upgrade checklist.
- Source of truth: `go.mod`, feedapi `config`, `app`, `render`, `response`, `errors`, `transport/httpx` packages.
- Acceptance criteria: focuses on the contract `weatherapi` relies on; does not become feedapi's full manual.

### `examples/config.minimal.yml`

- Audience: operators and developers.
- Purpose: minimal local config that can load successfully when a database is available.
- Canonical scope: server listen/default format, one Postgres database, templates base dir.
- Recommended outline: YAML only with comments kept brief.
- Source of truth: `config.yml`, feedapi config defaults and validation.
- Acceptance criteria: uses placeholders or safe local values; can be loaded by config tests; contains no real secrets.

### `examples/config.production.yml`

- Audience: operators.
- Purpose: production-oriented config pattern with explicit timeouts and pool settings.
- Canonical scope: explicit server timeouts, database pool fields, templates dir, secret placeholders.
- Recommended outline: YAML only with brief comments for values that must be changed.
- Source of truth: feedapi config/db packages, `Dockerfile`, `docs/operations.md`.
- Acceptance criteria: load-valid, no real secrets, linked from `docs/config.md` and `docs/operations.md`.

### `examples/requests.http`

- Audience: API consumers and developers.
- Purpose: copyable requests for implemented endpoints.
- Canonical scope: one or two requests per endpoint family using supported query params.
- Recommended outline: base URL variable and representative GET requests.
- Source of truth: `docs/api.md`, endpoint tests.
- Acceptance criteria: includes only implemented endpoints; no outlook routes; linked from README/API docs.

## File-by-File Rewrite Guidance

### `README.md`

Cover what `weatherapi` does: a read-only HTTP API over weatherfeeder-populated Postgres data. Include the shortest useful command, for example `go run ./cmd/weatherapi -config config.yml`, with a note that the configured Postgres database and templates directory must be available. Link to API, CLI, config, operations, and troubleshooting docs.

Avoid full route/field reference, config field tables, Docker internals, or future outlook functionality. Keep any endpoint summary grouped by family and link to `docs/api.md`.

Inspect `cmd/weatherapi/main.go`, `config.yml`, `Dockerfile`, and final target docs before rewriting.

### `docs/api.md`

Rewrite as the normative external HTTP contract. Cover response envelope, `data: null`, media negotiation, accepted `format` values, `units`, `precision`, `tz` / `TZ`, strict unknown-parameter rejection, errors, endpoint families, field definitions, optionality, nullability, and compact examples.

Explicitly avoid config/deployment instructions, SQL table details, implementation history, and roadmap endpoints. Do not describe unimplemented authentication, pagination, cache controls, rate limits, or retries except to state their implemented absence where useful for consumers.

Inspect route definitions, query binders, presenters, templates, endpoint tests, feedapi render negotiation, feedapi success/error envelopes, and feedapi status mapping. Do not carry forward the stale discussion section field names or current-conditions source description.

### `docs/cli.md`

Document `weatherapi` invocation, `-config`, `WEATHERAPI_CONFIG`, default `config.yml`, and signal behavior. Include examples for local binary and `go run` usage.

Avoid full YAML reference and endpoint reference. Link to `docs/config.md` and `docs/api.md`.

Inspect `cmd/weatherapi/main.go` and `Dockerfile`.

### `docs/config.md`

Document feedapi YAML as used by `weatherapi`: file discovery, required database list, first database as primary, server defaults, database fields, templates directory, and secrets guidance. Include minimal and production examples or link to files under `examples/`.

Avoid claiming unknown YAML fields are rejected; feedapi currently uses `yaml.Unmarshal` into structs and validation only checks required/defaulted fields. Avoid documenting unused provider/source/sink fields from weatherfeeder.

Inspect feedapi `config`, feedapi `db`, feedapi `app.defaultRenderers`, `config.yml`, and example files.

### `docs/operations.md`

Document how to run the service locally and in a container, required weatherfeeder schema/data, template availability for text output, logs, graceful shutdown, and verification requests. Make clear that `weatherapi` does not ingest data or manage weatherfeeder migrations.

Avoid full API field reference and full config reference. Link to `docs/api.md`, `docs/config.md`, and integration docs.

Inspect `cmd/weatherapi/main.go`, `Dockerfile`, `.woodpecker/build-image.yml`, feedapi app startup/shutdown, and repository no-data behavior.

### `docs/troubleshooting.md`

Organize by symptoms: startup failure, config decode/validation, database open/query errors, missing weatherfeeder tables, `format=text` problems, `406 unsupported_format`, `400 invalid_parameter`, invalid timezone, precision out of range, and `data: null` responses.

Avoid duplicating every parameter and field. Link to API/config/operations docs for reference details.

Inspect feedapi `errors`, feedapi `render`, query binders, endpoint tests, repository methods, and templates.

### `docs/policy/development.md`

Document repository layout, local build/test commands, dependency policy, endpoint-addition checklist, config-change checklist, presenter/template checklist, and documentation update checklist. Reinforce architecture invariants from `docs/policy/architecture.md`.

Avoid public API reference duplication and aspirational modules. Planned work belongs in `docs/roadmap/`.

Inspect architecture policy, `go.mod`, internal packages, tests, and examples after they are created.

### `docs/internal/runtime.md`

Document the runtime composition path from config to feedapi app startup. Include primary database selection and renderer/template registration.

Avoid operator runbooks and full config field reference. Link to `docs/config.md` and `docs/operations.md`.

Inspect `cmd/weatherapi/main.go` and feedapi `app` package.

### `docs/internal/http-adapter.md`

Document endpoint definition conventions, binders, strict query rejection, timezone parsing, forecast day-slice behavior, and route registration tests.

Avoid full public payload field reference. Link to `docs/api.md` for consumer contract.

Inspect `internal/adapters/inbound/httpapi` and `endpoints_test.go`.

### `docs/internal/presenters.md`

Document unit conversion, precision, timezone conversion, optional field preservation, copy-before-presenting behavior, and template dependencies.

Avoid SQL or route registration details. Link to HTTP adapter and API docs.

Inspect `internal/adapters/inbound/httpapi/presenter`, `templates/`, and presenter tests.

### `docs/internal/postgres-repository.md`

Document latest-resource query patterns, child-loading order, mapper responsibilities, SQL null handling, UTC normalization, `nil, nil` no-data behavior, and contextual errors.

Avoid full schema DDL; link to `docs/integrations/weatherfeeder-postgres.md` for storage contract assumptions.

Inspect `internal/adapters/outbound/postgres` and repository tests.

### `docs/integrations/weatherfeeder-postgres.md`

Document the storage contract consumed from weatherfeeder v0.10.0: table families read by each repository method, ordering used to select latest rows, child ordering, nullable fields, timestamp expectations, and the fact that `weatherapi` does not create or migrate these tables.

Avoid duplicating the complete weatherfeeder schema or documenting future tables. Link to weatherfeeder docs if available.

Inspect `go.mod`, all Postgres query/row/mapper files, and weatherfeeder model types.

### `docs/integrations/feedapi.md`

Document how feedapi affects `weatherapi`: config load/default/validate behavior, renderer registration, content negotiation precedence, success and error envelopes, status-code mapping, middleware, DB registry, and graceful shutdown.

Avoid documenting all feedapi internals or APIs not used by `weatherapi`.

Inspect feedapi `config`, `app`, `render`, `response`, `errors`, `transport/httpx`, and `middleware` packages.

## Examples Plan

Create an `examples/` directory because this is a config-driven HTTP API service and policy recommends maintained examples.

Recommended examples:

- `examples/config.minimal.yml`: minimal load-valid local configuration with one Postgres database and `templates` base directory. Validate with a config load test if practical. Link from README and `docs/config.md`.
- `examples/config.production.yml`: production-oriented config with explicit HTTP timeouts and database pool settings, using placeholders for credentials. Validate with a config load test if practical. Link from `docs/config.md` and `docs/operations.md`.
- `examples/requests.http`: copyable HTTP requests for implemented route families: observations, current conditions, alerts, hourly forecast, narrative forecast, discussion, and weather stories. Validate manually or with a lightweight grep/check that every path appears in route definitions if practical. Link from README and `docs/api.md`.

Do not add outlook examples until outlook endpoints are implemented. Do not include real database passwords, deployment hostnames, or private URLs.

## Internal Documentation Plan

### Runtime Composition

- Path: `docs/internal/runtime.md`.
- Purpose: explain how `cmd/weatherapi` composes feedapi, database registry, repository, service, endpoints, renderers, and shutdown.
- Inputs and outputs: YAML config, OS signals, database handles, HTTP server.
- Boundaries: runtime wiring only; no endpoint logic or SQL logic.
- Config fields used: `server`, `databases`, `templates`.
- Adapters used: feedapi app/db/templates, Postgres repository, HTTP endpoint registry.
- Failure behavior: config load/validation, missing database, DB open, app construction, server startup, DB close logging.
- Tests to inspect before changing: add or inspect runtime/config tests if created; existing package tests for endpoint registration and app service delegation.
- Architectural invariants: keep `cmd` thin; first DB is primary; feedapi owns generic runtime.

### HTTP Adapter

- Path: `docs/internal/http-adapter.md`.
- Purpose: explain route definitions, handlers, query binders, timezone parsing, and forecast day-slice filtering.
- Inputs and outputs: HTTP requests, typed request structs, service calls, response envelopes.
- Boundaries: no SQL and no business aggregation beyond endpoint-specific request shaping/day slicing.
- Config fields used: none directly; feedapi provides default format/renderers.
- Adapters used: feedapi endpoint/render/response and presenter package.
- Failure behavior: feedapi invalid parameter errors for rejected/invalid query parameters.
- Tests to inspect before changing: `internal/adapters/inbound/httpapi/endpoints_test.go`.
- Architectural invariants: strict query rejection; transport-specific policy remains at HTTP boundary.

### Presenters and Templates

- Path: `docs/internal/presenters.md`.
- Purpose: explain response payload transformation, unit conversion, rounding, timezone conversion, and text templates.
- Inputs and outputs: canonical weatherfeeder models or app read models; JSON/XML/text-ready payloads.
- Boundaries: no SQL, no service calls, no route registration.
- Config fields used: templates are loaded from `templates.base_dir` by feedapi.
- Adapters used: feedapi templates indirectly through endpoint template names.
- Failure behavior: nil inputs return nil payloads; absent optional fields remain absent; text output depends on loaded templates.
- Tests to inspect before changing: `internal/adapters/inbound/httpapi/presenter/payload_test.go` and endpoint text tests.
- Architectural invariants: copy before mutation; preserve optional fields; keep unit/timezone policy out of repository.

### Postgres Repository

- Path: `docs/internal/postgres-repository.md`.
- Purpose: explain SQL read organization and mapping behavior.
- Inputs and outputs: Postgres rows; canonical weatherfeeder models and app read models.
- Boundaries: no HTTP query binding, no unit conversion, no template rendering, no migrations.
- Config fields used: database connection config is supplied by feedapi/db through `cmd/weatherapi`.
- Adapters used: `database/sql`, `lib/pq`, weatherfeeder model types.
- Failure behavior: missing latest rows return `nil, nil`; query/scan/iteration/decode failures return contextual errors.
- Tests to inspect before changing: `internal/adapters/outbound/postgres/repository_test.go`.
- Architectural invariants: UTC-normalize timestamps; map nullable SQL to pointers; preserve child ordering.

## Integration Documentation Plan

### Weatherfeeder Postgres Storage Contract

- Path: `docs/integrations/weatherfeeder-postgres.md`.
- External system or contract: weatherfeeder-owned Postgres schema and weatherfeeder canonical model dependency.
- Current usage: `weatherapi` reads observations, current-condition observation aggregates, alert runs/alerts/references, forecast runs/periods, forecast discussions/key messages, and weather story runs/stories.
- Version or compatibility notes: `go.mod` currently depends on `gitea.maximumdirect.net/ejr/weatherfeeder v0.10.0`; table compatibility must match repository SQL.
- What should be documented: read-only boundary, table families, latest ordering, nullable/optional field assumptions, timestamp normalization, no migrations.
- What should not be documented: full weatherfeeder setup, source polling, sink write implementation, unimplemented outlook tables.

### Feedapi Runtime Contract

- Path: `docs/integrations/feedapi.md`.
- External system or contract: feedapi framework/runtime package dependency.
- Current usage: config load/default/validate, DB registry, endpoint registry, renderers, templates, middleware, HTTP transport, success/error envelopes.
- Version or compatibility notes: `go.mod` currently depends on `gitea.maximumdirect.net/ejr/feedapi v0.1.0`.
- What should be documented: behavior that affects `weatherapi` users or maintainers, including format negotiation and error shape.
- What should not be documented: unused feedapi packages, generic feedapi extension APIs not used by `weatherapi`.

### PostgreSQL Driver and Service

- Path: optional; prefer folding into `docs/integrations/weatherfeeder-postgres.md` unless operations docs become too large.
- External system or contract: PostgreSQL accessed through `database/sql` and `github.com/lib/pq`.
- Current usage: configured by feedapi database entries and used by the Postgres repository.
- Version or compatibility notes: `github.com/lib/pq v1.10.9`; exact PostgreSQL server version is not specified in the repository.
- What should be documented: connection URI, username/password handling, pool fields, read-only expectations, no schema ownership.
- What should not be documented: general PostgreSQL administration unrelated to `weatherapi`.

## Recommended Implementation Sequence

### Stage 1: Orientation, CLI, and Config

- Goal: establish user/operator entry points and remove README as the accidental endpoint reference.
- Files to create/update/delete/move: update `README.md`; create `docs/cli.md`; create `docs/config.md`; create `examples/config.minimal.yml`; create `examples/config.production.yml`.
- Repository areas to inspect: `cmd/weatherapi/main.go`, `config.yml`, feedapi `config` and `db` packages, `Dockerfile`.
- Acceptance criteria: README has shortest useful command and links; CLI doc documents only implemented flag/env/default behavior; config doc includes defaults, validation, primary DB ordering, templates, and secrets guidance; example configs load successfully if tests are added.
- Suggested validation commands: `go test ./...`; add or run config load tests for `examples/*.yml` if practical.
- Prompt size: small enough for one implementation prompt.

### Stage 2: Public HTTP API Reference

- Goal: rewrite `docs/api.md` as the canonical external contract.
- Files to create/update/delete/move: update `docs/api.md`; create `examples/requests.http` if not already created in Stage 1.
- Repository areas to inspect: `internal/adapters/inbound/httpapi`, `internal/adapters/inbound/httpapi/presenter`, `templates/`, feedapi `render`, `response`, `errors`, endpoint tests.
- Acceptance criteria: all implemented endpoints and only implemented endpoints are documented; query acceptance/rejection matches tests; discussion/current-conditions stale claims are fixed; error envelope/status codes are exact; examples are compact and valid.
- Suggested validation commands: `go test ./internal/adapters/inbound/httpapi ./internal/adapters/inbound/httpapi/presenter`; `rg "outlook|convective|product.*discussion|title.*narrative|latest observation/forecast|exact fields may vary" README.md docs/api.md` and manually review results.
- Prompt size: small enough for one implementation prompt, but keep examples concise.

### Stage 3: Operations and Troubleshooting

- Goal: document running and recovering the service without duplicating API/config references.
- Files to create/update/delete/move: create `docs/operations.md`; create `docs/troubleshooting.md`.
- Repository areas to inspect: `cmd/weatherapi/main.go`, `Dockerfile`, `.woodpecker/build-image.yml`, feedapi `app`, feedapi `render`, feedapi `errors`, query binders, repository no-data behavior.
- Acceptance criteria: operators can distinguish config, DB, template, request-validation, unsupported-format, and no-data issues; docs state that ingestion/schema ownership belongs to weatherfeeder; no invented health endpoint.
- Suggested validation commands: `go test ./...`; manually verify documented startup command and Docker paths against `Dockerfile`.
- Prompt size: small enough for one implementation prompt.

### Stage 4: Internal Architecture Docs

- Goal: provide enough implementation guidance for developers and LLM coding agents to make safe changes.
- Files to create/update/delete/move: create `docs/internal/runtime.md`; create `docs/internal/http-adapter.md`; create `docs/internal/presenters.md`; create `docs/internal/postgres-repository.md`.
- Repository areas to inspect: `docs/policy/architecture.md`, `cmd/weatherapi/main.go`, internal app/httpapi/presenter/postgres packages, tests.
- Acceptance criteria: docs explain boundaries, inputs/outputs, failure behavior, tests to inspect, and invariants; no public API field reference duplication.
- Suggested validation commands: `go test ./internal/app ./internal/adapters/inbound/httpapi ./internal/adapters/inbound/httpapi/presenter ./internal/adapters/outbound/postgres`.
- Prompt size: may be large; split into runtime/http adapter and presenter/postgres docs if needed.

### Stage 5: Integration and Development Policy Docs

- Goal: document external contracts and contributor workflow.
- Files to create/update/delete/move: create `docs/integrations/weatherfeeder-postgres.md`; create `docs/integrations/feedapi.md`; create `docs/policy/development.md`.
- Repository areas to inspect: `go.mod`, feedapi packages, weatherfeeder model/schema docs if available, Postgres SQL/row/mapper files, architecture policy.
- Acceptance criteria: integration docs document only contracts used by `weatherapi`; development policy gives concrete package/test paths and update checklists; no roadmap material outside `docs/roadmap/`.
- Suggested validation commands: `go test ./...`; `rg "outlook|planned|future|experimental|TODO|deprecated" docs README.md examples` and manually confirm roadmap-only exceptions.
- Prompt size: small enough for one implementation prompt if kept concise.

### Stage 6: Consistency and Link Pass

- Goal: make the documentation tree coherent after all target docs exist.
- Files to create/update/delete/move: update cross-links in `README.md`, `docs/*.md`, `docs/internal/*.md`, `docs/integrations/*.md`, and `examples/requests.http` comments if needed.
- Repository areas to inspect: complete docs tree, route definitions, examples, tests.
- Acceptance criteria: no broken relative links found by manual or automated checks; no current-behavior docs mention unimplemented outlook endpoints; examples remain valid; each canonical topic has one home.
- Suggested validation commands: `go test ./...`; `find docs examples -type f -maxdepth 4 | sort`; `rg "docs/|README|examples/" README.md docs examples`; run a markdown/link checker only if one is added to the repository.
- Prompt size: small enough for one implementation prompt.

## Validation Plan

Automated checks to run during or after documentation implementation:

- `go test ./...` from `weatherapi` after any doc/example changes that add tests or could affect embedded paths.
- `go test ./internal/app ./internal/adapters/inbound/httpapi ./internal/adapters/inbound/httpapi/presenter ./internal/adapters/outbound/postgres` when API, internal, or integration docs are cross-checked against behavior.
- Add config example loading tests if examples are created; validate `examples/config.minimal.yml` and `examples/config.production.yml` with feedapi `config.Load` or equivalent test helper.
- Use `rg` to check stale or forbidden current-doc content: `outlook`, `convective`, `planned`, `future`, `experimental`, `deprecated`, `product.*discussion`, `title.*narrative`, `latest observation/forecast`, and `exact fields may vary`.
- Use `rg` to verify documented routes against route registration: `/observations`, `/conditions/current`, `/alerts/active`, `/discussion`, `/weatherstories`, `/forecast/hourly`, and `/forecast/narrative`.
- Manually verify examples contain no real secrets and no unimplemented endpoints.

Documentation tooling status:

- No repository-local markdown linter, link checker, `Makefile`, `justfile`, `Taskfile`, or `package.json` was found during this planning pass.
- If documentation tooling is added later, update this roadmap or the development policy to make that command part of the validation checklist.

## Open Questions

No open questions block implementation of this documentation roadmap.

Recommendations made by this roadmap:

- Do not create `docs/consumers/` in the first migration because `docs/api.md` is the canonical HTTP consumer contract and no separate task-oriented client workflow exists yet.
- Keep `docs/roadmap/outlook.md` as roadmap-only material until outlook endpoints are implemented.
- Prefer concise internal docs over package-by-package manuals; the goal is safe change guidance, not source-code duplication.
