Step by Step Walkthrough
Event Flow
Step-by-Step Walkthrough
Step 1 , Message Arrives
Trigger: The classifier service publishes a FileClassifiedEvent to the classified-file topic.
Message shape:
Code: src/messaging/subscribers/messageReceiver.ts receives the message and routes it to classifiedFileHandler.
Step 2 , Validate the Event
The handler checks that all required fields are present and non-empty.
If invalid: Publishes a ProblemEvent with HTTP status 400 to the problem topic, then stops processing.
Code: src/messaging/handlers/classifiedFileHandler.ts
Step 3 , Create Job in SQL
Inserts (or upserts) a row in [splitter].[Job]:
This record lets operators query which files are in-flight and which have failed.
Code: src/repositories/jobRepository.ts
Step 4 , Download Classification JSON
Parses classifiedOutputUrl → extracts container docs and blob path classified/myfile.json.
Downloads and deserialises the classification output:
Code: src/internal/storage/blobStorageService.ts → downloadBuffer()
Step 5 , Download Source PDF
Parses internalUrl → downloads the PDF bytes as a Buffer.
Code: src/internal/storage/blobStorageService.ts → downloadBuffer()
Step 6 , Validate Page Ranges
Runs these checks against the classification + actual PDF:
If any check fails: Publishes ProblemEvent (400), marks job Failed, stops processing.
Code: src/internal/pdf/pdfSplitter.ts → buildValidatedPageRanges()
Step 7 , Split the PDF
For each form, pdf-lib extracts the relevant pages into a new Buffer:
Generated filenames:
Code: src/internal/pdf/pdfSplitter.ts → splitPdfByPageRanges()
Step 8 , Upload Split Files (Parallel)
For each split buffer, an HTTP POST is made to the File Intake service:
All three uploads run in parallel (Promise.allSettled).
Response per upload:
Code: src/services/fileIntake/fileIntakeService.ts → uploadChildFile()
Step 9 , Publish FileSplitFileEvent (per split)
One Service Bus message is published per successfully uploaded split:
Topic: split-file
Code: src/messaging/publishers/createMessageSender.ts
Step 10 , Upload Split Manifest JSON
A JSON document summarising all splits is uploaded to blob storage:
Blob path: splits/app-001/splitResults/classifier-xyz/20260729T100000_myfile_splitResult.json
Code: src/internal/storage/blobStorageService.ts → uploadBuffer()
Step 11 , Publish FileSplitFileResultEvent
The manifest is also published as a single Service Bus message:
Topic: split-file-result
Step 12 , Complete the Job
Updates [splitter].[Job] row:
Code: src/repositories/jobRepository.ts → completeJob()