Components

The 9 functions that make up the UNS pipeline. They communicate through shared infrastructure — not through direct calls to each other.

Data Pipeline

┌─────────────────────────────────────────────────────────────┐
│                        CAPTURE                               │
│  uns-sim ──→ MQTT Broker ──→ uns-framework ──→ Valkey Cache │
└──────────────────────────────────┬──────────────────────────┘
                                   │
┌──────────────────────────────────┼──────────────────────────┐
│                        PROCESS   │                           │
│  uns-cache ← reads ─────────────┤                           │
│  uns-log ← reads ───────────────┤                           │
│  uns-state ← reads ─────────────┘                           │
│       │                                                      │
│       ▼                                                      │
│  uns-stoppage ← reads uns_state table                       │
│  uns-productivity ← reads Valkey /program topics            │
│  uns-input ← receives HTTP POST from operators              │
└──────────────────────────────────┬──────────────────────────┘
                                   │
┌──────────────────────────────────┼──────────────────────────┐
│                        REPORT    │                           │
│  uns-kpi ← reads all PostgreSQL tables ──→ JSON KPI response│
└─────────────────────────────────────────────────────────────┘

Capture Layer

ComponentLanguageTypePurpose
uns-simNode.jsMQTT publisherSimulates 4 CNC machines across 2 areas
uns-frameworkGoMQTT subscriberCaches all UNS topics to Valkey

Processing Layer

ComponentLanguageTypePurpose
uns-cacheNode.jsHTTPReads cached topics with change detection
uns-logGoHTTPLogs change snapshots to PostgreSQL
uns-stateGoHTTPTracks machine state durations
uns-stoppageNode.jsHTTPClassifies stoppage reasons
uns-productivityGoHTTPTracks production runs and throughput
uns-inputNode.jsHTTPManual operator data entry

Reporting Layer

ComponentLanguageTypePurpose
uns-kpiGoHTTPComputes manufacturing KPIs from all data

Shared Patterns

All functions follow consistent patterns:

PatternDescription
Valkey configRuntime configuration stored in fnkit:config:*, cached 30s
Auto-create tablesPostgreSQL tables created on first run, no migrations
UNS path parsingHierarchy (enterprise/site/area/machine) extracted from topic path
JSON responsesAll HTTP functions return structured JSON
Docker containersEach function runs in its own container on fnkit-network
Independent deployUpdate one function without affecting others

See Code Patterns for implementation details.