# dspl1236/vagflasher architecture

> Architecture diagram of the GitHub repository dspl1236/vagflasher, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dspl1236/vagflasher
- Repository: https://github.com/dspl1236/vagflasher

## Overview

VAGFlasher is a local command-line tool for reading and flashing VAG ECU/TCU memory. The main workflow takes a .bin file, selects an ECU platform and vehicle interface, then runs a UDS programming sequence; reads return ECU data to an output file. ME17.5 is the implemented platform, while MED9 and ME7 support is described as planned. The graph follows the CLI, platform, protocol and transport code; J2534 transaction support is currently incomplete, and the README’s broader platform claims are not wired up in the sampled implementation.

Main entry points: [`vagflasher/cli.py`](https://github.com/dspl1236/vagflasher/blob/main/vagflasher/cli.py) (CLI), [`vagflasher/platforms/me17.py`](https://github.com/dspl1236/vagflasher/blob/main/vagflasher/platforms/me17.py) (ME17 platform), [`vagflasher/interfaces/funkbridge.py`](https://github.com/dspl1236/vagflasher/blob/main/vagflasher/interfaces/funkbridge.py) (FunkBridge), [`vagflasher/interfaces/j2534.py`](https://github.com/dspl1236/vagflasher/blob/main/vagflasher/interfaces/j2534.py) (J2534 PassThru)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_commands["CLI commands"]
  node_cli["CLI<br/>[cli.py]"]
  node_device_listing["J2534 discovery<br/>[cli.py]"]
end

subgraph group_platform["ECU workflow"]
  node_me17["ME17 platform<br/>[me17.py]"]
  node_session_security["Session and access<br/>[me17.py]"]
  node_flash_transfer["Erase and transfer<br/>[me17.py]"]
  node_ecu_read["ECU read<br/>[me17.py]"]
end

subgraph group_protocol["Diagnostic protocols"]
  node_uds["UDS services<br/>[uds.py]"]
  node_sa2["SA2 keys<br/>[sa2.py]"]
end

subgraph group_transport["Vehicle interfaces"]
  node_base_interface["Interface contract<br/>[base.py]"]
  node_funkbridge["FunkBridge<br/>[funkbridge.py]"]
  node_j2534["J2534 PassThru<br/>[j2534.py]"]
end

node_user(("Engineer"))
node_flash_input["Firmware .bin"]
node_read_output["Dump .bin"]
node_ecu{{"VAG ECU"}}
node_funk_service{{"FunkBridge dongle"}}
node_j2534_device{{"J2534 device"}}

node_user -->|"runs commands"| node_cli
node_flash_input -->|"supplies firmware"| node_cli
node_cli -->|"selects platform"| node_me17
node_cli -->|"selects interface"| node_funkbridge
node_cli -->|"selects interface"| node_j2534
node_cli -->|"lists devices"| node_device_listing
node_device_listing -->|"queries registry"| node_j2534
node_cli -->|"provides flash blocks"| node_flash_transfer
node_me17 -->|"starts access"| node_session_security
node_me17 -->|"orchestrates flash"| node_flash_transfer
node_me17 -->|"orchestrates read"| node_ecu_read
node_session_security -->|"builds and parses requests"| node_uds
node_session_security -->|"resolves seed"| node_sa2
node_flash_transfer -->|"builds and parses requests"| node_uds
node_ecu_read -->|"builds and parses requests"| node_uds
node_me17 -->|"transacts requests"| node_base_interface
node_base_interface -->|"implemented by"| node_funkbridge
node_base_interface -.->|"implemented by"| node_j2534
node_funkbridge -->|"sends UDS over WebSocket"| node_funk_service
node_funk_service -->|"returns UDS response"| node_funkbridge
node_j2534 -.->|"opens DLL connection"| node_j2534_device
node_funkbridge -->|"transports diagnostics"| node_ecu
node_j2534 -.->|"planned transactions"| node_ecu
node_ecu_read -->|"returns dump bytes"| node_cli
node_cli -->|"writes dump"| node_read_output

click node_cli "https://github.com/dspl1236/vagflasher/blob/main/vagflasher/cli.py"
click node_device_listing "https://github.com/dspl1236/vagflasher/blob/main/vagflasher/cli.py"
click node_me17 "https://github.com/dspl1236/vagflasher/blob/main/vagflasher/platforms/me17.py"
click node_session_security "https://github.com/dspl1236/vagflasher/blob/main/vagflasher/platforms/me17.py"
click node_flash_transfer "https://github.com/dspl1236/vagflasher/blob/main/vagflasher/platforms/me17.py"
click node_ecu_read "https://github.com/dspl1236/vagflasher/blob/main/vagflasher/platforms/me17.py"
click node_uds "https://github.com/dspl1236/vagflasher/blob/main/vagflasher/protocols/uds.py"
click node_sa2 "https://github.com/dspl1236/vagflasher/blob/main/vagflasher/protocols/sa2.py"
click node_base_interface "https://github.com/dspl1236/vagflasher/blob/main/vagflasher/interfaces/base.py"
click node_funkbridge "https://github.com/dspl1236/vagflasher/blob/main/vagflasher/interfaces/funkbridge.py"
click node_j2534 "https://github.com/dspl1236/vagflasher/blob/main/vagflasher/interfaces/j2534.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_device_listing toneBlue
class node_me17,node_session_security,node_flash_transfer,node_ecu_read toneAmber
class node_uds,node_sa2 toneMint
class node_base_interface,node_funkbridge,node_j2534 toneRose
class node_user,node_flash_input,node_read_output,node_ecu,node_funk_service,node_j2534_device toneIndigo
```

## Components

### CLI commands

- [CLI](https://github.com/dspl1236/vagflasher/blob/main/vagflasher/cli.py): `vagflasher/cli.py`
- [J2534 discovery](https://github.com/dspl1236/vagflasher/blob/main/vagflasher/cli.py): `vagflasher/cli.py`

### ECU workflow

- [ME17 platform](https://github.com/dspl1236/vagflasher/blob/main/vagflasher/platforms/me17.py): `vagflasher/platforms/me17.py`
- [Session and access](https://github.com/dspl1236/vagflasher/blob/main/vagflasher/platforms/me17.py): `vagflasher/platforms/me17.py`
- [Erase and transfer](https://github.com/dspl1236/vagflasher/blob/main/vagflasher/platforms/me17.py): `vagflasher/platforms/me17.py`
- [ECU read](https://github.com/dspl1236/vagflasher/blob/main/vagflasher/platforms/me17.py): `vagflasher/platforms/me17.py`

### Diagnostic protocols

- [UDS services](https://github.com/dspl1236/vagflasher/blob/main/vagflasher/protocols/uds.py): `vagflasher/protocols/uds.py`
- [SA2 keys](https://github.com/dspl1236/vagflasher/blob/main/vagflasher/protocols/sa2.py): `vagflasher/protocols/sa2.py`

### Vehicle interfaces

- [Interface contract](https://github.com/dspl1236/vagflasher/blob/main/vagflasher/interfaces/base.py): `vagflasher/interfaces/base.py`
- [FunkBridge](https://github.com/dspl1236/vagflasher/blob/main/vagflasher/interfaces/funkbridge.py): `vagflasher/interfaces/funkbridge.py`
- [J2534 PassThru](https://github.com/dspl1236/vagflasher/blob/main/vagflasher/interfaces/j2534.py): `vagflasher/interfaces/j2534.py`

### Other components

- **Engineer**
- **Firmware .bin**
- **Dump .bin**
- **VAG ECU**
- **FunkBridge dongle**
- **J2534 device**

## Connections

- Engineer → CLI: runs commands
- Firmware .bin → CLI: supplies firmware
- CLI → ME17 platform: selects platform
- CLI → FunkBridge: selects interface
- CLI → J2534 PassThru: selects interface
- CLI → J2534 discovery: lists devices
- J2534 discovery → J2534 PassThru: queries registry
- CLI → Erase and transfer: provides flash blocks
- ME17 platform → Session and access: starts access
- ME17 platform → Erase and transfer: orchestrates flash
- ME17 platform → ECU read: orchestrates read
- Session and access → UDS services: builds and parses requests
- Session and access → SA2 keys: resolves seed
- Erase and transfer → UDS services: builds and parses requests
- ECU read → UDS services: builds and parses requests
- ME17 platform → Interface contract: transacts requests
- Interface contract → FunkBridge: implemented by
- Interface contract → J2534 PassThru: implemented by
- FunkBridge → FunkBridge dongle: sends UDS over WebSocket
- FunkBridge dongle → FunkBridge: returns UDS response
- J2534 PassThru → J2534 device: opens DLL connection
- FunkBridge → VAG ECU: transports diagnostics
- J2534 PassThru → VAG ECU: planned transactions
- ECU read → CLI: returns dump bytes
- CLI → Dump .bin: writes dump
