How sahiliot/nem_plant_monitoring works
NEM Plant Monitoring pairs a React dashboard with a FastAPI service. Users authenticate, configure assets, variables and monitoring rules, then submit readings or collect them read-only from OPC UA; the service evaluates conditions, records alerts/events and supports maintenance workflows. Dashboard configuration also covers documents, collections, backup/restore and account settings, with live updates and optional email delivery. The graph preserves these documented capabilities; some subsystem links are based on README descriptions because their implementation files were not sampled.
Main entry points: routes HTTP routes · monitoring_engine.py Rule evaluation · App.jsx React dashboard · opcua_collector.py OPC UA collector
Components 23
Dashboard
- React dashboard
Nem_Frontend/src/app/App.jsx - Sign-in state
Nem_Frontend/src/features/auth/AuthContext.jsx - API client
Nem_Frontend/src/services/api.js - Live updates UI
Nem_Frontend/src/services/liveUpdates.js
API and access
- HTTP routes
Nem_Backend/app/api/routes - Accounts and roles
Nem_Backend/app/api/routes/auth.py - Access scoping
Nem_Backend/app/services/access_scope.py
Plant monitoring
- Assets and variables
Nem_Backend/app/api/routes/assets.py - Reading ingestion
Nem_Backend/app/services/reading_ingestion.py - OPC UA collector
Nem_Backend/app/services/opcua_collector.py - OPC UA transport
Nem_Backend/app/services/opcua_client.py - Rules and templates
Nem_Backend/app/schemas/rule.py - Rule evaluation
Nem_Backend/app/services/monitoring_engine.py - Alerts and events
Nem_Backend/app/services/event_log.py
Operations
- Maintenance workflows
Nem_Backend/app/services/maintenance_schedule.py - Dashboard configuration
Nem_Backend/app/api/routes/dashboard.py - Email delivery
Nem_Backend/app/services/email_notifications.py - Live event hub
Nem_Backend/app/main.py
Persistence
- Database sessions
Nem_Backend/app/db/session.py - Application database
Nem_Backend/app/db/init_db.py
Other components
- Plant user
- OPC UA server
- SMTP server
Connections 27
- Plant user → React dashboard: uses
- React dashboard → Sign-in state: routes through
Nem_Frontend/src/app/App.jsx - Sign-in state → API client: requests session
Nem_Frontend/src/features/auth/AuthContext.jsx - React dashboard → API client: calls API
- API client → HTTP routes: sends HTTP
- HTTP routes → Accounts and roles: registers routes
Nem_Backend/app/main.py - HTTP routes → Assets and variables: manages
- HTTP routes → Reading ingestion: accepts readings
- HTTP routes → Rules and templates: configures rules
Nem_Backend/app/api/routes/frontend_compat.py - HTTP routes → Maintenance workflows: manages work
- HTTP routes → Dashboard configuration: manages configuration
Nem_Backend/app/api/routes/frontend_compat.py - HTTP routes → Access scoping: checks access
Nem_Backend/app/main.py - OPC UA server → OPC UA collector: provides signals
- OPC UA collector → OPC UA transport: reads and subscribes
- OPC UA collector → Reading ingestion: submits values
- Reading ingestion → Rule evaluation: triggers evaluation
Nem_Backend/app/services/reading_ingestion.py - Rules and templates → Rule evaluation: defines conditions
- Rule evaluation → Alerts and events: records transitions
Nem_Backend/app/services/monitoring_engine.py - Rule evaluation → Email delivery: enqueues eligible jobs
Nem_Backend/app/services/monitoring_engine.py - Email delivery → SMTP server: delivers mail
- React dashboard → Live updates UI: subscribes
- Live updates UI → Live event hub: opens WebSocket
- Live event hub → OPC UA collector: refreshes configuration
Nem_Backend/app/main.py - HTTP routes → Database sessions: uses sessions
Nem_Backend/app/db/session.py - Database sessions → Application database: reads and writes
Nem_Backend/app/db/session.py - Rule evaluation → Maintenance workflows: supports schedules
- Maintenance workflows → Alerts and events: creates warnings