A real-time IoT streaming engine for retrofitting analog factory machines with digital monitoring. Ingests telemetry from non-invasive sensors (optical tower lights, CT clamps), tracks machine state in-memory, computes rolling OEE metrics, and broadcasts live updates to dashboards via WebSocket.
Sensors ──TCP──> Ingestion ──chan──> Hub ──chan──> Client ──WebSocket──> Dashboard
(listener) (actor) (writePump)
- Ingestion layer accepts raw TCP connections and decodes newline-delimited JSON telemetry
- Hub runs as a single goroutine owning all state — no mutexes, channel-only communication
- Client pairs (readPump/writePump) manage WebSocket connections with backpressure eviction
- OEE (Availability x Performance x Quality) is computed on the hot path, never from database queries
- Write-ahead buffer handles sensor reconnection — backlogged telemetry replays into state without flooding dashboards
cmd/server/ Server entry point (TCP + HTTP listeners)
cmd/simulator/ Mock sensor fleet with Markov state transitions
internal/model/ Shared domain types (TelemetryPacket, MachineState, OEE)
internal/ingestion/ TCP listener and JSON decoder
internal/engine/ Hub, Client, state machine, OEE calculation
internal/dashboard/ HTTP server and WebSocket upgrade
static/ Dashboard HTML/JS
- Go 1.22+
Build both binaries:
go build ./cmd/server
go build ./cmd/simulatorStart the server:
./server
# or with custom addresses:
./server -tcp :9000 -http :8080Start the simulator:
./simulator
# or with options:
./simulator -sensors 50 -addr localhost:9000 -interval 1sOpen the dashboard at http://localhost:8080, select a factory, and click Connect.
| Flag | Default | Description |
|---|---|---|
-tcp |
:9000 |
Telemetry TCP listen address |
-http |
:8080 |
Dashboard HTTP listen address |
| Flag | Default | Description |
|---|---|---|
-addr |
localhost:9000 |
Server address to connect to |
-sensors |
50 |
Number of simulated sensors |
-interval |
1s |
Send interval per sensor |