Classifier Service:-Architecture Design
1. Background & Problem Statement
Applications frequently receive multi-document uploads that contain mixed document types, for example a single PDF containing multiple tax forms, invoices, or supporting records. Before extraction can occur, each logical document segment must be identified before being routed to the appropriate extract. A centralized Classifier service is required to solve this problem in a consistent, extensible way. Today this responsibility sits inside ClassifyFileTool.ts in Paperboy. Form classification and splitting are tightly coupled in a service. This creates several challenges:
- The classify logic cannot be scaled or replaced independently
- Incorrect classification results to incorrect processes downstream
2. Current State (As-Is) in Paperboy
2.1 Where Classification Lives Today
2.2 Current Classification and Split Data Flow
2.3 Classification JSON Schema (Current Output)
2.4 FileData Table (Split Records)
3. Challenges with the Current Architecture
4. Recommended Architecture
4.1 Design Principles
- Single Responsibility - The Classifier receives a message and emits addressable forms classification result.
- Contract-Driven - Input is a message containing internal url. Output is a
ClassificationResultDTO persisted to the database and/or blob storage. - Fault Isolated - Classification failures must not corrupt the parent file record, this must raise an explicit error that the orchestrator (agentic loop) can surface.
- Independently Scalable - The classifier must be callable independently of classification.
4.2 Proposed Service Boundary
Classification and Document Splitter become independent with a well-defined handoff.
4.3 New Service: fluxx-classifier
Location: [CLADevOps/fluxx-classifier: Created by Terraform](https://github.com/CLADevOps/fluxx-classifier)
Published message in accepted-file topic:
High level instruction:
- Download the file using internalUrl props from the received message.
- Split the file into chunks of 10 (dafault).
- Classifiy each chunk using OpenAI.
- Filter each form type classification.
- Save filtered classification result and upload to blob storage as json file
- Save classification result to
classifier.File - Publish a message to
classified-topic.
SplitResult (as output):
4.4 Updated fluxx-document-splitter
fluxx-document-splitter is simplified to document splitter only:
- Removes all classification logic
- Sets
FileData.status = 'spltted'on success - Returns the splitted document result for extraction.
This makes the agentic loop’s workflow explicit:
4.5 Blob Storage Layout
A dedicated splits/ folder separates split manifests from classification and extraction artifacts.