# anandakrishnano-bit/smarthelmet-app architecture

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

- Interactive diagram: https://gitdiagram.com/anandakrishnano-bit/smarthelmet-app
- Repository: https://github.com/anandakrishnano-bit/smarthelmet-app

## Overview

Smart Helmet OS monitors rider safety across Arduino hardware, an Android companion, and a browser dashboard. Sensors feed the Arduino, which emits telemetry over Bluetooth; the Android app monitors that stream and handles safety decisions, location, SOS dispatch, and ride records. Separately, the Python bridge can read the Bluetooth serial stream and broadcast telemetry to the web dashboard, which presents live status and offers its own SOS controls. The README documents the product flow and major capabilities; some implementation links are omitted where excerpts do not show the caller.

Main entry points: [`app/src/main/java/com/smarthelmet/app/SmartHelmetService.java`](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/SmartHelmetService.java) (Safety Service), [`app/src/main/java/com/smarthelmet/app/MainActivity.java`](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/MainActivity.java) (Mobile Dashboard), [`app.js`](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app.js) (Dashboard Logic), [`arduino/smart_helmet.ino`](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/arduino/smart_helmet.ino) (Sensor Firmware)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_hardware["Helmet Hardware"]
  node_sensors["Helmet Sensors<br/>[smart_helmet.ino]"]
  node_firmware["Sensor Firmware<br/>[smart_helmet.ino]"]
end

subgraph group_bridge["WebSocket Bridge"]
  node_backend["Serial Bridge<br/>[backend.py]"]
  node_websocket["WebSocket Server<br/>[backend.py]"]
end

subgraph group_web["Web Dashboard"]
  node_dashboard["Dashboard Logic<br/>[app.js]"]
  node_dashboard_ui["Dashboard UI<br/>[index.html]"]
  node_browser_storage[("Browser Settings<br/>[app.js]")]
end

subgraph group_android["Android Safety App"]
  node_main["Mobile Dashboard<br/>[MainActivity.java]"]
  node_service["Safety Service"]
  node_bluetooth["Bluetooth Reader"]
  node_decision["Decision Engine"]
  node_packet["Telemetry Packet"]
  node_graph["Telemetry Graph<br/>[GraphView.java]"]
end

subgraph group_records["Settings And Journal"]
  node_settings["Settings Screen"]
  node_preferences[("App Preferences")]
  node_logger["Ride Logger"]
  node_journal["Ride Journal"]
end

node_rider(("Rider"))
node_browser_gps["Browser Location"]
node_sms["SMS Network"]
node_gps["Device Location"]

node_sensors -->|"provide readings"| node_firmware
node_firmware -->|"emit serial data"| node_backend
node_firmware -->|"emit Bluetooth data"| node_bluetooth
node_backend -->|"broadcast telemetry"| node_websocket
node_websocket -->|"send telemetry"| node_dashboard
node_dashboard -->|"updates"| node_dashboard_ui
node_dashboard -->|"reads and writes"| node_browser_storage
node_dashboard -->|"requests location"| node_browser_gps
node_rider -->|"controls SOS"| node_dashboard
node_rider -->|"uses app"| node_main
node_main -->|"starts and binds"| node_service
node_service -->|"connects through"| node_bluetooth
node_bluetooth -->|"parses readings"| node_packet
node_service -->|"uses state machine"| node_decision
node_main -->|"displays telemetry"| node_graph
node_main -->|"opens settings"| node_settings
node_settings -->|"saves settings"| node_preferences
node_service -->|"records ride events"| node_logger
node_main -->|"opens journal"| node_journal
node_journal -->|"reads log entries"| node_logger
node_service -->|"dispatches SOS"| node_sms
node_service -->|"acquires coordinates"| node_gps
node_gps -.->|"location in alert"| node_sms

click node_sensors "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/arduino/smart_helmet.ino"
click node_firmware "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/arduino/smart_helmet.ino"
click node_backend "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/backend.py"
click node_websocket "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/backend.py"
click node_dashboard "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app.js"
click node_dashboard_ui "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/index.html"
click node_browser_storage "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app.js"
click node_main "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/MainActivity.java"
click node_service "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/SmartHelmetService.java"
click node_bluetooth "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/BluetoothReader.java"
click node_decision "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/DecisionEngine.java"
click node_packet "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/TelemetryPacket.java"
click node_graph "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/GraphView.java"
click node_settings "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/SettingsActivity.java"
click node_preferences "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/SettingsActivity.java"
click node_logger "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/BlackBoxLogger.java"
click node_journal "https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/BlackBoxActivity.java"

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_sensors,node_firmware,node_browser_gps toneBlue
class node_backend,node_websocket toneAmber
class node_dashboard,node_dashboard_ui,node_browser_storage toneMint
class node_main,node_service,node_bluetooth,node_decision,node_packet,node_graph toneRose
class node_settings,node_preferences,node_logger,node_journal,node_rider,node_sms,node_gps toneIndigo
```

## Components

### Helmet Hardware

- [Helmet Sensors](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/arduino/smart_helmet.ino): `arduino/smart_helmet.ino`
- [Sensor Firmware](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/arduino/smart_helmet.ino): `arduino/smart_helmet.ino`

### WebSocket Bridge

- [Serial Bridge](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/backend.py): `backend.py`
- [WebSocket Server](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/backend.py): `backend.py`

### Web Dashboard

- [Dashboard Logic](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app.js): `app.js`
- [Dashboard UI](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/index.html): `index.html`
- [Browser Settings](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app.js): `app.js`

### Android Safety App

- [Mobile Dashboard](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/MainActivity.java): `app/src/main/java/com/smarthelmet/app/MainActivity.java`
- [Safety Service](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/SmartHelmetService.java): `app/src/main/java/com/smarthelmet/app/SmartHelmetService.java`
- [Bluetooth Reader](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/BluetoothReader.java): `app/src/main/java/com/smarthelmet/app/BluetoothReader.java`
- [Decision Engine](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/DecisionEngine.java): `app/src/main/java/com/smarthelmet/app/DecisionEngine.java`
- [Telemetry Packet](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/TelemetryPacket.java): `app/src/main/java/com/smarthelmet/app/TelemetryPacket.java`
- [Telemetry Graph](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/GraphView.java): `app/src/main/java/com/smarthelmet/app/GraphView.java`

### Settings And Journal

- [Settings Screen](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/SettingsActivity.java): `app/src/main/java/com/smarthelmet/app/SettingsActivity.java`
- [App Preferences](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/SettingsActivity.java): `app/src/main/java/com/smarthelmet/app/SettingsActivity.java`
- [Ride Logger](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/BlackBoxLogger.java): `app/src/main/java/com/smarthelmet/app/BlackBoxLogger.java`
- [Ride Journal](https://github.com/anandakrishnano-bit/smarthelmet-app/blob/main/app/src/main/java/com/smarthelmet/app/BlackBoxActivity.java): `app/src/main/java/com/smarthelmet/app/BlackBoxActivity.java`

### Other components

- **Rider**
- **Browser Location**
- **SMS Network**
- **Device Location**

## Connections

- Helmet Sensors → Sensor Firmware: provide readings (evidence: `README.md`)
- Sensor Firmware → Serial Bridge: emit serial data (evidence: `README.md`)
- Sensor Firmware → Bluetooth Reader: emit Bluetooth data (evidence: `README.md`)
- Serial Bridge → WebSocket Server: broadcast telemetry (evidence: `backend.py`)
- WebSocket Server → Dashboard Logic: send telemetry (evidence: `README.md`)
- Dashboard Logic → Dashboard UI: updates (evidence: `app.js`)
- Dashboard Logic → Browser Settings: reads and writes (evidence: `app.js`)
- Dashboard Logic → Browser Location: requests location (evidence: `app.js`)
- Rider → Dashboard Logic: controls SOS (evidence: `app.js`)
- Rider → Mobile Dashboard: uses app (evidence: `README.md`)
- Mobile Dashboard → Safety Service: starts and binds (evidence: `app/src/main/java/com/smarthelmet/app/MainActivity.java`)
- Safety Service → Bluetooth Reader: connects through (evidence: `app/src/main/java/com/smarthelmet/app/SmartHelmetService.java`)
- Bluetooth Reader → Telemetry Packet: parses readings (evidence: `README.md`)
- Safety Service → Decision Engine: uses state machine (evidence: `README.md`)
- Mobile Dashboard → Telemetry Graph: displays telemetry (evidence: `app/src/main/java/com/smarthelmet/app/MainActivity.java`)
- Mobile Dashboard → Settings Screen: opens settings (evidence: `README.md`)
- Settings Screen → App Preferences: saves settings (evidence: `app/src/main/java/com/smarthelmet/app/SettingsActivity.java`)
- Safety Service → Ride Logger: records ride events (evidence: `README.md`)
- Mobile Dashboard → Ride Journal: opens journal (evidence: `README.md`)
- Ride Journal → Ride Logger: reads log entries (evidence: `app/src/main/java/com/smarthelmet/app/BlackBoxActivity.java`)
- Safety Service → SMS Network: dispatches SOS (evidence: `app/src/main/java/com/smarthelmet/app/SmartHelmetService.java`)
- Safety Service → Device Location: acquires coordinates (evidence: `README.md`)
- Device Location → SMS Network: location in alert
