app), backend models (backend), and platform bindings (src).
High-Level Architecture
Core Components
Frontend (app/)
React components, Redux state management, Material-UI theming, and user interactions
Backend (backend/)
MQTT topic tree model, message storage, data transformations, and business logic
Platform (src/)
Electron bindings for desktop app and Express server for browser mode
MQTT.js
Connection management, protocol handling, and broker communication
Package Structure
App Package (app/)
The React frontend containing all rendering logic:
Key files:
app/src/components/Sidebar/DetailsTab.tsx- Main UI container (422 lines)app/src/components/Tree/Tree.tsx- Topic tree visualizationapp/src/theme.ts- Material-UI v7 theme configuration
Backend Package (backend/)
Data models and core business logic:
Platform Layer (src/)
Electron and server bindings:
Data Flow
Desktop Mode (Electron)
Browser Mode (Server)
Browser mode uses Socket.IO for bidirectional communication between client and server. Authentication is handled by
AuthManager.ts with bcrypt password hashing.State Management
Redux Store Structure
- Store configuration:
app/src/store.ts - Reducers:
app/src/reducers/ - Actions:
app/src/actions/
MQTT Topic Tree Model
The core data structure (backend/src/Model/Tree.ts):
Tree.updateWithMessage()- Insert/update message in treeTreeNode.findNode()- Traverse to specific topicTreeNode.deleteNode()- Remove topic and children
Component Architecture
Main UI Components
Component Communication
Key Design Patterns
1. Singleton Pattern - LLM Service
Ensures a single instance manages AI assistant state:app/src/services/llmService.ts:229 for implementation.
2. Higher-Order Components - Styling
Material-UI’swithStyles HOC for component styling:
3. Observer Pattern - Event Bus
Cross-component communication without Redux:4. Strategy Pattern - Message Decoders
Pluggable decoders for different message formats:Technology Stack
Frontend
| Technology | Version | Purpose |
|---|---|---|
| React | 19.2.3 | UI framework |
| Redux | 5.0.1 | State management |
| Material-UI | 7.3.6 | Component library |
| TypeScript | 5.9.3 | Type safety |
| D3.js | 7.9.0 | Data visualization |
| @visx/* | 3.x | Chart components |
| ACE Editor | 1.4.11 | Code editing |
Backend
| Technology | Version | Purpose |
|---|---|---|
| MQTT.js | 5.14.1 | MQTT protocol |
| Electron | 39.2.7 | Desktop platform |
| Express | 5.2.1 | Web server |
| Socket.IO | 4.8.1 | Real-time communication |
| Protobuf.js | 8.0.0 | Binary message decoding |
Development
| Technology | Version | Purpose |
|---|---|---|
| Webpack | 5.98.0 | Module bundling |
| Mocha | 10.8.2 | Test framework |
| Playwright | 1.57.0 | UI automation |
| ESLint | 8.57.0 | Code linting |
| Prettier | 3.7.4 | Code formatting |
Platform-Specific Code
Electron Desktop
Entry point:src/electron.ts
- Native menu bar (
src/MenuTemplate.ts) - Auto-updater (
src/autoUpdater.ts) - Crash reporting (
src/registerCrashReporter.ts) - macOS notarization (see
NOTARIZATION.md)
Browser Mode
Entry point:src/server.ts
- Authentication (
src/AuthManager.ts) - Rate limiting (express-rate-limit)
- Security headers (helmet)
- Session management
- Docker deployment support
Extension Points
Adding a Message Decoder
Adding a UI Component
Build Process
Webpack Configuration
Desktop mode:app/webpack.config.js
- Target:
electron-renderer - Entry:
app/src/index.tsx - Output:
app/dist/bundle.js
app/webpack.browser.config.mjs
- Target:
web - Entry:
app/src/index.tsx - Output:
app/dist/bundle.js - Dev server on port 3000
TypeScript Compilation
app/tsconfig.json for Webpack integration.
Performance Considerations
Topic Tree Optimization
- Uses
Mapfor O(1) child lookup - Lazy rendering with
react-windowfor large trees - Memoized selectors to prevent unnecessary renders
Message History
- Circular buffer for chart data (configurable limit)
- Automatic pruning of old messages
- Efficient diff calculation for updates
Bundle Size
- Main bundle: ~2.5 MB (includes Material-UI, D3)
- Vendor bundle: ~1.8 MB
- Total: ~4.3 MB (before gzip)
Testing Architecture
See Testing Guide for comprehensive test documentation. Test locations:- Unit tests:
app/src/**/*.spec.tsx,backend/src/spec/ - UI tests:
src/spec/ui-tests.spec.ts - LLM tests:
app/src/services/spec/
Security Architecture
Security considerations:
- API keys stored in
localStorage(browser) or encrypted storage (Electron) - Password authentication uses bcrypt with 10 rounds
- Rate limiting on authentication endpoints
- Helmet.js security headers in browser mode
- No server-side data storage of MQTT credentials
Deployment Architecture
Desktop Releases
- Electron Builder creates platform-specific packages
- macOS: DMG with notarization
- Windows: NSIS installer + portable
- Linux: AppImage, deb, snap
Docker Container
- Multi-stage build for minimal image size
- Multi-arch support (amd64, arm64, arm/v7)
- Environment-based configuration
- Volume mount for persistent data
Next Steps
Testing
Learn the testing strategy and write tests
Styling
Follow Material-UI styling conventions