Skip to content

Migrate to Strawberry / FastAPI / Mangum (final sibling: container + PynamoDB) #86

Description

@chrisbc

Summary

Migrate solvis-graphql-api from Graphene 3 / Flask / serverless-wsgi to Strawberry / FastAPI / Mangum — the 4th and final sibling, run last because it adds the two biggest deltas: a container (ECR) Lambda and a PynamoDB ORM.

Epic: GNS-Science/nshm-toshi-api#359
Runbook: nshm-toshi-api/docs/MIGRATION_RUNBOOK.md
Worked log: docs/MIGRATION_LOG.md (branch migrate/strawberry)
Owner: @chrisbc

Phase 0 inventory — done

Captured in docs/MIGRATION_LOG.md. Key findings (several easier than the runbook's §A4 framing):

  • PynamoDB is a single modelBinaryLargeObjectModel (5 attrs) already wrapped by a hand-written BinaryLargeObject class. Convert to pydantic + boto3 behind the unchanged wrapper API.
  • Container entry is the serverless-wsgi handler.py workaround → Mangum replaces it; update Dockerfile CMD + serverless image.command.
  • Repo already ships a cross-stage differential validator (ab_test/ + cli_ab_test, 9 query checks) → reuse as the Phase 5 validation tool and corpus seed.
  • moto-based tests already exist → no testcontainers.
  • Still on poetry; .yarnrc.yml lacks the age gate; both serverless-s3-local + serverless-dynamodb load at boot (runbook §4.7 risk); heavy container image (matplotlib/solvis/shapely).
  • Secrets posture = repo-level static AWS keys + single TEST env (the Model §4.2 caveat, not AWS_TEST/AWS_PROD).

Plan (tailored — full detail in the log)

  • Phase 0 — inventory, branch migrate/strawberry
  • poetry → uv via the dockerbash poetry2uv skill (running externally on the branch)
  • Phase 0 artifacts — legacy SDL baseline (guard stdout) + vendor the A/B query set as corpus
  • Phase 1 — FastAPI/Mangum + container entry swap; .yarnrc.yml age gate; drop serverless-wsgi
  • Phase 2 — PynamoDB→pydantic+boto3 (keep wrapper API); port ~25 graphene types to Strawberry at parity
  • Phase 3 — tests to Strawberry (keep moto); CI → -uv workflows; remove branches: filter
  • Phase 4 — container build/dep-install path; yarn resolutions hygiene; vuln bumps; image-size pass
  • Phase 5 — deploy to test; cli_ab_test prod-vs-new differential validation; promote + prod watch; file runbook feedback PR

Status

Phase 0 inventory complete; branch pushed and awaiting the external poetry2uv run before Phase 1 code begins.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions