Skip to main content

Generated page. Written from IdaMilk/SunApps_Manufacturing at commit 3e9a346 on 2026-07-28, version 1.1.13.

SunApps Manufacturing

What is it?

An Express service that coordinates manufacturing workflow: creating and completing work orders, tracking what has been staged at each production line, managing the consumption queue, and running backflush.

It is one of the services the SunApps Gateway proxies to.

Purpose

Completing a work order is not one action — it needs the right materials staged in the right consumption bins, the consumed quantities backflushed, and the finished pallets created. This service owns that choreography so the front-end can treat "complete this work order" as a single call.

The staging dashboard exists because the lines stop when material is not staged. Tracking queue depth per line and reminding stagers before a line runs dry is the difference between a smooth shift and a stoppage.

How it Works

Standard Express layering — routes → controllers → services → Sequelize models — with the interesting logic in the services.

Work order completion takes a staging configuration, resolves which consumption bins the line draws from (config/lineConfig.js), backflushes consumed material, and creates finished-good pallets. helpers/ensureWorkOrderHasLot.js guards the case where a work order reaches completion without a lot assigned.

The consumption queue is polled rather than event-driven. consumptionQueueService watches queue depth per line and raises reminders when work orders are waiting on staged pallets — those reminders go back through the gateway's /internal API, which broadcasts them over Socket.IO to the stagers room. Polling can be switched off entirely with DISABLE_POLLERS.

MESWOCBuffer buffers work order completion data arriving from MES, which decouples the two services: MES can post a pallet completion without waiting for the downstream work to finish.

Core Features

FeaturePurpose
Work order completionComplete a work order with its staging configuration
Work order lookupDetails, item list, staging configuration
Consumption bin resolutionWhich bins a production line draws from
Staging dashboardLive staging state per line
Consumption queueQueue depth tracking and staging reminders
BackflushRecords material consumed against a work order
Finished-good palletsCreates pallets for completed production
Pallet completion from MESEntry point for MES-triggered pallet events
KPI pollingFeeds KPI displays

API

MethodPathPurpose
GET/Health check
POST/api/workorder/completeComplete a work order with staging configuration
GET/api/workorder/:idWork order details and item list
GET/api/workorder/:id/stagingStaging configuration for a work order
GET/api/workorder/line/:lineId/binsConsumption bins for a line
POST/api/manufacturing/pallet-completionTrigger a pallet completion event
GET/api/staging/dashboardStaging dashboard data
POST/api/staging/notify-transferNotify a staging transfer completed
GET/api/staging/queue/:lineIdQueue status for a line
DELETE/api/staging/queue/:lineIdClear a line's queue
GET/api/staging/line-configLine bin configuration
PUT/api/staging/line-configUpdate line bin configuration

The /api/mes mount is a compatibility alias. The same router is mounted at both /api/manufacturing and /api/mes. The /api/mes namespace now belongs to SunApps MES, but external callers still POST to /api/mes/pallet-completion, so the gateway registers that one path against this service before its /api/mes catch-all. Two services and one gateway all have to agree about that path — worth knowing before changing any of them.

Data model

ModelHolds
ConsumptionQueueMaterial consumption events awaiting processing
MESWOCBufferWork order completion data buffered from MES

Sequelize syncs models on startup, and ensureRuntimeSchema() applies additional runtime schema — the same boot-time migration pattern used by the gateway and MES.

Tech Stack

TechnologyVersionPurpose
Express5.2.1HTTP framework
Sequelize6.37.8ORM
tedious19.2.1SQL Server driver
morgan1.10.1Request logging
rotating-file-stream3.2.9Log rotation
cors2.8.6Cross-origin support
dotenv17.4.2Configuration

Node 14 or higher per the README, though the deployment workflow and sibling services use Node 24.

Interfaces

SystemDirectionPurpose
SunApps GatewaybothReceives proxied traffic; calls back via /internal for broadcasts
SQL ServeroutboundQueue and buffer state
SunApps MESinboundPallet completion events
NetSuiteoutboundVia the Core API gateway

Operations

Deployed by GitHub Actions to an internal application server under a process supervisor — the same development / production / tagging workflow trio as the other SunApps services.

Configuration, names only:

VariableDefaultPurpose
ENVIRONMENTdevEnvironment mode
PORT4002Listen port
DISABLE_POLLERSfalseDisables consumption queue polling
CORE_API_URLGateway base URL
SQL_SERVER, SQL_DATABASE, SQL_USER, SQL_PASSWORDrequiredDatabase connection

If staging reminders stop appearing, check DISABLE_POLLERS before anything else — it silences the queue poller without any other visible symptom.

Repository

RepositoryIdaMilk/SunApps_Manufacturing
Version1.1.13
Primary languageJavaScript (Node, CommonJS)
Files29
Last activity2026-07-14
StatusActive