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
| Component | Language | Type | Purpose |
| uns-sim | Node.js | MQTT publisher | Simulates 4 CNC machines across 2 areas |
| uns-framework | Go | MQTT subscriber | Caches all UNS topics to Valkey |
Processing Layer
| Component | Language | Type | Purpose |
| uns-cache | Node.js | HTTP | Reads cached topics with change detection |
| uns-log | Go | HTTP | Logs change snapshots to PostgreSQL |
| uns-state | Go | HTTP | Tracks machine state durations |
| uns-stoppage | Node.js | HTTP | Classifies stoppage reasons |
| uns-productivity | Go | HTTP | Tracks production runs and throughput |
| uns-input | Node.js | HTTP | Manual operator data entry |
Reporting Layer
| Component | Language | Type | Purpose |
| uns-kpi | Go | HTTP | Computes manufacturing KPIs from all data |
Shared Patterns
All functions follow consistent patterns:
| Pattern | Description |
| Valkey config | Runtime configuration stored in fnkit:config:*, cached 30s |
| Auto-create tables | PostgreSQL tables created on first run, no migrations |
| UNS path parsing | Hierarchy (enterprise/site/area/machine) extracted from topic path |
| JSON responses | All HTTP functions return structured JSON |
| Docker containers | Each function runs in its own container on fnkit-network |
| Independent deploy | Update one function without affecting others |
See Code Patterns for implementation details.