How tma/tm-to-abrp works
Project type and purpose
• This is a small, Dockerized Go-based microservice (“TM-to-ABRP Bridge”) whose job is to subscribe to Teslamate’s MQTT feed, transform the live data for A Better Route Planner (ABRP), and optionally expose a minimal web UI for manual control.
File structure
• Top-level Docker & VSCode configs (.devcontainer/, Dockerfile, .github/workflows) indicate containerized CI/CD.
• cmd/main.go is the entry point.
• internal/app/ contains the core modules:
• abrp.go – ABRP API client
• car.go – domain model for Tesla car data
• http.go – HTTP server & UI handlers
• messages.go – MQTT subscription and message parsing
• web/public and web/templates hold the static assets and HTML templates for the user interface.
• test/send_messages.go is a smoke test tool.
README for additional insights
• The README confirms the service subscribes to an MQTT broker (Teslamate must be configured), processes messages, and forwards them to ABRP using its REST API (requires API keys and tokens).
• It also describes a tiny web UI on a configurable PATH_PREFIX to enable/disable data forwarding for a time window.
• Docker-compose examples show it runs in isolation or alongside Teslamate.
Components and their relationships
a. Main components:
• MQTT Broker (external, via Teslamate)
• TM-to-ABRP Bridge (Docker container hosting Go service)
• MQTT Client (internal/messages.go)
• Data Processor & Car Model (internal/car.go)
• ABRP REST Client (internal/abrp.go)
• HTTP Server & UI (internal/http.go + web/templates + web/public)
• ABRP External Service (REST API)
• Web Browser / User (interacts with UI)
b. Interactions:
• Bridge → subscribes to MQTT topics ← Teslamate
• Bridge → transforms incoming payloads → ABRP via HTTPS
• User ← HTTP GET/POST → Bridge’s web server (enable/disable forwarding)
c. Architectural patterns & principles:
• Single-container microservice (12-factor app): environment-driven config, stateless.
• Clear separation of concerns: messaging, domain modeling, external API client, HTTP/UI.
• Minimalist web UI embedded in service.
d. Key technologies: Go, MQTT client library, net/http, HTML templates, Docker
Putting it all together
1) MQTT Client ← subscribe
2) Message Processor & Car Model
3) ABRP REST Client → publish
4) HTTP Server + Templates/Static UI
• Environment-variable-driven config at the container perimeter.