Data Flow¶
Startup¶
- Operator starts
serveorworker. - Configuration is loaded: OS environment, then
.env/--env-file, then defaults. - MongoDB connection is established.
serveandworkerfail fast if MongoDB is unreachable. - HTTP routes become available for
serve. workerwaits for shutdown signals and does not execute outbound business jobs.
Inbound work-order request flow¶
flowchart TD
req[HTTP request JSON or XML] --> dec[Decoder]
dec --> norm[Normalize]
norm --> val[Contract validation]
val --> actor[Integration actor]
actor --> svc[Persistence service]
svc --> mongo[(MongoDB)]
svc --> resp[Standard response envelope]
| Step | Behavior |
|---|---|
| Request | POST /api/v1/inbound/work-orders (live) or /test (format only) |
| Decoder | JSON DisallowUnknownFields or strict XML; DOCTYPE rejected |
| Normalize | stage_type Turkish casing; UTC Z datetimes |
| Validate | Required fields, StrictInt64, enums, date order, duplicates |
| Actor | Exists, active, tenant match — or typed 409 / unexpected 500 |
| Service | Product upsert, project/production/stage merge, machine/employee resolve |
| MongoDB | Customer database; no multi-document transaction required |
| Response | { success, request_id, data, error } with summary and warnings |
Live POST also applies Idempotency-Key and request archive when those features are enabled.
Planned outbound flow¶
The worker is intended to read eligible MongoDB records and push them to external APIs. This is not implemented.