3.0 KiB
3.0 KiB
01. Extend Types and Add Feedback DB Schema
meta: id: multi-image-user-feedback-01 feature: multi-image-user-feedback priority: P0 depends_on: [] tags: [types, schema, database]
objective:
- Update shared TypeScript types to support multi-image requests, species-constrained inference, top-5 combo predictions, and post-evaluation feedback.
- Add a new database table for storing feedback entries.
deliverables:
src/lib/types.ts— updated with new interfacessrc/lib/db/schema.ts— updated withdiagnosisFeedbacktable
steps:
-
Add these new types to
src/lib/types.ts:IdentifyOptions— optional fields sent in the identify request:secondImageId?: string,userSpecies?: string,useForTraining?: booleanIdentifyRequest— extend to includeoptions?: IdentifyOptionsTopPrediction— a prediction with both species and disease info:{ speciesName: string, diseaseName: string, diseaseId: string, confidence: ConfidenceResult, rank: number }IdentifyResponse— extend to includetopSpeciesDisease?: TopPrediction[],speciesConfidence?: ConfidenceResult,infoProvided: string[](which optional inputs the user gave)AccuracyRating—"correct" | "incorrect" | "unsure"DiagnosisFeedback— full feedback shape:{ sessionId: string, imageIds: string[], userSpecies?: string, predictedDiseaseId: string, accuracyRating: AccuracyRating, consentToStoreImages: boolean, userCorrectedSpecies?: string, notes?: string, createdAt: string }FeedbackRequest— POST body for the feedback endpointFeedbackResponse— confirmation response
-
Add a
diagnosisFeedbacktable tosrc/lib/db/schema.ts:id— text primary key (UUID v4)sessionId— text, session identifier for groupingimageIds— JSON text array of stored image IDsuserSpecies— text, nullablepredictedDiseaseId— text, the top model predictionaccuracyRating— text enum:"correct" | "incorrect" | "unsure"consentToStoreImages— integer (boolean)userCorrectedSpecies— text, nullable (only when accuracy=incorrect or unsure)notes— text, nullablemodelVersion— text, the model version usedcreatedAt— text, auto timestamp- Add indexes on
sessionId,accuracyRating,createdAt
-
Export
DiagnosisFeedbackRowandDiagnosisFeedbackInserttype helpers.
tests:
- Unit: verify new types compile correctly
- Unit: verify schema migration produces correct table DDL
- Unit: verify INSERT and SELECT on feedback table through Drizzle
acceptance_criteria:
- All new types are exported from
src/lib/types.ts diagnosisFeedbacktable exists in schema with all required columnsDiagnosisFeedbackRowandDiagnosisFeedbackInsertare exported
validation:
npx tsc --noEmitpasses- Drizzle Kit (
npx drizzle-kit generate) produces valid migration SQL
notes:
- The
sessionIdties together the upload, identify, and feedback flow - Image storage consent is a boolean to comply with data privacy requirements