How betaflight/blackbox-log-viewer works
Main Components
a. User Interface (UI) Layer:
• Represented by the primary HTML file (index.html) and assets in the “public” folder (images, CSS, client-side JavaScript).
• The UI includes interactive elements (e.g., “Open log file/video” button, seek bar, graph displays, dialogs) that allow users to load, view, and interact with logs and videos.
b. Core Application Logic (Frontend Application Core):
• The “src” folder contains key modules such as log parsing (e.g., flightlog.js, flightlog_parser.js), graph configuration (graph_config.js and associated dialogs), and other tools (e.g., gps_transform.js, decoders.js).
• This layer encapsulates the business logic, including synchronizing logs with video playback, graphing, and video export functionalities.
c. Web Workers & Export Modules:
• The “webm-writer” subdirectory also indicates a clear module for exporting graphs as WebM video by handling video encoding.
d. External Libraries & Vendor Code:
• Files in “public/js” (e.g., FileSaver.js, three.js, jquery-related libraries) and the “src/vendor” directory represent 3rd-party libraries that assist with UI, data processing, animation, or other functionalities.
• These libraries are integrated into the core code base to enable specific features such as graphing and multimedia handling.
e. Development & Build Tools:
• Configuration files such as package.json, vite.config.js, and the presence of yarn scripts point to a modern development environment with Vite for bundling, hot module reloading, and other optimizations.
• Directories like “test” indicate that automated testing and sample configurations are part of the quality assurance process.
Relationships and Interactions
• The user launches the application through the browser (indexed by index.html), which loads assets from the “public” directory.
• UI actions drive the core application logic found in the “src” modules. For instance, when a log file is loaded, the parser module (flightlog_parser.js) processes the file and prepares data for the graph modules.
• Graphing components (graph_config, graph_spectrum, etc.) render visualizations, and any computationally heavy tasks (e.g., CSV, GPX exports) are offloaded to dedicated Web Workers which communicate back using postMessage mechanisms.
• External libraries (jQuery, FileSaver.js, three.js) interface directly with the UI components or assist in processing data, enabling a smooth interactive experience.
• Development tooling (Vite, Yarn, nvm) sits outside the runtime architecture but is critical for builds, testing, and deployment.
Architectural Patterns & Design Principles
• There is a clear separation of concerns: the presentation/UI layer (HTML/CSS, static assets) is decoupled from the application logic (src modules) and specialized worker processes.
• The PWA design pattern is in use, meaning the application is built to function both online and offline.
• Modularity is key: individual functionalities like log parsing, data visualization, and export functions are implemented as discrete modules, ensuring maintainability and ease of testing.
Additional Note
• Architecture’s modularity, PWA nature (offline capability), and the integration of third-party libraries that extend functionality.