# ahansardar/saferide architecture

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

- Interactive diagram: https://gitdiagram.com/ahansardar/saferide
- Repository: https://github.com/ahansardar/saferide

## Overview

SafeRide is a Windows dashboard for configuring and operating a two-Arduino safety prototype. The main workflow is: select connected boards, configure and validate them, generate matching firmware, compile and upload it, then relay helmet telemetry to the vehicle and display live safety status. The vehicle firmware makes the final relay decision. The README also documents optional USB-driver assistance, session-log export, and verified automatic updates. Some connections are supported by README statements and the app’s indexed imports; unsampled implementation details are not inferred.

Main entry points: [`app.py`](https://github.com/ahansardar/saferide/blob/main/app.py) (Dashboard), [`firmware_builder.py`](https://github.com/ahansardar/saferide/blob/main/firmware_builder.py) (Firmware generation), [`uploader.py`](https://github.com/ahansardar/saferide/blob/main/uploader.py) (Compile and upload), [`updater.py`](https://github.com/ahansardar/saferide/blob/main/updater.py) (Update manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operation["Dashboard operation"]
  node_dashboard["Dashboard<br/>[app.py]"]
  node_serial["USB serial bridge<br/>[app.py]"]
  node_telemetry["Packet parsing<br/>[core.py]"]
  node_live["Live safety display<br/>[app.py]"]
end

subgraph group_firmware["Firmware and boards"]
  node_builder["Firmware generation"]
  node_uploader["Compile and upload<br/>[uploader.py]"]
  node_helmetfw["Helmet firmware<br/>[helmet.ino]"]
  node_vehiclefw["Vehicle firmware<br/>[vehicle.ino]"]
end

subgraph group_support["Configuration and support"]
  node_sessionlog[("Session log<br/>[session_log.py]")]
  node_configui["Configuration wizard<br/>[app.py]"]
  node_config["Config validation<br/>[device_config.py]"]
  node_configstore[("Saved settings<br/>[device_config.py]")]
  node_driverui["USB driver assistant<br/>[app.py]"]
  node_drivers["Driver support<br/>[driver_support.py]"]
  node_driverassets["Driver package<br/>[CH341SER.EXE]"]
end

subgraph group_updates["Release updates"]
  node_updater["Update manager<br/>[updater.py]"]
  node_version["Release metadata<br/>[version.py]"]
end

node_rider(("Operator"))
node_arduino["Arduino CLI"]
node_boards["Arduino boards"]
node_release["GitHub Releases"]

node_rider -->|"operates"| node_dashboard
node_dashboard -->|"configures"| node_configui
node_configui -->|"validates"| node_config
node_config -->|"saves settings"| node_configstore
node_dashboard -->|"generates firmware"| node_builder
node_builder -->|"uses settings"| node_config
node_dashboard -->|"uploads sketches"| node_uploader
node_uploader -->|"runs commands"| node_arduino
node_uploader -->|"flashes"| node_boards
node_builder -->|"renders"| node_helmetfw
node_builder -->|"renders"| node_vehiclefw
node_rider -->|"connects by USB"| node_boards
node_dashboard -->|"starts link"| node_serial
node_serial -->|"parses packets"| node_telemetry
node_serial -->|"relays telemetry"| node_vehiclefw
node_helmetfw -->|"sends telemetry"| node_serial
node_vehiclefw -->|"decides relay"| node_boards
node_telemetry -->|"supplies state"| node_live
node_dashboard -->|"records activity"| node_sessionlog
node_rider -->|"requests drivers"| node_driverui
node_driverui -->|"launches install"| node_drivers
node_drivers -->|"verifies installer"| node_driverassets
node_dashboard -->|"checks and downloads"| node_updater
node_updater -->|"reads release settings"| node_version
node_updater -->|"fetches assets"| node_release

click node_dashboard "https://github.com/ahansardar/saferide/blob/main/app.py"
click node_serial "https://github.com/ahansardar/saferide/blob/main/app.py"
click node_telemetry "https://github.com/ahansardar/saferide/blob/main/core.py"
click node_live "https://github.com/ahansardar/saferide/blob/main/app.py"
click node_sessionlog "https://github.com/ahansardar/saferide/blob/main/session_log.py"
click node_configui "https://github.com/ahansardar/saferide/blob/main/app.py"
click node_config "https://github.com/ahansardar/saferide/blob/main/device_config.py"
click node_configstore "https://github.com/ahansardar/saferide/blob/main/device_config.py"
click node_builder "https://github.com/ahansardar/saferide/blob/main/firmware_builder.py"
click node_uploader "https://github.com/ahansardar/saferide/blob/main/uploader.py"
click node_helmetfw "https://github.com/ahansardar/saferide/blob/main/firmware/helmet/helmet.ino"
click node_vehiclefw "https://github.com/ahansardar/saferide/blob/main/firmware/vehicle/vehicle.ino"
click node_driverui "https://github.com/ahansardar/saferide/blob/main/app.py"
click node_drivers "https://github.com/ahansardar/saferide/blob/main/driver_support.py"
click node_driverassets "https://github.com/ahansardar/saferide/blob/main/drivers/CH341SER.EXE"
click node_updater "https://github.com/ahansardar/saferide/blob/main/updater.py"
click node_version "https://github.com/ahansardar/saferide/blob/main/version.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_dashboard,node_serial,node_telemetry,node_live toneBlue
class node_builder,node_uploader,node_helmetfw,node_vehiclefw toneAmber
class node_sessionlog,node_configui,node_config,node_configstore,node_driverui,node_drivers,node_driverassets toneMint
class node_updater,node_version toneRose
class node_rider,node_arduino,node_boards,node_release toneIndigo
```

## Components

### Dashboard operation

- [Dashboard](https://github.com/ahansardar/saferide/blob/main/app.py): `app.py`
- [USB serial bridge](https://github.com/ahansardar/saferide/blob/main/app.py): `app.py`
- [Packet parsing](https://github.com/ahansardar/saferide/blob/main/core.py): `core.py`
- [Live safety display](https://github.com/ahansardar/saferide/blob/main/app.py): `app.py`

### Firmware and boards

- [Firmware generation](https://github.com/ahansardar/saferide/blob/main/firmware_builder.py): `firmware_builder.py`
- [Compile and upload](https://github.com/ahansardar/saferide/blob/main/uploader.py): `uploader.py`
- [Helmet firmware](https://github.com/ahansardar/saferide/blob/main/firmware/helmet/helmet.ino): `firmware/helmet/helmet.ino`
- [Vehicle firmware](https://github.com/ahansardar/saferide/blob/main/firmware/vehicle/vehicle.ino): `firmware/vehicle/vehicle.ino`

### Configuration and support

- [Session log](https://github.com/ahansardar/saferide/blob/main/session_log.py): `session_log.py`
- [Configuration wizard](https://github.com/ahansardar/saferide/blob/main/app.py): `app.py`
- [Config validation](https://github.com/ahansardar/saferide/blob/main/device_config.py): `device_config.py`
- [Saved settings](https://github.com/ahansardar/saferide/blob/main/device_config.py): `device_config.py`
- [USB driver assistant](https://github.com/ahansardar/saferide/blob/main/app.py): `app.py`
- [Driver support](https://github.com/ahansardar/saferide/blob/main/driver_support.py): `driver_support.py`
- [Driver package](https://github.com/ahansardar/saferide/blob/main/drivers/CH341SER.EXE): `drivers/CH341SER.EXE`

### Release updates

- [Update manager](https://github.com/ahansardar/saferide/blob/main/updater.py): `updater.py`
- [Release metadata](https://github.com/ahansardar/saferide/blob/main/version.py): `version.py`

### Other components

- **Operator**
- **Arduino CLI**
- **Arduino boards**
- **GitHub Releases**

## Connections

- Operator → Dashboard: operates (evidence: `README.md`)
- Dashboard → Configuration wizard: configures (evidence: `README.md`)
- Configuration wizard → Config validation: validates (evidence: `app.py`)
- Config validation → Saved settings: saves settings (evidence: `device_config.py`)
- Dashboard → Firmware generation: generates firmware (evidence: `app.py`)
- Firmware generation → Config validation: uses settings (evidence: `firmware_builder.py`)
- Dashboard → Compile and upload: uploads sketches (evidence: `README.md`)
- Compile and upload → Arduino CLI: runs commands (evidence: `uploader.py`)
- Compile and upload → Arduino boards: flashes (evidence: `README.md`)
- Firmware generation → Helmet firmware: renders (evidence: `firmware_builder.py`)
- Firmware generation → Vehicle firmware: renders (evidence: `firmware_builder.py`)
- Operator → Arduino boards: connects by USB (evidence: `README.md`)
- Dashboard → USB serial bridge: starts link (evidence: `README.md`)
- USB serial bridge → Packet parsing: parses packets (evidence: `app.py`)
- USB serial bridge → Vehicle firmware: relays telemetry (evidence: `README.md`)
- Helmet firmware → USB serial bridge: sends telemetry (evidence: `README.md`)
- Vehicle firmware → Arduino boards: decides relay (evidence: `README.md`)
- Packet parsing → Live safety display: supplies state (evidence: `app.py`)
- Dashboard → Session log: records activity (evidence: `README.md`)
- Operator → USB driver assistant: requests drivers (evidence: `README.md`)
- USB driver assistant → Driver support: launches install (evidence: `app.py`)
- Driver support → Driver package: verifies installer (evidence: `driver_support.py`)
- Dashboard → Update manager: checks and downloads (evidence: `app.py`)
- Update manager → Release metadata: reads release settings (evidence: `updater.py`)
- Update manager → GitHub Releases: fetches assets (evidence: `README.md`)
