IMPLEMENTATION DOCS / UNS FRAMEWORK

Components

The 12 documented components of fn-uns, grouped by their role in capturing, processing, and using machine data.

Use this map to choose the components for your use case. The sample quick start runs only the capture pipeline.
On this page 6 sections
Data PipelineCapture LayerProcessing LayerReporting LayerAI LayerShared Patterns

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│
└──────────────────────────────────┬──────────────────────────┘
                                   │
┌──────────────────────────────────┼──────────────────────────┐
│                        AI        │                           │
│  uns-ai ← reads Valkey + all PostgreSQL tables              │
│         → calls AI provider (OpenAI / Anthropic)            │
│         → publishes results to MQTT                         │
│         → stores audit trail in PostgreSQL                  │
└─────────────────────────────────────────────────────────────┘

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-historianGoMQTTLogs every value change to PostgreSQL in real-time
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
uns-dashboardGrafanaDashboards5 dashboards for real-time manufacturing visibility

AI Layer

ComponentLanguageTypePurpose
uns-aiNode.jsHTTPAI-powered analysis: anomaly detection, shift summaries, smart alerting, predictive maintenance

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.