本文へスキップ
プロジェクトに戻る

SMTrack+

: 2024担当: Front-end lead & API development1回閲覧

Real-time temperature monitoring for hospital medicine cabinets, with WebSocket alerts and MQTT-connected devices.

技術構成

What the system does#

SMTrack+ monitors the temperature of medicine cabinets across a hospital and reports on it through a set of RESTful APIs. The web client is built with a modern front-end stack, and state management was part of the design from day one — readings do not trickle in, they stream continuously from dozens of cabinets at once.

How a reading reaches the screen#

  • An embedded device inside each cabinet samples temperature and humidity, then publishes to its own MQTT topic.
  • The server subscribes to every topic, persists each reading to PostgreSQL, and checks it against the configured safe range.
  • When a reading falls out of range the server broadcasts over WebSocket, so any dashboard already open updates itself — nobody has to refresh.
  • The client keeps the latest values in one store, so the charts, the summary cards and the alert list can never disagree with each other.
javascript
client.subscribe('smtrack/+/temperature', { qos: 1 })

client.on('message', (topic, payload) => {
  const deviceId = topic.split('/')[1]
  const reading = JSON.parse(payload.toString())

  void readings.save(deviceId, reading)
  if (readings.isOutOfRange(reading)) gateway.emit('alert', { deviceId, reading })
})
An alert that arrives five minutes late is barely different from having no alerting at all.
Lesson from the first ward rollout

Shipping and keeping it running#

  1. Configured GitHub Actions to build and deploy automatically on every merge into the main branch.
  2. Kept staging and production on separate environments so changes are exercised before they reach a live ward.
  3. Logged device disconnects separately from application errors, which cut on-site debugging time considerably.
LayerTechnologyResponsibility
Web appNext.js + TypeScriptDashboard, history charts, device configuration
APINestJS + PostgreSQLReading storage and alerting rules
DevicesMQTTPublish sensor readings from inside each cabinet
AlertsWebSocketPush state changes to open dashboards instantly