# pattanakorn025/ims architecture

> Architecture diagram of the GitHub repository pattanakorn025/ims, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pattanakorn025/ims
- Repository: https://github.com/pattanakorn025/ims

## Overview

IMS combines OT/IT telemetry monitoring with a manufacturing digital twin and SPC workflows. The main path is device telemetry through Node-RED into PostgreSQL/TimescaleDB, then queried and interpreted for operational dashboards and engineering analysis. The factory-twin service exposes live state, geometry, alarms, history, and predictive/SPC results to browser views; a separate alarm API handles lifecycle transitions. README documents the broader Grafana/TimescaleDB platform, while sampled excerpts support only selected service routes and library calls, so uncertain wiring is omitted.

Main entry points: [`services/factory-twin-3d/server.js`](https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/server.js) (Factory Twin API), [`nodered_data/settings.js`](https://github.com/pattanakorn025/ims/blob/main/nodered_data/settings.js) (Node-RED Ingestion), [`services/alarm-api/server.js`](https://github.com/pattanakorn025/ims/blob/main/services/alarm-api/server.js) (Alarm Lifecycle API), [`services/factory-twin-3d/public/app.js`](https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/public/app.js) (3D Twin View)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Telemetry Ingestion"]
  node_nodered["Node-RED Ingestion<br/>[settings.js]"]
  node_parser["SNMP Parser<br/>[parser.js]"]
  node_breaker["Circuit Breaker<br/>[circuit-breaker.js]"]
end

subgraph group_data["Data And Analysis"]
  node_timescale[("TimescaleDB")]
  node_telemetry["Telemetry Queries<br/>[telemetry.js]"]
  node_analytics["Analytics<br/>[analytics.js]"]
  node_spc["SPC Analysis<br/>[spc.js]"]
  node_predictive["Predictive Analysis<br/>[predictive.js]"]
  node_alarmstate[("Alarm Lifecycle State")]
end

subgraph group_twin["Factory Twin"]
  node_twinserver["Factory Twin API<br/>[server.js]"]
  node_mapping["Asset Mapping<br/>[mapping.js]"]
  node_wire["Geometry Projection<br/>[wire.js]"]
  node_alarmlib["Alarm Logic<br/>[alarm.js]"]
end

subgraph group_ops["Operations And Views"]
  node_alarmapi["Alarm Lifecycle API<br/>[server.js]"]
  node_app["3D Twin View<br/>[app.js]"]
  node_eap["EAP Floor Map<br/>[eap.js]"]
  node_grafana["Grafana Dashboards"]
end

node_ot(("OT Devices"))
node_it(("IT Fleet"))
node_operator(("Operator / Engineer"))

node_ot -->|"send telemetry"| node_nodered
node_it -->|"send SNMP data"| node_nodered
node_nodered -->|"parse readings"| node_parser
node_nodered -->|"guard polling"| node_breaker
node_nodered -->|"ingest telemetry"| node_timescale
node_twinserver -->|"query state"| node_timescale
node_twinserver -->|"fetch history"| node_telemetry
node_twinserver -->|"validate metrics"| node_analytics
node_twinserver -->|"compute SPC"| node_spc
node_twinserver -->|"build forecasts"| node_predictive
node_twinserver -->|"resolve identity"| node_mapping
node_twinserver -->|"project geometry"| node_wire
node_twinserver -->|"resolve alarm identity"| node_alarmlib
node_alarmapi -->|"read and update"| node_alarmstate
node_app -->|"request twin data"| node_twinserver
node_eap -->|"request floor data"| node_twinserver
node_grafana -->|"query dashboards"| node_timescale
node_operator -->|"inspect factory"| node_app
node_operator -->|"inspect floor"| node_eap
node_operator -->|"review metrics"| node_grafana
node_operator -->|"manage alarms"| node_alarmapi

click node_nodered "https://github.com/pattanakorn025/ims/blob/main/nodered_data/settings.js"
click node_parser "https://github.com/pattanakorn025/ims/blob/main/nodered_data/lib/parser.js"
click node_breaker "https://github.com/pattanakorn025/ims/blob/main/nodered_data/lib/circuit-breaker.js"
click node_twinserver "https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/server.js"
click node_telemetry "https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/lib/telemetry.js"
click node_analytics "https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/lib/analytics.js"
click node_spc "https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/lib/spc.js"
click node_predictive "https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/lib/predictive.js"
click node_mapping "https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/lib/mapping.js"
click node_wire "https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/lib/wire.js"
click node_alarmlib "https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/lib/alarm.js"
click node_alarmapi "https://github.com/pattanakorn025/ims/blob/main/services/alarm-api/server.js"
click node_app "https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/public/app.js"
click node_eap "https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/public/eap.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_nodered,node_parser,node_breaker toneBlue
class node_timescale,node_telemetry,node_analytics,node_spc,node_predictive,node_alarmstate toneAmber
class node_twinserver,node_mapping,node_wire,node_alarmlib toneMint
class node_alarmapi,node_app,node_eap,node_grafana toneRose
class node_ot,node_it,node_operator toneIndigo
```

## Components

### Telemetry Ingestion

- [Node-RED Ingestion](https://github.com/pattanakorn025/ims/blob/main/nodered_data/settings.js): `nodered_data/settings.js`
- [SNMP Parser](https://github.com/pattanakorn025/ims/blob/main/nodered_data/lib/parser.js): `nodered_data/lib/parser.js`
- [Circuit Breaker](https://github.com/pattanakorn025/ims/blob/main/nodered_data/lib/circuit-breaker.js): `nodered_data/lib/circuit-breaker.js`

### Data And Analysis

- **TimescaleDB**
- [Telemetry Queries](https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/lib/telemetry.js): `services/factory-twin-3d/lib/telemetry.js`
- [Analytics](https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/lib/analytics.js): `services/factory-twin-3d/lib/analytics.js`
- [SPC Analysis](https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/lib/spc.js): `services/factory-twin-3d/lib/spc.js`
- [Predictive Analysis](https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/lib/predictive.js): `services/factory-twin-3d/lib/predictive.js`
- **Alarm Lifecycle State**

### Factory Twin

- [Factory Twin API](https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/server.js): `services/factory-twin-3d/server.js`
- [Asset Mapping](https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/lib/mapping.js): `services/factory-twin-3d/lib/mapping.js`
- [Geometry Projection](https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/lib/wire.js): `services/factory-twin-3d/lib/wire.js`
- [Alarm Logic](https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/lib/alarm.js): `services/factory-twin-3d/lib/alarm.js`

### Operations And Views

- [Alarm Lifecycle API](https://github.com/pattanakorn025/ims/blob/main/services/alarm-api/server.js): `services/alarm-api/server.js`
- [3D Twin View](https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/public/app.js): `services/factory-twin-3d/public/app.js`
- [EAP Floor Map](https://github.com/pattanakorn025/ims/blob/main/services/factory-twin-3d/public/eap.js): `services/factory-twin-3d/public/eap.js`
- **Grafana Dashboards**

### Other components

- **OT Devices**
- **IT Fleet**
- **Operator / Engineer**

## Connections

- OT Devices → Node-RED Ingestion: send telemetry
- IT Fleet → Node-RED Ingestion: send SNMP data
- Node-RED Ingestion → SNMP Parser: parse readings
- Node-RED Ingestion → Circuit Breaker: guard polling
- Node-RED Ingestion → TimescaleDB: ingest telemetry
- Factory Twin API → TimescaleDB: query state
- Factory Twin API → Telemetry Queries: fetch history
- Factory Twin API → Analytics: validate metrics
- Factory Twin API → SPC Analysis: compute SPC
- Factory Twin API → Predictive Analysis: build forecasts
- Factory Twin API → Asset Mapping: resolve identity
- Factory Twin API → Geometry Projection: project geometry
- Factory Twin API → Alarm Logic: resolve alarm identity
- Alarm Lifecycle API → Alarm Lifecycle State: read and update
- 3D Twin View → Factory Twin API: request twin data
- EAP Floor Map → Factory Twin API: request floor data
- Grafana Dashboards → TimescaleDB: query dashboards
- Operator / Engineer → 3D Twin View: inspect factory
- Operator / Engineer → EAP Floor Map: inspect floor
- Operator / Engineer → Grafana Dashboards: review metrics
- Operator / Engineer → Alarm Lifecycle API: manage alarms
