Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

ERP Document Classifier MLOps Template

This repository contains a production-ready, Dockerized template for training and deploying a machine learning micro-model designed to automatically classify/sort warehouse documents (such as invoices, receipts, waybills, and packing lists) for ERP systems.

The template integrates a Python (ML/FastAPI) microservice with a Java (Spring Boot) ERP microservice using REST APIs.


🗺 System Architecture

sequenceDiagram
    participant User as User/ERP UI
    participant Java as Java ERP (8081)
    participant Python as Python Classifier (8000)
    
    User->>Java: Upload Document/Trigger Sim
    Note over Java: Instantiate Document object
    Java->>Python: POST /classify {"text": "..."}
    Note over Python: Load ML Model & Vectorizer
    Note over Python: Run Inference (TF-IDF + LogReg)
    Python-->>Java: Response {"category": "INVOICE", "confidence": 0.95}
    Note over Java: Update Document metadata & Category
    Java-->>User: Processed Document JSON
Loading

📁 Repository Structure

  • docker-compose.yml - Orchestra configuration to build and run both services together.
  • classifier-service/ (Python ML Service)
    • train.py - Script containing synthetic warehouse document generation, TF-IDF feature extraction, and Logistic Regression training. Saves model pipeline to a .joblib file.
    • app.py - FastAPI application serving model inference via HTTP POST /classify. Automatically runs train.py on startup if no model exists.
    • Dockerfile - Slim Python container environment configuration.
  • erp-service/ (Java ERP Integration Service)
    • pom.xml - Maven configurations using Spring Boot 2.7.18 (Java 8 compatible).
    • WarehouseController.java - Exposes ERP endpoints to classify documents and trigger simulated document batch runs.
    • ClassifierClient.java - Handles REST requests to the Python service using Spring RestTemplate.
    • Dockerfile - Multi-stage Java container compiling the app and serving the .jar package.

🚀 Quick Start (Docker Compose)

The easiest way to start both services and test the integration is using Docker Compose:

# Build and run the MLOps pipeline
docker-compose up --build

Docker will:

  1. Compile the Java code and package the Spring Boot JAR inside the build container.
  2. Build the Python environment and execute the training script (train.py) to generate models/document_classifier.joblib.
  3. Spin up Python service on port 8000 and Java service on port 8081.

📡 Testing the API Endpoints

Once docker-compose is running, you can test the simulated warehouse ERP document classification using curl or Postman:

1. Simulate a Warehouse Batch Processing

This endpoint triggers the Java ERP system to create a mock batch of 4 different warehouse documents (Invoice, Waybill, Receipt, Packing List), call the MLOps Classifier, and return the classified metadata:

curl -X GET http://localhost:8081/api/warehouse/simulate-batch

Expected JSON Response:

[
  {
    "id": "DOC-001",
    "text": "Order details. Invoice number 44293. Total sum due: $340.00. Payment due immediately.",
    "category": "INVOICE",
    "confidence": 0.8845
  },
  {
    "id": "DOC-002",
    "text": "Logistics waybill TRK-88543. Destination: Berlin, Germany. Carrier: DHL Express.",
    "category": "WAYBILL",
    "confidence": 0.9412
  },
  ...
]

2. Classify a Custom Document Text

Post a custom document text to the Java service for classification:

curl -X POST http://localhost:8081/api/warehouse/classify \
     -H "Content-Type: application/json" \
     -d '{"text": "Shipment contains 20 items. 10 keyboards, 10 mice in box 2."}'

Expected JSON Response:

{
  "id": "some-generated-uuid",
  "text": "Shipment contains 20 items. 10 keyboards, 10 mice in box 2.",
  "category": "PACKING_LIST",
  "confidence": 0.8711
}

About

a production-ready, Dockerized template for training and deploying a machine learning micro-model designed to automatically classify/sort warehouse documents (such as invoices, receipts, waybills, and packing lists) for ERP systems

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages