# fetzu/teslamate-abrp architecture

> Architecture diagram of the GitHub repository fetzu/teslamate-abrp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fetzu/teslamate-abrp
- Repository: https://github.com/fetzu/teslamate-abrp

## Overview

##### Main Components

a) External Systems (represented as external rectangles):
- TeslaMate System
- ABRP (A Better Route Planner) System

b) Core Components (represented as internal rectangles):
- MQTT Broker (Mosquitto)
- TeslaMate-ABRP Bridge (the main application)

- TeslaMate → MQTT Broker (vehicle data publication)
- MQTT Broker → TeslaMate-ABRP Bridge (subscription to vehicle data)
- TeslaMate-ABRP Bridge → ABRP API (data forwarding)

**[TeslaMate] → [MQTT Broker] → [TeslaMate-ABRP Bridge] → [ABRP API]**

##### Component Details

For each component, include these specific details:

a) MQTT Broker:
- Port (1883 default, 8883 for TLS)
- Authentication capabilities
- TLS support indicator

b) TeslaMate-ABRP Bridge:
- Configuration inputs (environment variables)
- Status reporting capability
- Model detection logic

##### Important Flows to Highlight

- Authentication flows (MQTT credentials, ABRP token)
- Vehicle data flow
- Status reporting flow (optional status topic)
- Configuration flow

##### Additional Elements

A configuration section showing:
- Environment variables
- Docker secrets support
- Required vs optional parameters

##### The unidirectional flow of data from TeslaMate to ABRP

Use standardized symbols:
- Services: Rectangles
- Security elements: Lock symbols

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef external fill:#b3d1ff,stroke:#333
    classDef infrastructure fill:#90EE90,stroke:#333
    classDef core fill:#FFB366,stroke:#333
    classDef config fill:#E6E6E6,stroke:#333
    classDef deployment fill:#DDA0DD,stroke:#333

    %% External Systems
    TM[TeslaMate]:::external
    ABRP[A Better Route Planner]:::external

    %% Infrastructure
    subgraph Broker["MQTT Infrastructure"]
        MQTT[("MQTT Broker\n(Mosquitto)\nPorts: 1883/8883")]:::infrastructure
    end

    %% Core Application
    subgraph Bridge["TeslaMate-ABRP Bridge"]
        MainApp["Bridge Application"]:::core
        Config["Configuration\n- Environment Variables\n- Docker Secrets"]:::config
    end

    %% Deployment Components
    subgraph Deployment["Deployment Pipeline"]
        Docker["Docker Container"]:::deployment
        Alpha["Alpha Build"]:::deployment
        Beta["Beta Build"]:::deployment
        Prod["Production Build"]:::deployment
    end

    %% Relationships
    TM -->|Vehicle Data| MQTT
    MQTT -->|Subscribe| MainApp
    MainApp -->|Forward Data| ABRP
    Config -->|Configure| MainApp
    MainApp -->|Build| Docker
    Docker -->|Deploy| Alpha
    Docker -->|Deploy| Beta
    Docker -->|Deploy| Prod

    %% Click Events
    click MainApp "https://github.com/fetzu/teslamate-abrp/blob/main/teslamate_mqtt2abrp.py"
    click Docker "https://github.com/fetzu/teslamate-abrp/tree/main/Dockerfile"
    click Alpha "https://github.com/fetzu/teslamate-abrp/blob/main/.github/workflows/build_alpha.yml"
    click Beta "https://github.com/fetzu/teslamate-abrp/blob/main/.github/workflows/build_beta.yml"
    click Prod "https://github.com/fetzu/teslamate-abrp/blob/main/.github/workflows/build_latest.yml"

    %% Legend
    subgraph Legend
        E["External Systems"]:::external
        I["Infrastructure"]:::infrastructure
        C["Core Components"]:::core
        CF["Configuration"]:::config
        D["Deployment"]:::deployment
    end
```
