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
| Feature | Purpose |
|---|---|
| Work order completion | Complete a work order with its staging configuration |
| Work order lookup | Details, item list, staging configuration |
| Consumption bin resolution | Which bins a production line draws from |
| Staging dashboard | Live staging state per line |
| Consumption queue | Queue depth tracking and staging reminders |
| Backflush | Records material consumed against a work order |
| Finished-good pallets | Creates pallets for completed production |
| Pallet completion from MES | Entry point for MES-triggered pallet events |
| KPI polling | Feeds KPI displays |
API
| Method | Path | Purpose |
|---|---|---|
GET | / | Health check |
POST | /api/workorder/complete | Complete a work order with staging configuration |
GET | /api/workorder/:id | Work order details and item list |
GET | /api/workorder/:id/staging | Staging configuration for a work order |
GET | /api/workorder/line/:lineId/bins | Consumption bins for a line |
POST | /api/manufacturing/pallet-completion | Trigger a pallet completion event |
GET | /api/staging/dashboard | Staging dashboard data |
POST | /api/staging/notify-transfer | Notify a staging transfer completed |
GET | /api/staging/queue/:lineId | Queue status for a line |
DELETE | /api/staging/queue/:lineId | Clear a line's queue |
GET | /api/staging/line-config | Line bin configuration |
PUT | /api/staging/line-config | Update 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
| Model | Holds |
|---|---|
ConsumptionQueue | Material consumption events awaiting processing |
MESWOCBuffer | Work 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
| Technology | Version | Purpose |
|---|---|---|
| Express | 5.2.1 | HTTP framework |
| Sequelize | 6.37.8 | ORM |
| tedious | 19.2.1 | SQL Server driver |
| morgan | 1.10.1 | Request logging |
| rotating-file-stream | 3.2.9 | Log rotation |
| cors | 2.8.6 | Cross-origin support |
| dotenv | 17.4.2 | Configuration |
Node 14 or higher per the README, though the deployment workflow and sibling services use Node 24.
Interfaces
| System | Direction | Purpose |
|---|---|---|
| SunApps Gateway | both | Receives proxied traffic; calls back via /internal for broadcasts |
| SQL Server | outbound | Queue and buffer state |
| SunApps MES | inbound | Pallet completion events |
| NetSuite | outbound | Via 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:
| Variable | Default | Purpose |
|---|---|---|
ENVIRONMENT | dev | Environment mode |
PORT | 4002 | Listen port |
DISABLE_POLLERS | false | Disables consumption queue polling |
CORE_API_URL | — | Gateway base URL |
SQL_SERVER, SQL_DATABASE, SQL_USER, SQL_PASSWORD | required | Database connection |
If staging reminders stop appearing, check DISABLE_POLLERS before anything else — it silences the queue poller without any other visible symptom.
Repository
| Repository | IdaMilk/SunApps_Manufacturing |
| Version | 1.1.13 |
| Primary language | JavaScript (Node, CommonJS) |
| Files | 29 |
| Last activity | 2026-07-14 |
| Status | Active |