This Go project simulates a complete vehicle telemetry system. It connects multiple components — a Generator, Hub, Consumer, and a Frontend (WebSocket) — that exchange telemetry, control commands in real time and visualizes metrics.
This project was developed over the course of four weeks as part of the Training Month (TM) as a Backend Engineer for Hyperloop UPV.
The different branches reflect the project’s progress throughout the four weeks.
Backend components (contained in this repository) were implemented by me, while the frontend —included as a Git submodule — was developed by maximka76667. In the final stage, both parts were integrated into a fully functional end-to-end system.
- Synthetic Generator models speed, pressure, and temperature, reacting to
start,stop,accelerate, andmodecommands with mode-aware speed caps. - Hub that routes data and commands between Generator, Consumer, and Frontend:
- fans telemetry to the frontend (WebSocket) and consumer (UDP) while forwarding commands from the frontend to the generator (channels) and consumer (TCP).
ResultDatais sent to both the Frontend (WS) and Consumer (UDP).Commandmessages flow from the Frontend (WS) to the Generator and Consumer (TCP).
- Consumer listens on UDP/TCP, autodetects
ResultDatavsCommandpayloads, and rotates structured.jsonllogs acrosslogs/,logs/data/, andlogs/commands/. - React frontend (Vite + Tailwind) offers connect/disconnect controls, command groups, toast feedback, and metric tiles that track the latest batch stats in real time.
- Central config package exposes runtime tuning parameters — settings that define how the system behaves when running, such as sensor cadence, aggregation windows, port bindings, log rotation, and vehicle identity.
- End-to-end integration test (
cmd/app/main_test.go) spins up the stack, drives scripted WebSocket commands, and records the telemetry stream undertest/. start.shboots the Go backend and frontend dev server together for a single command developer experience.
TM-software-H11/
│ .gitignore
│ .gitmodules
│ config.json
│ go.mod
│ go.sum
│ README.md
│ start.sh
│
├───cmd
│ └───app
│ main.go
│ main_test.go
│
├───config
│ config.go
│
├───frontend
│ │ package.json
│ │ package-lock.json
│ └───src
│
├───internal
│ ├───consumer
│ │ consumer.go
│ │ listener.go
│ │ logger.go
│ │ parser.go
│ │
│ ├───generator
│ │ generator.go
│ │ processor.go
│ │ sensor.go
│ │
│ ├───hub
│ │ hub.go
│ │ tcphandler.go
│ │ updhandler.go
│ │ wshandler.go
│ │
│ └───model
│ command.go
│ resultData.go
│ sensorData.go
│
├───logs
│ ├───commands
│ └───data
└───test
test_logs.jsonl
-
Install Go 1.25.1 or newer and Node.js 20+ (with npm).
-
Clone the repository, change into it and update the submodule:
git clone https://github.com/vasyl-ks/TM-software-H11.git cd TM-software-H11 git submodule update --init --recursive -
Inspect and adjust
config.jsonfor your desired intervals, ports, range and mode ratios. -
Install frontend dependencies:
cd frontend npm install -
Run the stack:
cd .. ./start.shThe script launches
go run ./cmd/app/main.goandnpm run dev(Vite). Stop withCtrl+C. -
To run only the backend:
go run ./cmd/app/main.go
Then start the frontend separately with
npm run devinsidefrontend/(use-- --hostif you need LAN access). -
To execute the integration test (writes logs under
test/):go test ./cmd/app -run TestFrontendSimulation -v -
Inspect telemetry and command logs in
logs/after running. Files rotate automatically whenmaxLinesis reached.
config.json governs how the system behaves:
- vehicle
vehicleID: identifier stamped on telemetry batches.
- sensor
intervalMilliSeconds: cadence for raw SensorData generation.minSpeed,maxSpeed,minPressure,maxPressure,minTemp,maxTemp: randomization bounds.ecoMode,normalMode,speedMode: relative limits applied when each driving mode is active.
- processor
intervalMilliSeconds: aggregation window for computing averages/min/max.
- logger
maxLines: number of log entries before a new file is created.fileDir: root folder for combined, data-only, and command-only.jsonllogs.
- hub
udpPort,tcpPort,wsPort: loopback endpoints used by consumer and frontend.bufferSize: byte buffer used by UDP/TCP readers.
Configuration loads once on startup via config.LoadConfig(). Update the file and restart to apply changes.
- Generator
Sensoremits random-but-mode-aware speed, pressure, and temperature readings and reacts to incoming commands.Processbatches readings for the configured interval, fan-outs calculations across goroutines, and forwards summarizedResultData.
- Hub
- Registers
/api/streamand upgrades HTTP requests to WebSocket connections. - Streams each
ResultDatabatch to connected frontend and the consumer (UDP) while duplicating commands to generator (channels) and consumer (TCP).
- Registers
- Consumer
- Opens UDP and TCP listeners (signalling readiness through
consumer.Ready). - Differentiates telemetry vs command payloads, then logs each to rotating files with timestamps.
- Opens UDP and TCP listeners (signalling readiness through
- Frontend
- Uses a WebSocket hook to connect on demand, show connection status, render the latest metrics, and send predefined commands or custom acceleration values.
- Provides toast notifications for connect/disconnect, command results, and validation feedback.
- Tests
TestFrontendSimulationspins up the services, drives a scripted command sequence, captures the WebSocket stream, and persists the interaction undertest/test_logs.jsonl.
- The system is fully concurrent, using goroutines and channels for communication.
- Goroutines and channels orchestrate concurrency;
consumer.Readyensures network listeners are up before the hub dials TCP/UDP. - The system is fully concurrent, using goroutines and channels for communication.
- Each transport layer (UDP, TCP, WS) runs independently but shares data via the Hub.
- WebSocket handlers handle graceful close frames and distinguish expected vs unexpected disconnects for cleaner logs.
- Generator speed adjusts based on commands in real time.
- Temperature and pressure are randomly generated based on speed, and they increase or decrease at different rates depending on the mode.
- Frontend tests provide an end-to-end check of the communication pipeline.
- Logs in
.jsonlformat are machine- and human-readable, suitable for further analysis. - Once the program starts, the vehicle begins sending telemetry automatically, but it must be started and accelerated through commands to simulate motion.