model-garage

module
v0.8.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2026 License: Apache-2.0

README

Model Garage

GitHub license GoDoc Go Report Card

Welcome to the Model Garage, a Golang toolkit for managing and working with DIMO vehicle signal data.

Features

  1. Signal Conversion: Converting raw data from various hardware devices (AutoPi, Ruptela, Tesla, etc.) into standardized VSS (Vehicle Signal Specification) format
  2. Cloud Event Processing: Transforming raw messages into CloudEvents for the DIMO data pipeline
  3. Modular Architecture: A plugin-like system where each hardware provider has its own conversion module
  4. Code Generation: Automatic generation of conversion functions from YAML definitions

Signal Definitions

Signal definitions can be found in the spec package. This package is the source of truth for signals used for DIMO Data.

Migrations

To create a new migration, run the following command:

Make migration name=<migration_name>

This will create a new migration file the given name in the migrations directory. this creation should be used over the goose binary to ensure expected behavior of embedded migrations.

Repo structure

Codegen

The codegen directory contains the code generation tool for creating models from vspec CSV schemas. The tool is a standalone application that can be run from the command line.

Example usage:

go run github.com/DIMO-Network/model-garage/cmd/codegen -generators=custom -custom.output-file=./pkg/vss/vehicle-structs.go -custom.template-file=./internal/generator/vehicle.tmpl -custom.format=true
codegen is a tool to generate code for the model-garage project.
Available generators:
        - custom: Runs a given golang template with pkg/schema.TemplateData data.
        - convert: Generates conversion functions for converting between raw data into signals.Usage:
  -convert.copy-comments
        Copy through comments on conversion functions. Default is false.
  -convert.output-file string
        Output file for the conversion functions. (default "convert-funcs_gen.go")
  -convert.package string
        Name of the package to generate the conversion functions. If empty, the base model name is used.
  -custom.format
        Format the generated file with goimports.
  -custom.output-file string
        Path of the generate gql file (default "custom.txt")
  -custom.template-file string
        Path to the template file. Which is executed with codegen.TemplateData data.
  -definitions string
        Path to the definitions file if empty, the definitions will be used
  -generators string
        Comma separated list of generators to run. Options: convert, custom. (default "all")
  -spec string
        Path to the vspec CSV file if empty, the embedded vspec will be used
Generation Info

The codegen tool is typically used to create files based on arbitrary signal definitions. The tool reads the signal definitions and custom templates and executes the templates to create the output files.

Custom Generator

The custom generator takes in a custom template file and output file. The template file is a Go template that is executed with the signal definitions. The data struct passed into the template is defined by pkg/schema/signal.go.(TemplateData) see vehicle.tmpl for an example template.

Convert Generator

The convert generator is a built-in generator that creates conversion functions for each signal. The conversion functions are created based on the signal definitions. The conversion functions are meant to be overridden with custom logic as needed. When generation is re-run, the conversion functions are not overwritten.

Getting Started

For comprehensive documentation on how to work with Model Garage, see the Developer Guide.

Quick links:

Common Tasks

Adding a New Signal
  1. Update pkg/schema/spec/default-definitions.yaml to add your signal
  2. Update module-specific definitions (e.g., pkg/ruptela/schema/ruptela_definitions.yaml)
  3. Run make generate to regenerate conversion code
  4. Implement custom conversion logic if needed
  5. Update tests

See the Adding New Signals guide for detailed steps.

Propagating Changes

After releasing changes to model-garage, update the following services:

  1. dis - Signal conversion and storage
  2. telemetry-api - API access to signals
  3. vehicle-triggers-api - Webhook support for signals
Adding Custom VSS Signals

When the COVESA standard doesn't have a signal you need:

  1. Go to the DIMO VSS repository
  2. Add your signal to overlays/DIMO/dimo.vspec
  3. Follow the process documented in that repository

Directories

Path Synopsis
cmd
clickhouse-container command
Package main is a binary for creating a test ClickHouse container.
Package main is a binary for creating a test ClickHouse container.
codegen command
Package main provides the entrypoint for the code generation tool.
Package main provides the entrypoint for the code generation tool.
migrate command
Package main is the entry point to run goose CLI with model-garage migrations.
Package main is the entry point to run goose CLI with model-garage migrations.
internal
generator/convert
Package convert provides a function to generate conversion functions for a vehicle struct.
Package convert provides a function to generate conversion functions for a vehicle struct.
generator/custom
Package custom provides the custom generation functionality that uses a provide template to generate a file.
Package custom provides the custom generation functionality that uses a provide template to generate a file.
pkg
autopi
Package autopi holds decoding functions for Ruptela status payloads.
Package autopi holds decoding functions for Ruptela status payloads.
cloudevent
Package cloudevent provides types for working with CloudEvents.
Package cloudevent provides types for working with CloudEvents.
codegen
Package codegen provides the code generation functionality for converting VSPEC signals to Go structs and ClickHouse tables.
Package codegen provides the code generation functionality for converting VSPEC signals to Go structs and ClickHouse tables.
compass
Code generated by github.com/DIMO-Network/model-garage.
Code generated by github.com/DIMO-Network/model-garage.
convert
Package convert provides common functions for handling signal conversion.
Package convert provides common functions for handling signal conversion.
defaultmodule
Package defaultmodule provides a default implementation for decoding DIMO data.
Package defaultmodule provides a default implementation for decoding DIMO data.
hashdog
Package hashdog holds decoding functions for hashdog (Macaron) status payloads.
Package hashdog holds decoding functions for hashdog (Macaron) status payloads.
migrations
Package migrations provides the functionality to run goose migrations on a clickhouse dimo database.
Package migrations provides the functionality to run goose migrations on a clickhouse dimo database.
modules
Package modules provides a way to load various code modules from data providers.
Package modules provides a way to load various code modules from data providers.
nativestatus
Package nativestatus provides a function to generate conversion functions for a vehicle struct.
Package nativestatus provides a function to generate conversion functions for a vehicle struct.
nativestatus/schema
Package schema information for converting native dimo status objects
Package schema information for converting native dimo status objects
runner
Package runner is a package that provides a programmatic interface to the code generation tool.
Package runner is a package that provides a programmatic interface to the code generation tool.
ruptela
Code generated by github.com/DIMO-Network/model-garage.
Code generated by github.com/DIMO-Network/model-garage.
ruptela/codegen command
ruptela/schema
Package schema contains the embedded schema files for the ruptela devices
Package schema contains the embedded schema files for the ruptela devices
schema
Package schema contains the types and functions for generating the schema from the spec and definition files.
Package schema contains the types and functions for generating the schema from the spec and definition files.
tesla
Package tesla handles incoming Tesla messages, both from polling the Fleet API and streaming from Fleet Telemetry.
Package tesla handles incoming Tesla messages, both from polling the Fleet API and streaming from Fleet Telemetry.
tesla/api
Code generated by github.com/DIMO-Network/model-garage.
Code generated by github.com/DIMO-Network/model-garage.
tesla/telemetry
Package telemetry converts batches of Tesla protobuf Payloads into VSS signals.
Package telemetry converts batches of Tesla protobuf Payloads into VSS signals.
tesla/telemetry/codegen command
Package main contains the code generation command for transforming a definitions file into code that executes a conversion from Tesla Fleet Telemetry protobufs into VSS signals.
Package main contains the code generation command for transforming a definitions file into code that executes a conversion from Tesla Fleet Telemetry protobufs into VSS signals.
tesla/telemetry/parse
Package parse contains functions for parsing typed Tesla values out of strings.
Package parse contains functions for parsing typed Tesla values out of strings.
tesla/telemetry/schema
Package schema merely embeds the definitions file for conversions from Tesla Fleet Telemetry to VSS signals.
Package schema merely embeds the definitions file for conversions from Tesla Fleet Telemetry to VSS signals.
tesla/telemetry/unit
Package unit converts between commonly used units of measure for vehicle signals.
Package unit converts between commonly used units of measure for vehicle signals.
twilio
Package twilio provides structures and methods to interact with Twilio data types.
Package twilio provides structures and methods to interact with Twilio data types.
version
Package version provides the version of the application.
Package version provides the version of the application.
vss
Package vss holds the data structures and functions for working with events from DIMOs VSS schema.
Package vss holds the data structures and functions for working with events from DIMOs VSS schema.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL