Skip to content

ai-review

Purpose

ai-review receives an ai_review.requested event, calls the external DERM AI inference endpoint with case images, persists the raw response and a structured AiReview row, then emits ai_review.completed (or ai_review.failed). It is the sole integration point between the platform and DERM AI; all other services treat it as a black box and interact via events.

Key endpoints

POST /v1/ai-review/reviews — manually trigger a review (admin / test use) GET /v1/ai-review/reviews — list reviews, filterable by case / org / product GET /v1/ai-review/reviews/:id — fetch a single review record GET /v1/ai-review/reviews/:id/raw — fetch the raw DERM AI response payload for the review POST /v1/ai-review/reviews/:id/supersede — supersede an existing review with a new inference run POST /v1/ai-review/reviews/:id/cancel — cancel a pending or in-progress review GET /health — liveness probe GET /health/ready — readiness probe (checks Prisma + Redis)

Database tables

AiReview — top-level review record: status, case / product / org IDs, timing, supersession chain AiReviewImage — images submitted for a review run (join between review and clinical-api image IDs) AiReviewResult — parsed inference result for the review (diagnoses, confidence, model version) AiReviewLesion — per-lesion detail rows from the DERM AI response

Events

ai_review.requested — consume — received from clinical-api; triggers a BullMQ inference job ai_review.started — emit — published when the inference job begins processing ai_review.completed — emit — published when DERM AI responds and results are persisted ai_review.failed — emit — published when inference fails or exhausts retries ai_review.superseded — emit — published when a review is replaced by a newer one

Dependencies

  • DERM AI — external HTTP inference service; presigned image URLs are included in the ai_review.requested payload
  • clinical-api — source of presigned image URLs
  • Redis — event transport (Redis Pub/Sub inbound; Redis Streams outbound via @sa-platform/events)
  • BullMQ — job queue for async inference processing and result polling
  • MySQL — primary store, accessed via Prisma 7 driver-adapter pattern

Where to learn more

  • Design spec
  • Source: services/ai-review/ (in this repo)