Architecture Overview
FitFileViewer is built as a cross-platform desktop application using Electron with a modular, scalable architecture.
High-Level Architectureβ
Key Principlesβ
π Security-Firstβ
- Context isolation enabled
- Node integration disabled in renderer
- Secure IPC communication
- Input validation
π¦ Modularityβ
- 50+ utility modules
- Clear separation of concerns
- Reusable components
- Single responsibility
β‘ Performanceβ
- Lazy loading
- Efficient data processing
- Memory management
- Caching strategies
Technology Stackβ
| Layer | Technology | Purpose |
|---|---|---|
| Framework | Electron | Cross-platform desktop |
| UI | HTML/CSS/JS | User interface |
| Charts | Chart.js, Vega-Lite | Data visualization |
| Maps | Leaflet | Geographic display |
| Tables | DataTables | Data grid |
| Parser | Garmin FIT SDK | FIT file parsing |
Component Layersβ
Process Modelβ
FitFileViewer uses Electron's multi-process architecture:
| Process | Responsibilities |
|---|---|
| Main | App lifecycle, window management, file system, IPC |
| Renderer | UI rendering, user interaction, visualization |
| Preload | Secure bridge between main and renderer |
Module Organizationβ
electron-app/
βββ main.ts # Main process source entry
βββ renderer.ts # Renderer process source entry
βββ preload.ts # Security bridge source
βββ main-ui.ts # UI management source
βββ fitParser.ts # FIT file parsing source
βββ utils/ # Utility modules
βββ formatting/ # Data formatters
βββ maps/ # Map utilities
βββ charts/ # Chart utilities
βββ state/ # State management
βββ ... # More modules
Data Flowβ
Security Modelβ
IPC Securityβ
All communication between processes uses validated channels:
// Preload - Exposed API
contextBridge.exposeInMainWorld("electronAPI", {
openFile: () => ipcRenderer.invoke("dialog:open-fit-file"),
// Only specific, validated operations
});
Content Securityβ
- No remote content loading
- Strict CSP headers
- Sandboxed renderer
Next: Process Architecture β