Find a file
2025-12-31 10:08:51 +00:00
ci fix: update references (GitLab migration) 2025-04-07 13:36:53 +02:00
readmeComponents fix: don't use python3 as language name, use python 2025-04-07 17:58:49 +02:00
.editorconfig chore: set .editorconfig 2025-04-22 00:09:03 +00:00
.gitignore chore: removed DS_Store 2024-12-17 16:25:03 +01:00
.gitlab-ci.yml fix: use CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX 2025-04-07 16:07:16 +02:00
CODEOWNERS chore: set CODEOWNERS 2025-04-22 00:26:07 +00:00
LICENSE chore: add license 2025-04-15 00:14:24 +02:00
README.md chore(readme): update README [ci skip] 2025-12-31 10:08:51 +00:00
renovate.json Add renovate.json 2024-05-08 14:04:09 +00:00

PDF Processor Status

Status

Stations

Repository develop main Code coverage Latest Release
stations develop pipeline status main pipeline status code coverage latest release

Base Workers

Repository develop main Code coverage Latest Release
python develop pipeline status main pipeline status code coverage latest release
typescript develop pipeline status main pipeline status code coverage latest release

Workers

Repository develop main Code coverage Latest Release Baseworker develop Baseworker main
document-mimetype-from-header develop pipeline status main pipeline status code coverage latest release BaseWorker BaseWorker
image-page develop pipeline status main pipeline status code coverage latest release BaseWorker BaseWorker
page-content develop pipeline status main pipeline status code coverage latest release BaseWorker BaseWorker
page-content-images develop pipeline status main pipeline status code coverage latest release BaseWorker BaseWorker
page-content-tables develop pipeline status main pipeline status code coverage latest release BaseWorker BaseWorker
page-interpreted-content-ocr develop pipeline status main pipeline status code coverage latest release BaseWorker BaseWorker
page-regions-image-processing develop pipeline status main pipeline status code coverage latest release BaseWorker BaseWorker
page-regions-yolo develop pipeline status main pipeline status code coverage latest release BaseWorker BaseWorker
pdf-metadata develop pipeline status main pipeline status code coverage latest release BaseWorker BaseWorker
pdf-nldocspec develop pipeline status main pipeline status code coverage latest release BaseWorker BaseWorker
pdf-pages develop pipeline status main pipeline status code coverage latest release BaseWorker BaseWorker

Table of contents

[[TOC]]

General architecture

Kimi

  • Stations
  • Workers
  • AMQP (RabbitMQ)
  • S3 Storage (MinIO)
flowchart TB

subgraph minio
    FileCreatedNotification{{FileCreatedNotification}}:::Notification

    File-- upload --> MinIO
    MinIO -. output .-> FileCreatedNotification
end

subgraph stationConvertFileToDocument [Station fileToDocument]
    StationConvertFileToDocument([ConvertFileToDocument]):::Station
    DocumentCreatedNotification{{DocumentCreatedNotification}}:::Notification
    Document[\Document/]:::Entity

    FileCreatedNotification -. input .-o StationConvertFileToDocument
    StationConvertFileToDocument-. output .-> DocumentCreatedNotification
    StationConvertFileToDocument-. output .-> Document
end

subgraph Station documentMimeType
    direction LR
    DocumentMimetypeFromHeaderWorker:::Worker
    StationExtractDocumentMimeType([ExtractDocumentMimeType]):::Station
    Document.MimeType[/MimeType/]:::Attribute

    Document --- Document.MimeType
    Document -. input .-o StationExtractDocumentMimeType
    StationExtractDocumentMimeType-. output .-> Document.MimeType
    StationExtractDocumentMimeType <--> DocumentMimetypeFromHeaderWorker
end

subgraph Station documentPageCount
    StationExtractDocumentMetaData([ExtractDocumentMetaData]):::Station
    Document.PageCount[/PageCount/]:::Attribute

    Document --- Document.PageCount
    Document -. input .-o StationExtractDocumentMetaData
    Document.MimeType -. input .-o StationExtractDocumentMetaData
    StationExtractDocumentMetaData-. output .-> Document.PageCount
end

subgraph Station documentToPages
    StationExtractDocumentPages([ExtractDocumentPages]):::Station
    PageCreatedNotification{{PageCreatedNotification}}:::Notification
    Page[\Page/]:::Entity

    direction TB
    Document --- Page
    Document -. input .- StationExtractDocumentPages
    Document.MimeType -. input .-o StationExtractDocumentPages
    StationExtractDocumentPages-. output .-> PageCreatedNotification
    StationExtractDocumentPages-. output .-> Page
end

subgraph Station pagesToContent
    StationPagesToContent([PagesToContent]):::Station
    PageContent[\PageContent/]:::Entity

    direction TB
    Page --- PageContent
    Page-. input .-o StationPagesToContent
    Document.PageCount-. input .-o StationPagesToContent
    StationPagesToContent-. output .-> PageContent
end

Naming convention

Stations and workers are separated as two different kinds;

  1. A Converter: Something that converts one entity to one or more other entities
  2. An Extractor: Something that enriches the input type with the value of an attribute of that entity

Station name:

A converter station:
station-[inputType]-[outputType]
I.e. station-file-document, station-document-pages

An extractor station:
station-[inputType]-[attributeName]
I.e. station-document-mimetype, station-page-text

Worker name:

A converter worker:
worker-[inputType]-[outputType](-[suffix]) I.e. worker-document-pages-nodejs

An extractor worker
worker-[inputType]-[attributeName](-[suffix])
I.e. worker-document-mimetype-python, worker-document-mimetype-nodejs, worker-page-text-tesseract

AMQP

Queue

Station: Station name
Worker: Worker name

Exchange

A station exchange has the name of input entity (station inputType), in plural. I.e. documents, pages.

Worker exchanges always exist in pairs: jobs and job-results.

Converter workers use the convention: [inputType]-to-[outputType], suffixed with the pair type. I.e:

  • document-to-pages-jobs and document-to-pages-job-results

Extractor workers use the convention: [inputType]-[outputAttributeName], suffixed with the pair type. I.e:

  • document-mimetype-jobs and document-mimetype-job-results
  • page-text-jobs and page-text-job-results

AMQP Exchange/queue data flow

flowchart LR

subgraph Legend["Legend"]
    Exchange{{"Exchange"}}
    ExchangeType{"Type"}
    Queue[["Queue"]]
end

 subgraph AMQP["AMQP"]
    %%{config: { 'fontFamily': 'Menlo', 'fontSize': 18, 'fontWeight': 400} }%%
    direction LR
    DocumentsExchange{{"documents"}}
    DocumentsExchangeFanout{"fanout"}

    StationDocumentMetadata[["station-document-metaData"]]
    StationDocumentMimetype[["station-document-mimeType"]]

    WorkerDocumentMimetypeNodejs[["worker-document-mimetype-nodejs"]]
    WorkerDocumentMimetypePython[["worker-document-mimetype-python"]]
    
    WorkerDocumentMetadata[["worker-document-metadata"]]
    
    DocumentMetadataJobsExchange{{"document-metadata-jobs"}}
    DocumentMetadataJobsExchangeFanout{"fanout"}

    DocumentMetadataJobResultsExchange{{"document-metadata-job-results"}}
    DocumentMetadataJobResultsExchangeFanout{"fanout"}

    DocumentMimetypeJobsExchange{{"document-mimetype-jobs"}}
    DocumentMimetypeJobsExchangeFanout{"fanout"}
    
    DocumentMimetypeJobResultsExchange{{"document-mimetype-job-results"}}
    DocumentMimetypeJobResultsExchangeFanout{"fanout"}
  end

DocumentsExchange --> DocumentsExchangeFanout
StationDocumentMimetype -. publish on .-> DocumentsExchange
StationDocumentMetadata -. publish on .-> DocumentsExchange
DocumentsExchangeFanout ---> StationDocumentMetadata & StationDocumentMimetype
StationDocumentMetadata -. publish on .-> DocumentMetadataJobsExchange
DocumentMetadataJobsExchange --> DocumentMetadataJobsExchangeFanout
DocumentMetadataJobResultsExchange --> DocumentMetadataJobResultsExchangeFanout
DocumentMetadataJobResultsExchangeFanout --> StationDocumentMetadata
DocumentMetadataJobsExchangeFanout --> WorkerDocumentMetadata
WorkerDocumentMetadata -. publish on .-> DocumentMetadataJobResultsExchange
StationDocumentMimetype -. publish on .-> DocumentMimetypeJobsExchange
DocumentMimetypeJobsExchange --> DocumentMimetypeJobsExchangeFanout
DocumentMimetypeJobResultsExchange --> DocumentMimetypeJobResultsExchangeFanout
DocumentMimetypeJobResultsExchangeFanout --> StationDocumentMimetype
DocumentMimetypeJobsExchangeFanout --> WorkerDocumentMimetypePython & WorkerDocumentMimetypeNodejs
WorkerDocumentMimetypePython -. publish on .-> DocumentMimetypeJobResultsExchange
WorkerDocumentMimetypeNodejs -. publish on .-> DocumentMimetypeJobResultsExchange

DocumentMetadataJobsExchange:::Exchange
DocumentMetadataJobResultsExchange:::Exchange

DocumentMimetypeJobsExchange:::Exchange
DocumentMimetypeJobResultsExchange:::Exchange

Basic outline of functionality

For the processing of files, the following processing-pipeline is set up;

  • A File is uploaded in MinIO, in bucket named Files. This triggers a MinIO bucket event named s3:ObjectCreated:Put. See the MinIO documentation about bucket events for more information, or the MinIO documentation about RabbitMQ events for further details about the configuration.

  • MinIO is configured (in the Kubernetes values yml) to send bucket notifications over AMQP. This notification is sent on the files exchange.

  • This notification is picked up by the station-convert-file-to-document station. This station generates a document ID and posts the document info on the documents exchange. The published information is in the format of the DocumentInfoReport type

  • All stations with station input type document will receive this document info, and will generate a record for this document in their own storage through the stations' Storage Type. The stations will subscribe to the document's attributes, as they are configured in the stationDefinitions. Stations will "hold" that record in state "pending" until all required attributes are present. These attributes will be published on the documents exchange by other stations.

  • As soon as all required attributes for the document are present, the record will be ready for processing. The station will publish a worker job on the exchange for its worker.