- Python 100%
| ci | ||
| readmeComponents | ||
| .editorconfig | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| CODEOWNERS | ||
| LICENSE | ||
| README.md | ||
| renovate.json | ||
PDF Processor Status
Status
Stations
| Repository | develop | main | Code coverage | Latest Release |
|---|---|---|---|---|
| stations |
Base Workers
| Repository | develop | main | Code coverage | Latest Release |
|---|---|---|---|---|
| python | ||||
| typescript |
Workers
| Repository | develop | main | Code coverage | Latest Release | Baseworker develop | Baseworker main |
|---|---|---|---|---|---|---|
| document-mimetype-from-header | ||||||
| image-page | ||||||
| page-content | ||||||
| page-content-images | ||||||
| page-content-tables | ||||||
| page-interpreted-content-ocr | ||||||
| page-regions-image-processing | ||||||
| page-regions-yolo | ||||||
| pdf-metadata | ||||||
| pdf-nldocspec | ||||||
| pdf-pages |
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;
- A Converter: Something that converts one entity to one or more other entities
- 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-jobsanddocument-to-pages-job-results
Extractor workers use the convention: [inputType]-[outputAttributeName], suffixed with the pair type. I.e:
document-mimetype-jobsanddocument-mimetype-job-resultspage-text-jobsandpage-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 nameds3: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
filesexchange. -
This notification is picked up by the
station-convert-file-to-documentstation. This station generates a document ID and posts the document info on thedocumentsexchange. The published information is in the format of the DocumentInfoReport type -
All stations with station input type
documentwill 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 thedocumentsexchange 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.