Parsing Pipeline
The parsing pipeline is designed for reliability and repeatability. Every import is tracked as a session and can be previewed, audited, or reprocessed.
Pipeline stages
-
Upload
- Files go to the uploads directory:
UPLOADS_DIR, otherwise./uploads(/app/uploadsin Docker) - A SHA-256 hash is computed to catch duplicate uploads
- Up to 10 MB per file
- Files go to the uploads directory:
-
Queue
- Parsing runs asynchronously in the BullMQ statement parsing queue (
parsing/queue) STATEMENT_PARSING_CONCURRENCY(default 5) limits how many statements are parsed at once
- Parsing runs asynchronously in the BullMQ statement parsing queue (
-
Parser selection
ParserFactoryServicedetects the bank from the document text (bank name, then BIC) and holds the parsers: Bereke (new layout), Bereke (old layout), Kaspi, Hapoalim, generic PDF, Excel, CSV, and DOCXOcrService(tesseract.js) extracts text from images and scans
-
Quality gate
StatementQualityGateServicerates the parsed statementready,review, orblocked
-
Import session: preview and commit
- An
import_sessionsrecord tracks the status:pending,processing,preview,completed,failed, orcancelled GET /statements/:id/import-previewshows the parsed rows and their conflicts with existing transactionsPOST /statements/:id/import-commitsaves them; each conflict is resolved asskip,force_import, ormark_duplicate
- An
-
Categorization
- Learning rules apply per-workspace merchant patterns
- AI classification uses the OpenAI-compatible endpoint configured under Integrations (the Anthropic API is also supported)
-
Deduplication
- Transaction fingerprints plus fuzzy matching on date, amount, and text
- Uncertain matches are flagged for manual review
Error handling
- Parsing errors are captured on the statement and its import session
POST /statements/:id/reprocessreruns parsing without re-uploading- Logs are structured JSON with request and trace IDs; parsers log volumes and outcomes, never transaction contents
Related code
backend/src/modules/parsingbackend/src/modules/importbackend/src/modules/classification
Next: Importing Statements