-
Notifications
You must be signed in to change notification settings - Fork 1
STEP 5- Implement upload.py — wire OCR pipeline and write results to pantry #12
Copy link
Copy link
Open
Description
Body:
backend/app/routers/upload.py needs to implement POST /upload/receipt. This is the endpoint that ties the entire Vision pipeline together (Steps 2–4) and writes the results into the user's pantry.
Endpoint: POST /upload/receipt
- Auth: Depends(verify_firebase_token) → uid
- Body: multipart/form-data with an image file
Data flow to implement:
image file upload
→ await file.read() → image_bytes
→ validate: len(image_bytes) ≤ 10 MB (raise 413 if exceeded)
→ ocr_service.extract_text(image_bytes) → raw_text
→ receipt_parser.parse(raw_text) → parsed_names
→ [normalizer.normalize(n) for n in parsed_names] → normalized_names
→ for each name: db.collection("users").document(uid).collection("pantry").document().set(...)
→ return ReceiptUploadResponse(raw_text=raw_text, parsed_items=[...])
Depends on:
- ocr_service.py, receipt_parser.py, normalizer.py (Steps 2–4, already implemented)
- Firebase Admin + db initialized (Step 1)
- pantry_service for the Firestore write (or write directly to users/{uid}/pantry/)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels