How unocelli/fuxa works
Project Type and Purpose
• FUXA is a full-stack, web-based SCADA/HMI/Dashboard application.
• Frontend: Angular (HTML5/CSS/TypeScript) providing both an editor (design mode) and a runtime viewer (real-time dashboards).
• Backend: Node.js/Express REST API + a real-time runtime engine that manages device connections (Modbus, S7, OPC-UA, BACnet, MQTT, HTTP, etc.), user/project storage, event dispatching, and plugin execution.
High-Level File Structure and Architectural Indicators
• Top-level “client” folder: Angular CLI app with src/app, src/assets, environments, build configuration.
• src/app/_services (HTTP/REST, auth, project, plugin, HMI services)
• src/app components organized by feature (alarms, device, editor, gauges, users, etc.)
• Top-level “server” folder: Node.js application
• server/api – Express routes for auth, users, projects, plugins, alarms
• server/runtime – Runtime engine modules: device drivers, alarm storage, DAQ storage, event bus, plugin loader
• server/project*.fuxap & .json – project definition files
• server/jwt-helper.js – JWT auth support
• server/main.js & fuxa.js – bootstrap the HTTP server and runtime engine
• No separate database tier: uses file-based or in-memory JSON stores under server/runtime/storage and server/runtime/project and server/runtime/users.
a. Main Components
• User’s Web Browser (Runs Angular Editor & Viewer)
• Angular Client:
– UI Components (Editor, Dashboard Viewer, Login, Settings)
– Services: AuthService, ProjectService, PluginService, HmiService, ResWebApiService (REST), ResClientService (runtime socket/SSE)
• Node.js Backend:
– API Layer (Express routers under server/api)
– Auth Layer (JWT, auth middleware)
– Runtime Engine (server/runtime):
· Device Connectors (Modbus, S7, OPC-UA, BACnet, MQTT, HTTP-Request, Template)
· Storage Modules (project storage, DAQ storage, user storage)
· Event Dispatcher (push data to clients)
· Plugin Host (load/execute custom plugins)
– File-based storage (project files, default settings)
• External Systems:
– Physical/Virtual Devices (PLC, sensors, actuators) using industrial protocols
• Optional Real-Time Channel: WebSocket or Server-Sent Events between runtime engine and Angular client for live data updates.
b. Relationships & Data Flows
1) Browser → HTTP REST → Node API (login, CRUD on users/projects/plugins)
2) Browser ← HTTP REST ← Node API (serve Angular assets or JSON via CI/CD build)
3) Browser ↔ Real-Time Channel ↔ Runtime Engine (subscribe to data points, alarms, events)
4) Runtime Engine → connects → External Devices via various protocol adapters
5) Runtime Engine → writes/reads → file-based storage (project definitions, DAQ data, user settings)
6) Runtime Engine → triggers → Alarm storage & dispatch
c. Architectural Patterns & Principles
• Layered architecture:
• Presentation (Angular)
• API / Controller (Express routers)
• Domain / Runtime Engine (device abstraction, event bus)
• Persistence (file/in-memory JSON storage)
• Modular design: each device protocol and each feature lives in its own module/folder.
• Separation of concerns: Editor code vs. runtime viewer code; API endpoints vs. runtime engine.
• Plugin architecture: server/runtime/plugins and client/src/app/editor/plugins enable extensibility.
d. Key Technologies & Frameworks
• Frontend: Angular, RxJS, Angular CLI, TypeScript, Webpack (via ng build)
• Backend: Node.js, Express.js, jsonwebtoken (JWT), CommonJS modules
• Device Protocols: modbus-serial, node-opcua, node-bacstack, mqtt.js, S7 drivers, HTTP requests
• Storage: file-based JSON (no external DB), in-memory caches for DAQ and alarm history
Essential Elements
• Component names (e.g., AuthService, DeviceConnector, AlarmStorage)
• Data stores (e.g., project.demo.fuxap, prjstorage.js)
• External services/devices and their protocols
• Authentication flow (login → JWT → secured endpoints)
• Plugin loading/execution path
• Runtime event bus pushing to client