How inavflight/inav-configurator works
Main High-Level Components
• Application Shell & Build System
– Electron main process and rendering processes (indicated by usage of Node.js, npm/yarn commands, and the inclusion of both HTML and JavaScript files).
– Build and packaging scripts (forge.config.js, package.json, various CI workflows under .github/workflows) that drive cross-platform builds.
• User Interface (UI) Layer
– HTML files (index.html, pages in the "tabs" and "wizard" directories) and associated CSS (located in src/css and tabs directories) which form the front-end.
– Client-side JavaScript files that control UI behavior (e.g., js/gui.js, js/main.js, and the many tab-related JS files).
• Communication & Connection Framework
– The “js/connection” folder clearly segregates connection types (connection.js, connectionBle.js, connectionSerial.js, connectionTcp.js, connectionUdp.js) indicating a Factory/Strategy pattern to manage various communication protocols.
– Additional protocol handling found in “js/protocols” (stm32, stm32usbdfu) and MSP related modules in “js/msp”.
• Data & Configuration Management
– Modules handling configuration, settings, defaults and global variables (e.g., js/settings.js, js/globalSettings.js, js/configurator_main.js, js/localization.js).
– Data storage and status updating components (js/data_storage.js, js/periodicStatusUpdater.js).
• External Services Integration
– Map provider integration: components for map configuration (indirectly referenced in the README along with MapProxy and Bing Maps API integration) should be incorporated.
– Asset management for fonts, images, and models stored in “assets”, “images”, and “resources” directories (including OSD fonts and 3D model files).
• Additional Libraries & Utilities
– Third-party libraries (CanvasRenderer, Projector, Three.js, jQuery-related scripts, Switchery, etc.) are housed under "js/libraries" and clearly play roles in rendering and UI interactions.
– Helper utilities for debugging, filtering, and event handling such as js/debug_trace.js, js/helpers.js, and filtering scripts.
Relationships & Interactions
• The UI layer (renderers created from index.html and various tab pages) drives user interactions. It sends commands, configuration updates, and requests to the underlying connection/communication layer.
• The Connection Manager (or the “js/connection” subsystem) abstracts the details of communicating with hardware (serial, BLE, TCP/UDP). This layer uses a factory pattern so that the UI doesn’t need to know the specifics.
• The Configuration Engine (modules like js/configurator_main.js, js/settings.js) bridges UI commands to data storage, applying changes to the INAV firmware parameters and settings.
• Communication between these layers happens via event-driven mechanisms (using callbacks, event listeners, or even web workers as seen in the js/workers directory).
• The Build & Packaging subsystem coordinates cross-platform packaging (WiX for Windows, deb/rpm for Linux, DMG for Mac) and interacts with external services (Map providers configuration, API keys for Bing Maps) as described in the README.
Important Architectural Patterns & Design Principles
• Modularization: Clear separation into directories for connection types, UI logic (tabs, wizard), and external libraries, which allows focused development and easier scalability.
• Abstraction & Factories: Especially in connection modules (using a connectionFactory.js to manage different hardware protocols).
• Event-Driven Programming: Given the number of event listeners, debug modules, and asynchronous UI updates, this becomes central to how data flows within the application.
• Cross-Platform Packaging: Emphasize that the tool is built with cross-platform compatibility in mind using Electron alongside platform-specific build scripts and assets.
• Separation of Concerns: Distinct directories for resources, assets, and logic components (UI, protocol, settings, etc.) ensure a clean architecture.