A real-time telemetry monitoring application built with Tauri, React, and TypeScript. THQ provides a comprehensive dashboard for tracking and visualizing location data, speed metrics, and system logs through WebSocket connections.
Note: THQ is specifically designed for TrainLCD development and testing purposes. This project is tailored to the TrainLCD ecosystem and may not be suitable for general-purpose telemetry monitoring applications.
- Real-time Location Tracking: Monitor GPS coordinates, accuracy, and movement states
- Interactive Mapping: Live map visualization with OpenStreetMap integration using Leaflet
- Speed Analytics: Real-time speed charts and movement state tracking
- WebSocket Architecture: Supports both server and client modes for distributed monitoring
- Telemetry Logging: Comprehensive logging system with different severity levels
- Data Visualization: Interactive charts and tables for telemetry analysis
- Responsive UI: Modern, dark-mode compatible interface built with Tailwind CSS
THQ can operate in two modes:
- Hosts a WebSocket server on port 8080
- Receives telemetry data from multiple clients
- Distributes data to connected subscribers
- Ideal for central monitoring stations
- Connects to a remote WebSocket server
- Receives and displays telemetry data
- Perfect for remote monitoring dashboards
- Node.js (v18 or later)
- Rust (latest stable)
- Tauri Prerequisites
- Clone the repository:
git clone https://github.com/TrainLCD/THQ.git
cd THQ
- Install dependencies:
npm install
- Build and run in development mode:
npm run tauri dev
To start THQ as a WebSocket server:
npm run tauri dev -- --enable-server
- Create a
.env.client.local
file:
WEBSOCKET_ENDPOINT=ws://your-server:8080
- Run in client mode (default):
npm run tauri dev
npm run dev
- Start Vite development servernpm run build
- Build the applicationnpm run tauri dev
- Run Tauri in development modenpm run tauri build
- Build Tauri application for productionnpm run test
- Run testsnpm run test:watch
- Run tests in watch modenpm run check
- Run Biome linter and formatter
src/
βββ components/ # React components
β βββ ConsoleLogTable.tsx
β βββ CurrentLocationMap.tsx
β βββ MovingLogTable.tsx
β βββ SpeedChart.tsx
βββ domain/ # Business logic and types
β βββ commands.ts # Tauri commands and event types
β βββ emoji.ts # State emoji mappings
β βββ threshold.ts # Configuration constants
βββ hooks/ # Custom React hooks
β βββ useTelemetry.ts # Main telemetry data hook
βββ atoms/ # Jotai state management
βββ utils/ # Utility functions
src-tauri/
βββ src/
β βββ ws_server.rs # WebSocket server implementation
β βββ ws_client.rs # WebSocket client implementation
β βββ domain.rs # Rust data structures
β βββ tauri_bridge.rs # Tauri event bridge
βββ Cargo.toml
THQ handles three main types of telemetry events:
{
id: string;
lat: number;
lon: number;
accuracy: number | null;
speed: number;
timestamp: number;
state: "arrived" | "approaching" | "passing" | "moving";
device: string;
}
{
id: string;
type: "system" | "app" | "client";
timestamp: number;
level: "debug" | "info" | "warn" | "error";
message: string;
device: string;
}
{
type: "websocket_message_error" |
"json_parse_error" |
"payload_parse_error" |
"accuracy_low" |
"invalid_coords" |
"unknown";
reason: string;
}
The project includes comprehensive tests for hooks and domain logic:
# Run all tests
npm run test
# Run tests in watch mode
npm run test:watch
THQ uses a JSON-based WebSocket protocol for communication:
Subscribe to events:
{
"type": "subscribe"
}
Location update:
{
"id": "generated-id",
"type": "location_update",
"device": "device-id",
"state": "moving",
"coords": {
"latitude": 35.0,
"longitude": 139.0,
"accuracy": 5.0,
"speed": 10.0
},
"timestamp": 1234567890
}
Log message:
{
"id": "generated-id",
"type": "log",
"device": "device-id",
"timestamp": 1234567890,
"log": {
"type": "system",
"level": "info",
"message": "System operational"
}
}
THQ implements comprehensive error handling for:
- Invalid GPS coordinates
- Low accuracy readings
- WebSocket connection failures
- Malformed telemetry data
- Maintains up to 1,000 telemetry records in memory
- Bounded append with capacity limit (keeps the latest 1,000 entries; no dedup)
- Efficient real-time updates using Jotai state management
- Optimized rendering with React.memo and useMemo
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes
- Run tests (
npm run test
) - Format code (
npm run check
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is part of the TrainLCD ecosystem. Please refer to the LICENSE file for details.
For questions and support, please open an issue on GitHub or contact the TrainLCD team.