# tobyy85/pi-play architecture

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

- Interactive diagram: https://gitdiagram.com/tobyy85/pi-play
- Repository: https://github.com/tobyy85/pi-play

## Overview

Pi-Play is an Electron-based Raspberry Pi in-car dashboard integrating Arduino hardware. The user-facing workflow is to open dashboard apps for navigation, media, phone, radio, and vehicle information; hardware sensor readings and controls are another major capability. The excerpts show Arduino sensor registration, change detection, and serial output, but not the Electron IPC wiring or most app-service implementations, so those relationships are left unverified rather than presented as confirmed calls.

Main entry points: [`app/src/main/services`](https://github.com/tobyy85/pi-play/tree/main/app/src/main/services) (Device services), [`app/src/renderer/main.tsx`](https://github.com/tobyy85/pi-play/blob/main/app/src/renderer/main.tsx) (React renderer), [`hardware/arduino/src/SensorManager.cpp`](https://github.com/tobyy85/pi-play/blob/main/hardware/arduino/src/SensorManager.cpp) (Sensor manager), [`hardware/arduino/src/SensorHandler.cpp`](https://github.com/tobyy85/pi-play/blob/main/hardware/arduino/src/SensorHandler.cpp) (Sensor handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["Application shell"]
  node_electron["Electron main process<br/>[main.ts]"]
  node_window["Window manager<br/>[windowManager.ts]"]
  node_renderer["React renderer<br/>[main.tsx]"]
  node_router["App router<br/>[router.tsx]"]
end

subgraph group_dashboard["Dashboard apps"]
  node_appcatalog["App catalog"]
  node_maps["Maps and GPS"]
  node_music["Music player"]
  node_phone["Phone and calls"]
  node_radio["Radio"]
  node_reversecam["Reverse camera"]
  node_overlays["Vehicle overlays"]
end

subgraph group_services["Device services"]
  node_bootstrap["Service bootstrap<br/>[services.ts]"]
  node_device_services["Device services"]
  node_shared["Shared contracts"]
end

subgraph group_arduino["Arduino firmware"]
  node_sensor_setup["Sensor setup<br/>[sensors.cpp]"]
  node_sensor_manager["Sensor manager<br/>[SensorManager.cpp]"]
  node_sensor_handler["Sensor handler<br/>[SensorHandler.cpp]"]
  node_sensor_io["Serial communication"]
  node_sensor_types["Sensor hardware"]
  node_engine["Engine detector<br/>[engineDetector.cpp]"]
end

subgraph group_parking["Parking hardware"]
  node_parking_sensor["Ultrasonic sensing"]
  node_parking_serial["Parking serial output"]
end

node_driver(("Driver"))

node_driver -.->|"uses dashboard"| node_renderer
node_renderer -->|"renders"| node_router
node_router -.->|"routes apps"| node_appcatalog
node_driver -.->|"selects app"| node_appcatalog
node_electron -.->|"manages window"| node_window
node_bootstrap -.->|"initializes services"| node_device_services
node_renderer -.->|"exchanges IPC"| node_device_services
node_device_services -.->|"uses contracts"| node_shared
node_sensor_setup -->|"registers sensors"| node_sensor_manager
node_sensor_setup -->|"reads hardware"| node_sensor_types
node_sensor_manager -->|"updates handlers"| node_sensor_handler
node_sensor_handler -->|"sends readings"| node_sensor_io
node_sensor_manager -->|"dispatches requests"| node_sensor_handler
node_engine -.->|"signals state"| node_sensor_io
node_parking_sensor -.->|"reports distance"| node_parking_serial
node_sensor_io -.->|"sends serial data"| node_device_services
node_device_services -.->|"provides GPS data"| node_maps
node_device_services -.->|"controls playback"| node_music
node_device_services -.->|"provides call data"| node_phone
node_device_services -.->|"controls radio"| node_radio
node_device_services -.->|"provides camera"| node_reversecam
node_device_services -.->|"provides controls"| node_overlays

click node_electron "https://github.com/tobyy85/pi-play/blob/main/app/src/main/main.ts"
click node_window "https://github.com/tobyy85/pi-play/blob/main/app/src/main/managers/windowManager.ts"
click node_renderer "https://github.com/tobyy85/pi-play/blob/main/app/src/renderer/main.tsx"
click node_router "https://github.com/tobyy85/pi-play/blob/main/app/src/renderer/routes/router.tsx"
click node_appcatalog "https://github.com/tobyy85/pi-play/tree/main/app/src/renderer/features/apps"
click node_maps "https://github.com/tobyy85/pi-play/tree/main/app/src/renderer/features/appMaps"
click node_music "https://github.com/tobyy85/pi-play/tree/main/app/src/renderer/features/appMusic"
click node_phone "https://github.com/tobyy85/pi-play/tree/main/app/src/renderer/features/appPhone"
click node_radio "https://github.com/tobyy85/pi-play/tree/main/app/src/renderer/features/appRadio"
click node_reversecam "https://github.com/tobyy85/pi-play/tree/main/app/src/renderer/features/appReverseCamera"
click node_overlays "https://github.com/tobyy85/pi-play/tree/main/app/src/renderer/features/brightness"
click node_bootstrap "https://github.com/tobyy85/pi-play/blob/main/app/src/main/bootstrap/services.ts"
click node_device_services "https://github.com/tobyy85/pi-play/tree/main/app/src/main/services"
click node_shared "https://github.com/tobyy85/pi-play/tree/main/app/src/shared"
click node_sensor_setup "https://github.com/tobyy85/pi-play/blob/main/hardware/arduino/sensors.cpp"
click node_sensor_manager "https://github.com/tobyy85/pi-play/blob/main/hardware/arduino/src/SensorManager.cpp"
click node_sensor_handler "https://github.com/tobyy85/pi-play/blob/main/hardware/arduino/src/SensorHandler.cpp"
click node_sensor_io "https://github.com/tobyy85/pi-play/blob/main/hardware/arduino/src/SerialCommunication.cpp"
click node_sensor_types "https://github.com/tobyy85/pi-play/tree/main/hardware/arduino/src/sensors"
click node_engine "https://github.com/tobyy85/pi-play/blob/main/hardware/arduino/engineDetector.cpp"
click node_parking_sensor "https://github.com/tobyy85/pi-play/blob/main/hardware/parkingSensors/src/UltrasonicSensor.cpp"
click node_parking_serial "https://github.com/tobyy85/pi-play/blob/main/hardware/parkingSensors/src/serialCommunication.cpp"

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_electron,node_window,node_renderer,node_router toneBlue
class node_appcatalog,node_maps,node_music,node_phone,node_radio,node_reversecam,node_overlays toneAmber
class node_bootstrap,node_device_services,node_shared toneMint
class node_sensor_setup,node_sensor_manager,node_sensor_handler,node_sensor_io,node_sensor_types,node_engine toneRose
class node_parking_sensor,node_parking_serial,node_driver toneIndigo
```

## Components

### Application shell

- [Electron main process](https://github.com/tobyy85/pi-play/blob/main/app/src/main/main.ts): `app/src/main/main.ts`
- [Window manager](https://github.com/tobyy85/pi-play/blob/main/app/src/main/managers/windowManager.ts): `app/src/main/managers/windowManager.ts`
- [React renderer](https://github.com/tobyy85/pi-play/blob/main/app/src/renderer/main.tsx): `app/src/renderer/main.tsx`
- [App router](https://github.com/tobyy85/pi-play/blob/main/app/src/renderer/routes/router.tsx): `app/src/renderer/routes/router.tsx`

### Dashboard apps

- [App catalog](https://github.com/tobyy85/pi-play/tree/main/app/src/renderer/features/apps): `app/src/renderer/features/apps`
- [Maps and GPS](https://github.com/tobyy85/pi-play/tree/main/app/src/renderer/features/appMaps): `app/src/renderer/features/appMaps`
- [Music player](https://github.com/tobyy85/pi-play/tree/main/app/src/renderer/features/appMusic): `app/src/renderer/features/appMusic`
- [Phone and calls](https://github.com/tobyy85/pi-play/tree/main/app/src/renderer/features/appPhone): `app/src/renderer/features/appPhone`
- [Radio](https://github.com/tobyy85/pi-play/tree/main/app/src/renderer/features/appRadio): `app/src/renderer/features/appRadio`
- [Reverse camera](https://github.com/tobyy85/pi-play/tree/main/app/src/renderer/features/appReverseCamera): `app/src/renderer/features/appReverseCamera`
- [Vehicle overlays](https://github.com/tobyy85/pi-play/tree/main/app/src/renderer/features/brightness): `app/src/renderer/features/brightness`

### Device services

- [Service bootstrap](https://github.com/tobyy85/pi-play/blob/main/app/src/main/bootstrap/services.ts): `app/src/main/bootstrap/services.ts`
- [Device services](https://github.com/tobyy85/pi-play/tree/main/app/src/main/services): `app/src/main/services`
- [Shared contracts](https://github.com/tobyy85/pi-play/tree/main/app/src/shared): `app/src/shared`

### Arduino firmware

- [Sensor setup](https://github.com/tobyy85/pi-play/blob/main/hardware/arduino/sensors.cpp): `hardware/arduino/sensors.cpp`
- [Sensor manager](https://github.com/tobyy85/pi-play/blob/main/hardware/arduino/src/SensorManager.cpp): `hardware/arduino/src/SensorManager.cpp`
- [Sensor handler](https://github.com/tobyy85/pi-play/blob/main/hardware/arduino/src/SensorHandler.cpp): `hardware/arduino/src/SensorHandler.cpp`
- [Serial communication](https://github.com/tobyy85/pi-play/blob/main/hardware/arduino/src/SerialCommunication.cpp): `hardware/arduino/src/SerialCommunication.cpp`
- [Sensor hardware](https://github.com/tobyy85/pi-play/tree/main/hardware/arduino/src/sensors): `hardware/arduino/src/sensors`
- [Engine detector](https://github.com/tobyy85/pi-play/blob/main/hardware/arduino/engineDetector.cpp): `hardware/arduino/engineDetector.cpp`

### Parking hardware

- [Ultrasonic sensing](https://github.com/tobyy85/pi-play/blob/main/hardware/parkingSensors/src/UltrasonicSensor.cpp): `hardware/parkingSensors/src/UltrasonicSensor.cpp`
- [Parking serial output](https://github.com/tobyy85/pi-play/blob/main/hardware/parkingSensors/src/serialCommunication.cpp): `hardware/parkingSensors/src/serialCommunication.cpp`

### Other components

- **Driver**

## Connections

- Driver → React renderer: uses dashboard
- React renderer → App router: renders (evidence: `app/src/renderer/main.tsx`)
- App router → App catalog: routes apps
- Driver → App catalog: selects app
- Electron main process → Window manager: manages window
- Service bootstrap → Device services: initializes services
- React renderer → Device services: exchanges IPC
- Device services → Shared contracts: uses contracts
- Sensor setup → Sensor manager: registers sensors (evidence: `hardware/arduino/sensors.cpp`)
- Sensor setup → Sensor hardware: reads hardware (evidence: `hardware/arduino/sensors.cpp`)
- Sensor manager → Sensor handler: updates handlers (evidence: `hardware/arduino/src/SensorManager.cpp`)
- Sensor handler → Serial communication: sends readings (evidence: `hardware/arduino/src/SensorHandler.cpp`)
- Sensor manager → Sensor handler: dispatches requests (evidence: `hardware/arduino/src/SensorManager.cpp`)
- Engine detector → Serial communication: signals state
- Ultrasonic sensing → Parking serial output: reports distance
- Serial communication → Device services: sends serial data
- Device services → Maps and GPS: provides GPS data
- Device services → Music player: controls playback
- Device services → Phone and calls: provides call data
- Device services → Radio: controls radio
- Device services → Reverse camera: provides camera
- Device services → Vehicle overlays: provides controls
