mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
The export panel rendered twenty data switches and eight of them changed nothing. The grouped selection folded down to twelve flat flags and dropped oxygen saturation, body fat, body composition, resting heart rate, HRV, VO2 max, steps and distance on the way, so a user who switched any of them off still exported the readings in the PDF, in the FHIR bundle, in the package, through a clinician share link and over MCP. Each one now resolves to a flag the aggregator reads, and the rows are excluded at the query rather than fetched and dropped. Three more controls were untruthful in their own way: - The medications switch documented itself as excluding all medication data and excluded the adherence figures only. The drug list and the per-dose administration ledger rode along regardless. Both follow the switch now; the rows are still read, because compliance and the GLP-1 block are computed from them, and they no longer leave the aggregator. - Allergies and family history were gated for the PDF and fetched unconditionally for the FHIR bundle, so a package could carry a compliant PDF and a violating bundle in the same zip. The reads are gated, and a deselected section is not read at all. - The PHQ-9, GAD-7, WHO-5 and SCI screening totals had no per-report control. They rode the mental-health module alone, which has been default-on since v1.29.1, so depression and anxiety screeners reached FHIR bundles, share links and the MCP doctor-visit resource on accounts that never chose to send them. They get their own section key, defaulting off, with the module gate kept as the second lock, and the stale privacy-by-default comment that argued otherwise is corrected. The share link's FHIR promise is removed rather than implemented. The create form offered a toggle and a resource-type picker, the values were persisted and badged on the finished link, and the API description called the toggle a REST reachability switch, while no route has ever answered a share token with FHIR or any other machine-readable format. Serving one is a feature with real security surface and does not belong in a correctness fix. The toggle, the picker, the badge and both claims are gone; the create schema rejects the two keys instead of accepting and ignoring them; the columns stay, unread, so no data is destroyed to undo a promise. Two files are split along seams this change already touched. The measurement-type gating maps and the filter that reads them leave the aggregator for their own module, so the query gate and the output gate cannot disagree; the export panel's control shape and the selection it builds leave the component, so the selection contract can be extended without the rendering. Three accepted-and-discarded wire keys (activity energy, GLP-1, side effects) are dropped: nothing rendered them and nothing read them.
HealthLog API Spec
openapi.yaml is the canonical OpenAPI 3.1 description for the HealthLog
Next.js API. It is the source of truth for the native iOS client's
DTO codegen.
The MCP server is documented separately — it is a distinct contract over JSON-RPC, not part of the REST OpenAPI spec:
mcp-capabilities.md— the tool, resource, and prompt catalogue, the grounding contract, and the write model.mcp-skills.md— building a connector or skill on top of it.../self-hosting/mcp.md— enabling and connecting the surface (operator guide).
Preview locally
Open an interactive Redoc preview in your browser:
npx @redocly/cli preview docs/api/openapi.yaml
Generate static HTML for sharing:
npx @redocly/cli build-docs docs/api/openapi.yaml --output docs/api/index.html
Validate
npx @redocly/cli lint docs/api/openapi.yaml
The spec is expected to be lint-clean (errors = 0). Some warnings are intentional:
no-server-example.com—http://localhost:3000is the dev server.operation-2xx-response/operation-4xx-response— webhook + redirect endpoints intentionally omit one or the other.no-unused-components—ReminderPhaseis exposed for client codegen even though no path response references it directly.
Layout
info— title, version (mirrored frompackage.json), description.servers— productionhttps://healthlog.bombeck.ioplushttp://localhost:3000for local development.tags— domain groupings (Auth,Measurements,Medications,Mood,Dashboard,Insights,Achievements,DoctorReport,Integrations,User,Tokens,Notifications,Onboarding,Health,Settings,Analytics,Export,AuditLog,Monitoring,Webhooks,Ingest,Admin).securitySchemes:bearerAuth— long-livedhlk_*API tokens issued viaPOST /api/tokens. Required on/api/ingest/medication.sessionCookie— HttpOnlyhealthlog_sessioncookie set by the password and passkey login flows. Used by the web app and any iOS client running inside a web view.
components.schemas— DTOs for all routes plus the underlying Prisma models (e.g.Measurement,Medication,MedicationIntakeEvent,MoodEntry,User,DashboardLayout,ApiEnvelope,ApiError).paths— all routes fromsrc/app/api/**/route.ts, including the/api/admin/*family which is taggedAdminand marked internal.
Conventions
- Successful responses use the envelope
{ data, error: null }. - Error responses use the envelope
{ data: null, error: '<message>' }. - Pagination uses
limit+offsetquery parameters and ameta: { total, limit, offset }block on the response. - All timestamps are ISO 8601 / RFC 3339 (
format: date-time) in UTC. - IDs are CUIDs (opaque strings).
Updating the spec
When adding or changing routes:
- Update the relevant route handler under
src/app/api/**/route.ts. - Mirror the change in
openapi.yaml. KeepoperationIdcamelCase and stable — the iOS codegen keys off it. - Run
npx @redocly/cli lint docs/api/openapi.yamland resolve all errors. Warnings are tolerated when documented above. - Bump
info.versionif the change is breaking for clients.