feat: add BullMQ queue infrastructure and frontend job status hook

- apps/Backend/src/queue/: connection, queues, workers, processors
- apps/Frontend/src/hooks/use-job-status.ts: WebSocket job progress hook
- apps/Frontend/src/lib/socket.ts: shared Socket.IO singleton

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ff
2026-04-13 22:30:40 -04:00
parent e10126f772
commit 90302a76b7
13 changed files with 1079 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
/**
* Processor for "ocr" jobs.
* Calls the PaymentOCR Python service with the uploaded files.
*/
import axios from "axios";
import FormData from "form-data";
const OCR_BASE_URL =
process.env.OCR_SERVICE_BASE_URL || "http://localhost:5003";
export interface OcrProcessorInput {
files: { originalname: string; bufferBase64: string; mimetype: string }[];
}
export async function runOcrProcessor(
input: OcrProcessorInput
): Promise<any[]> {
const { files } = input;
const form = new FormData();
for (const f of files) {
const buf = Buffer.from(f.bufferBase64, "base64");
form.append("files", buf, {
filename: f.originalname,
contentType: f.mimetype,
knownLength: buf.length,
});
}
const resp = await axios.post<{ rows: any[] }>(
`${OCR_BASE_URL}/extract/json`,
form,
{
headers: form.getHeaders(),
maxBodyLength: Infinity,
maxContentLength: Infinity,
timeout: 180_000, // OCR can be heavy; 3-minute limit
}
);
return resp.data?.rows ?? [];
}