Reference
API and demo reference
What the hosted demo actually does, and the REST contract the full pipeline exposes.
How demo mode works
The demo ships as a static export on Vercel. There is no Python, OpenCV, or ONNX runtime on the server, so nothing is processed remotely.
- Your file stays in the browser. It is never uploaded.
- Results come from a stored sample run of the real pipeline.
- Six sample records load on the first visit.
- New records are saved to this browser's localStorage.
To run the real pipeline, build the container with docker build -t smart-document-scanner . && docker run -p 8000:8000 smart-document-scanner and open http://localhost:8000. The same image runs on Railway, or locally with the Python entrypoint.
REST API
Five endpoints cover processing, job polling, history, and health.
| Method | Path | Description |
|---|---|---|
| POST | /api/process | Accept multipart fields file, doc_type, fast_denoise, and cpp_acceleration, then queue a job. |
| GET | /api/jobs/{id} | Return job status, stage progress, and the full result once processing completes. |
| DELETE | /api/jobs/{id} | Remove a job and its stored artifacts from the server history. |
| GET | /api/history | List recent jobs, newest first, for the history screen. |
| GET | /api/health | Report service health plus the OCR engine and accelerator in use. |
Example request
Send the image as multipart form data. Fast denoise and C++ acceleration are optional booleans.
curl -X POST http://localhost:8000/api/process \
-F "file=@document.jpg" \
-F "doc_type=auto" \
-F "fast_denoise=true" \
-F "cpp_acceleration=true"Response shape
Every job result carries detection facts, extraction coverage, parsed fields, and artifact URLs.
{
"job_id": "9f2c1e70",
"document_detected": true,
"rotation_angle": 1.4,
"detection_area_ratio": 0.62,
"detection_method": "contour",
"detection_score": 0.91,
"detection_selection": "largest_quad",
"corners": [[82, 64], [1518, 71], [1509, 1562], [75, 1551]],
"image_width": 1600,
"image_height": 1200,
"processing_time_ms": 1840,
"ocr_confidence": 0.88,
"extracted_field_count": 4,
"recognised_field_count": 4,
"extraction_coverage": 1.0,
"fields": {
"document_type": "receipt",
"classification": { "document_type": "receipt", "score": 0.93, "signals": ["total"] },
"fields": [
{ "name": "merchant", "value": "Kopi Senja", "confidence": 0.9, "source": "line" }
]
},
"raw_text": "KOPI SENJA\nTotal 48.000",
"warnings": [],
"assets": {
"original": "/api/jobs/9f2c1e70/assets/original.jpg",
"detected": "/api/jobs/9f2c1e70/assets/detected.jpg",
"corrected": "/api/jobs/9f2c1e70/assets/corrected.jpg",
"enhanced": "/api/jobs/9f2c1e70/assets/enhanced.jpg"
}
}