candle-annotator/openspec/specs/backend-api/spec.md
Marko Djordjevic 7e0579f65d sync: migrate delta specs to main openspec/specs
- Added 5 new capabilities: feature-engineering, annotation-ingestion, ml-training, ml-inference, prediction-ui
- Updated 2 existing capabilities: backend-api, span-annotation
- All specs synced from openspec/changes/candle-backend/specs/
2026-02-16 11:44:34 +01:00

2.3 KiB

ADDED Requirements

Requirement: Predict proxy endpoint

The system SHALL provide a POST /api/predict Next.js API route that proxies requests to the Python inference service at ${INFERENCE_API_URL}/predict. The route SHALL forward the request body (pair, timeframe, candles array) and return the Python service's response. If the inference service is unreachable, the route SHALL return HTTP 503 with { "error": "Inference service unavailable" }.

Scenario: Successful prediction proxy

  • WHEN POST /api/predict is called with valid candle data and the Python service is running
  • THEN the route forwards the request to the inference service and returns the prediction response with HTTP 200

Scenario: Inference service down

  • WHEN POST /api/predict is called but the Python inference service is unreachable
  • THEN the route returns HTTP 503 with { "error": "Inference service unavailable" }

Scenario: Inference service error

  • WHEN the Python inference service returns an error status (4xx or 5xx)
  • THEN the route forwards the error status and message to the client

Requirement: Batch predict proxy endpoint

The system SHALL provide a POST /api/predict/batch Next.js API route that proxies batch prediction requests to ${INFERENCE_API_URL}/predict/batch. The route SHALL forward pair, timeframe, start_date, and end_date.

Scenario: Successful batch prediction

  • WHEN POST /api/predict/batch is called with valid parameters
  • THEN the route forwards to the inference service and returns the batch prediction response

Scenario: Timeout on large batch

  • WHEN the batch prediction takes longer than INFERENCE_BATCH_TIMEOUT
  • THEN the route returns HTTP 504 with { "error": "Batch prediction timed out" }

Requirement: Model info proxy endpoint

The system SHALL provide a GET /api/model/info Next.js API route that proxies to ${INFERENCE_API_URL}/model/info. This endpoint returns model metadata and per-class metrics.

Scenario: Successful model info

  • WHEN GET /api/model/info is called and the inference service is running
  • THEN the route returns the model metadata JSON

Scenario: No model available

  • WHEN GET /api/model/info is called and the inference service returns 503
  • THEN the route returns HTTP 503 with { "error": "No model available" }