Decompose: Add HTTP service layer (FastAPI) exposing the EmbroideryPipeline — Phase 2: POST /v1/digitize #47

Closed
opened 2026-06-22 16:31:08 +00:00 by Mark · 2 comments
Owner

Phase 2: POST /v1/digitize

Wire the 5-stage pipeline to a single endpoint. This is the core of the
service.

Files:

  • Modify: src/service/app.py (add /v1/digitize route)
  • Modify: src/service/models.py (DigitizeRequest, DigitizeResponse
    pydantic models)
  • New: src/service/handlers/digitize.py (route handler, calls
    EmbroideryPipeline.process_bytes(), formats response)

Acceptance:

  • POST /v1/digitize with a 1024×1024 PNG and default settings returns
    a valid DigitizeResponse (regions, stitchObjects, stats) within 5
    seconds on a 4-core dev box.
  • The response includes a stats.stages breakdown (depends on issue
    #35 — the stages dict population fix — being merged first).
  • Errors at any stage (raster conversion fails, no regions detected,
    format emit fails) return a structured 503 with the failing stage
    named in the body. No 500s on expected failures.
  • 3 concurrent requests handled without deadlock.

Depends on: P1 (skeleton). Soft-depends on #32 (importable pipeline)
and #33 (process_bytes method) — if those aren't done first, this
phase has to call process(input_path) and write temp files, which
adds friction. Land them first for cleanliness.



Decomposed from easystitch#31

## Phase 2: POST /v1/digitize Wire the 5-stage pipeline to a single endpoint. This is the core of the service. **Files:** - Modify: `src/service/app.py` (add `/v1/digitize` route) - Modify: `src/service/models.py` (DigitizeRequest, DigitizeResponse pydantic models) - New: `src/service/handlers/digitize.py` (route handler, calls `EmbroideryPipeline.process_bytes()`, formats response) **Acceptance:** - `POST /v1/digitize` with a 1024×1024 PNG and default settings returns a valid `DigitizeResponse` (regions, stitchObjects, stats) within 5 seconds on a 4-core dev box. - The response includes a `stats.stages` breakdown (depends on issue #35 — the `stages` dict population fix — being merged first). - Errors at any stage (raster conversion fails, no regions detected, format emit fails) return a structured `503` with the failing stage named in the body. No 500s on expected failures. - 3 concurrent requests handled without deadlock. **Depends on:** P1 (skeleton). Soft-depends on #32 (importable pipeline) and #33 (process_bytes method) — if those aren't done first, this phase has to call `process(input_path)` and write temp files, which adds friction. Land them first for cleanliness. --- --- _Decomposed from [easystitch#31](https://forgejo.tail018ac4.ts.net/Mark/easystitch/issues/31)_
Author
Owner

Cross-link: ThreadCraft #11 — this phase is the /v1/digitize endpoint the ThreadCraft frontend calls.

**Cross-link:** ThreadCraft #11 — this phase is the /v1/digitize endpoint the ThreadCraft frontend calls.
Author
Owner

This issue has been decomposed into the following sub-issues:

# Title Phase Scope
#85 POST /v1/digitize Wire the 5-stage pipeline to a single endpoint. This is the core of the service.

Each sub-issue awaits triage pipeline assessment before queue routing.

This issue has been decomposed into the following sub-issues: | # | Title | Phase Scope | |---|-------|-------------| | #85 | POST /v1/digitize | Wire the 5-stage pipeline to a single endpoint. This is the core of the service. | Each sub-issue awaits triage pipeline assessment before queue routing.
Mark closed this issue 2026-06-26 18:51:41 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/easystitch#47
No description provided.