# iunreallx/redrive architecture

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

- Interactive diagram: https://gitdiagram.com/iunreallx/redrive
- Repository: https://github.com/iunreallx/redrive

## Overview

ReDrive is a Flutter OBD2 application: a driver selects an adapter, connects to the vehicle, and uses live telemetry and diagnostics through a dashboard. The README documents Bluetooth, Wi-Fi, and USB support, automatic recovery, fault-code decoding/clearing, and a demo mode. Its repository structure identifies a transport-independent ELM327/PID pipeline and separate UI, provider, and transport layers. Dart implementation excerpts were not provided, so internal call relationships are left unasserted; dashed edges mark plausible but unverified integration.

Main entry points: [`lib/services/connection/obd_connection_switcher.dart`](https://github.com/iunreallx/redrive/blob/main/lib/services/connection/obd_connection_switcher.dart) (Connection switcher), [`lib/obd/elm/elm_client.dart`](https://github.com/iunreallx/redrive/blob/main/lib/obd/elm/elm_client.dart) (ELM327 client), [`lib/obd/polling/polling_controller.dart`](https://github.com/iunreallx/redrive/blob/main/lib/obd/polling/polling_controller.dart) (PID polling), [`lib/obd/source/live_obd_source.dart`](https://github.com/iunreallx/redrive/blob/main/lib/obd/source/live_obd_source.dart) (Telemetry source)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["App interface"]
  node_navigation["App navigation<br/>[root_screen.dart]"]
  node_connection_ui["Connection selection"]
  node_dashboard["Vehicle dashboard<br/>[car_screen.dart]"]
  node_home["Home screen<br/>[home_screen.dart]"]
end

subgraph group_transport["Adapter connections"]
  node_bluetooth["Bluetooth transport"]
  node_wifi["Wi-Fi transport"]
  node_switcher["Connection switcher"]
end

subgraph group_obd["OBD processing"]
  node_obd_connection["OBD connection API"]
  node_session["OBD session<br/>[obd_session.dart]"]
  node_elm["ELM327 client<br/>[elm_client.dart]"]
  node_polling["PID polling"]
  node_pid_registry["PID definitions<br/>[pid_registry.dart]"]
  node_telemetry["Telemetry source"]
  node_data_model["Telemetry model<br/>[obd_data.dart]"]
end

subgraph group_features["Vehicle features"]
  node_dtc["Fault-code decoder<br/>[dtc_decoder.dart]"]
  node_demo["Demo data"]
end

subgraph group_state["Application state"]
  node_provider["OBD app state<br/>[obd_provider.dart]"]
  node_bluetooth_provider["Bluetooth state"]
end

node_driver(("Driver"))

node_driver -->|"selects adapter"| node_connection_ui
node_driver -->|"views vehicle data"| node_dashboard
node_connection_ui -.->|"initiates connection"| node_switcher
node_switcher -.->|"selects transport"| node_bluetooth
node_switcher -.->|"selects transport"| node_wifi
node_bluetooth -.->|"implements connection"| node_obd_connection
node_wifi -.->|"implements connection"| node_obd_connection
node_obd_connection -.->|"carries session traffic"| node_session
node_session -.->|"initializes client"| node_elm
node_elm -.->|"serves PID requests"| node_polling
node_polling -.->|"uses PID definitions"| node_pid_registry
node_polling -.->|"supplies live readings"| node_telemetry
node_telemetry -.->|"produces telemetry"| node_data_model
node_telemetry -.->|"feeds live data"| node_dashboard
node_elm -.->|"supports diagnostics"| node_dtc
node_driver -->|"reads or clears codes"| node_dtc
node_demo -->|"offers emulator mode"| node_driver
node_provider -.->|"holds app state"| node_dashboard
node_bluetooth_provider -.->|"supports device selection"| node_connection_ui

click node_navigation "https://github.com/iunreallx/redrive/blob/main/lib/screens/root_screen.dart"
click node_connection_ui "https://github.com/iunreallx/redrive/blob/main/lib/screens/connection_screen.dart"
click node_dashboard "https://github.com/iunreallx/redrive/blob/main/lib/screens/car_screen.dart"
click node_home "https://github.com/iunreallx/redrive/blob/main/lib/screens/home_screen.dart"
click node_bluetooth "https://github.com/iunreallx/redrive/blob/main/lib/services/bluetooth/connection/bluetooth_obd_connection.dart"
click node_wifi "https://github.com/iunreallx/redrive/blob/main/lib/services/wifi/connection/wifi_obd_connection.dart"
click node_switcher "https://github.com/iunreallx/redrive/blob/main/lib/services/connection/obd_connection_switcher.dart"
click node_obd_connection "https://github.com/iunreallx/redrive/blob/main/lib/obd/connection/obd_connection.dart"
click node_session "https://github.com/iunreallx/redrive/blob/main/lib/obd/session/obd_session.dart"
click node_elm "https://github.com/iunreallx/redrive/blob/main/lib/obd/elm/elm_client.dart"
click node_polling "https://github.com/iunreallx/redrive/blob/main/lib/obd/polling/polling_controller.dart"
click node_pid_registry "https://github.com/iunreallx/redrive/blob/main/lib/obd/pid/pid_registry.dart"
click node_telemetry "https://github.com/iunreallx/redrive/blob/main/lib/obd/source/live_obd_source.dart"
click node_data_model "https://github.com/iunreallx/redrive/blob/main/lib/obd/models/obd_data.dart"
click node_dtc "https://github.com/iunreallx/redrive/blob/main/lib/obd/diagnostics/dtc_decoder.dart"
click node_demo "https://github.com/iunreallx/redrive/blob/main/lib/obd/demo/demo_data_generator.dart"
click node_provider "https://github.com/iunreallx/redrive/blob/main/lib/providers/obd_provider.dart"
click node_bluetooth_provider "https://github.com/iunreallx/redrive/blob/main/lib/providers/bluetooth_provider.dart"

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_navigation,node_connection_ui,node_dashboard,node_home toneBlue
class node_bluetooth,node_wifi,node_switcher toneAmber
class node_obd_connection,node_session,node_elm,node_polling,node_pid_registry,node_telemetry,node_data_model toneMint
class node_dtc,node_demo toneRose
class node_provider,node_bluetooth_provider,node_driver toneIndigo
```

## Components

### App interface

- [App navigation](https://github.com/iunreallx/redrive/blob/main/lib/screens/root_screen.dart): `lib/screens/root_screen.dart`
- [Connection selection](https://github.com/iunreallx/redrive/blob/main/lib/screens/connection_screen.dart): `lib/screens/connection_screen.dart`
- [Vehicle dashboard](https://github.com/iunreallx/redrive/blob/main/lib/screens/car_screen.dart): `lib/screens/car_screen.dart`
- [Home screen](https://github.com/iunreallx/redrive/blob/main/lib/screens/home_screen.dart): `lib/screens/home_screen.dart`

### Adapter connections

- [Bluetooth transport](https://github.com/iunreallx/redrive/blob/main/lib/services/bluetooth/connection/bluetooth_obd_connection.dart): `lib/services/bluetooth/connection/bluetooth_obd_connection.dart`
- [Wi-Fi transport](https://github.com/iunreallx/redrive/blob/main/lib/services/wifi/connection/wifi_obd_connection.dart): `lib/services/wifi/connection/wifi_obd_connection.dart`
- [Connection switcher](https://github.com/iunreallx/redrive/blob/main/lib/services/connection/obd_connection_switcher.dart): `lib/services/connection/obd_connection_switcher.dart`

### OBD processing

- [OBD connection API](https://github.com/iunreallx/redrive/blob/main/lib/obd/connection/obd_connection.dart): `lib/obd/connection/obd_connection.dart`
- [OBD session](https://github.com/iunreallx/redrive/blob/main/lib/obd/session/obd_session.dart): `lib/obd/session/obd_session.dart`
- [ELM327 client](https://github.com/iunreallx/redrive/blob/main/lib/obd/elm/elm_client.dart): `lib/obd/elm/elm_client.dart`
- [PID polling](https://github.com/iunreallx/redrive/blob/main/lib/obd/polling/polling_controller.dart): `lib/obd/polling/polling_controller.dart`
- [PID definitions](https://github.com/iunreallx/redrive/blob/main/lib/obd/pid/pid_registry.dart): `lib/obd/pid/pid_registry.dart`
- [Telemetry source](https://github.com/iunreallx/redrive/blob/main/lib/obd/source/live_obd_source.dart): `lib/obd/source/live_obd_source.dart`
- [Telemetry model](https://github.com/iunreallx/redrive/blob/main/lib/obd/models/obd_data.dart): `lib/obd/models/obd_data.dart`

### Vehicle features

- [Fault-code decoder](https://github.com/iunreallx/redrive/blob/main/lib/obd/diagnostics/dtc_decoder.dart): `lib/obd/diagnostics/dtc_decoder.dart`
- [Demo data](https://github.com/iunreallx/redrive/blob/main/lib/obd/demo/demo_data_generator.dart): `lib/obd/demo/demo_data_generator.dart`

### Application state

- [OBD app state](https://github.com/iunreallx/redrive/blob/main/lib/providers/obd_provider.dart): `lib/providers/obd_provider.dart`
- [Bluetooth state](https://github.com/iunreallx/redrive/blob/main/lib/providers/bluetooth_provider.dart): `lib/providers/bluetooth_provider.dart`

### Other components

- **Driver**

## Connections

- Driver → Connection selection: selects adapter (evidence: `README.md`)
- Driver → Vehicle dashboard: views vehicle data (evidence: `README.md`)
- Connection selection → Connection switcher: initiates connection
- Connection switcher → Bluetooth transport: selects transport
- Connection switcher → Wi-Fi transport: selects transport
- Bluetooth transport → OBD connection API: implements connection
- Wi-Fi transport → OBD connection API: implements connection
- OBD connection API → OBD session: carries session traffic
- OBD session → ELM327 client: initializes client
- ELM327 client → PID polling: serves PID requests
- PID polling → PID definitions: uses PID definitions
- PID polling → Telemetry source: supplies live readings
- Telemetry source → Telemetry model: produces telemetry
- Telemetry source → Vehicle dashboard: feeds live data
- ELM327 client → Fault-code decoder: supports diagnostics
- Driver → Fault-code decoder: reads or clears codes (evidence: `README.md`)
- Demo data → Driver: offers emulator mode (evidence: `README.md`)
- OBD app state → Vehicle dashboard: holds app state
- Bluetooth state → Connection selection: supports device selection
