# p6g9yhk6/sunnypilot-teslahw1 architecture

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

- Interactive diagram: https://gitdiagram.com/p6g9yhk6/sunnypilot-teslahw1
- Repository: https://github.com/p6g9yhk6/sunnypilot-teslahw1

## Overview

This is a Tesla HW1/AP1-focused fork of sunnypilot/openpilot: an on-device driver-assistance system, with vehicle support layered into the broader perception, planning, control, and device stack. The intended driving flow runs from camera and vehicle/sensor inputs through perception and localization, then planning and actuation, with UI and logging alongside it. The README also documents Bridge Toggle and `op fork`; PitStop and SunnyLink are distinct operational capabilities. Several subsystem links are dashed because their runtime calls were not shown in the sampled source.

Main entry points: [`system/manager/manager.py`](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/system/manager/manager.py) (Process manager), [`selfdrive/controls/plannerd.py`](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/selfdrive/controls/plannerd.py) (Trajectory planning), [`selfdrive/controls/controlsd.py`](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/selfdrive/controls/controlsd.py) (Motion control), [`pitstop/server.py`](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/pitstop/server.py) (PitStop web service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_drive["Driving stack"]
  node_model["Driving perception<br/>[modeld.py]"]
  node_localization["Localization<br/>[locationd.py]"]
  node_map["Map services<br/>[mapd_manager.py]"]
  node_planner["Trajectory planning<br/>[plannerd.py]"]
  node_controls["Motion control<br/>[controlsd.py]"]
end

subgraph group_device["Device services"]
  node_manager["Process manager<br/>[manager.py]"]
  node_messaging["Pub/sub messaging<br/>[__init__.py]"]
  node_camera["Camera capture<br/>[main.cc]"]
  node_sensors["Sensors and GPS<br/>[sensord.py]"]
  node_logger["Drive logger<br/>[loggerd.cc]"]
  node_params[("Persistent parameters<br/>[params.h]")]
end

subgraph group_interface["Vehicle and UI"]
  node_vehicle["Vehicle interface<br/>[card.py]"]
  node_panda["Panda hardware<br/>[pandad.py]"]
  node_tesla["Tesla HW1 support"]
  node_ui["On-device UI<br/>[ui.py]"]
end

subgraph group_operations["Operations and support"]
  node_pitstop["PitStop web service<br/>[server.py]"]
  node_diagnostics["Vehicle diagnostics<br/>[diagnostics.py]"]
  node_models["Model management<br/>[manager.py]"]
  node_sunnylink["SunnyLink services<br/>[sunnylinkd.py]"]
  node_backup["Config backups<br/>[manager.py]"]
  node_fork["OS fork management<br/>[updated.py]"]
end

node_driver(("Driver"))

node_driver -.->|"interacts with"| node_ui
node_manager -->|"subscribes and publishes"| node_messaging
node_camera -.->|"provides frames"| node_model
node_sensors -.->|"provides measurements"| node_localization
node_model -.->|"provides perception"| node_planner
node_localization -.->|"provides pose"| node_planner
node_map -.->|"provides map data"| node_planner
node_planner -.->|"provides plan"| node_controls
node_controls -.->|"commands"| node_vehicle
node_vehicle -.->|"uses hardware"| node_panda
node_tesla -.->|"extends support"| node_vehicle
node_controls -.->|"driving status"| node_ui
node_camera -.->|"records video"| node_logger
node_manager -.->|"manages process"| node_logger
node_pitstop -->|"routes diagnostics"| node_diagnostics
node_pitstop -->|"routes model actions"| node_models
node_models -->|"reports status"| node_messaging
node_sunnylink -.->|"supports backups"| node_backup
node_driver -.->|"uses local service"| node_pitstop
node_manager -.->|"stores device state"| node_params
node_fork -.->|"updates device OS"| node_manager

click node_manager "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/system/manager/manager.py"
click node_messaging "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/cereal/messaging/__init__.py"
click node_camera "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/system/camerad/main.cc"
click node_sensors "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/system/sensord/sensord.py"
click node_model "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/selfdrive/modeld/modeld.py"
click node_localization "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/selfdrive/locationd/locationd.py"
click node_map "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/sunnypilot/mapd/mapd_manager.py"
click node_planner "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/selfdrive/controls/plannerd.py"
click node_controls "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/selfdrive/controls/controlsd.py"
click node_vehicle "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/selfdrive/car/card.py"
click node_panda "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/selfdrive/pandad/pandad.py"
click node_tesla "https://github.com/p6g9yhk6/sunnypilot-teslahw1/tree/master/selfdrive/car"
click node_ui "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/selfdrive/ui/ui.py"
click node_logger "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/system/loggerd/loggerd.cc"
click node_params "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/common/params.h"
click node_pitstop "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/pitstop/server.py"
click node_diagnostics "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/pitstop/diagnostics.py"
click node_models "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/sunnypilot/models/manager.py"
click node_sunnylink "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/sunnypilot/sunnylink/athena/sunnylinkd.py"
click node_backup "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/sunnypilot/sunnylink/backups/manager.py"
click node_fork "https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/system/updated/updated.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_model,node_localization,node_map,node_planner,node_controls toneBlue
class node_manager,node_messaging,node_camera,node_sensors,node_logger,node_params toneAmber
class node_vehicle,node_panda,node_tesla,node_ui toneMint
class node_pitstop,node_diagnostics,node_models,node_sunnylink,node_backup,node_fork toneRose
class node_driver toneIndigo
```

## Components

### Driving stack

- [Driving perception](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/selfdrive/modeld/modeld.py): `selfdrive/modeld/modeld.py`
- [Localization](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/selfdrive/locationd/locationd.py): `selfdrive/locationd/locationd.py`
- [Map services](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/sunnypilot/mapd/mapd_manager.py): `sunnypilot/mapd/mapd_manager.py`
- [Trajectory planning](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/selfdrive/controls/plannerd.py): `selfdrive/controls/plannerd.py`
- [Motion control](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/selfdrive/controls/controlsd.py): `selfdrive/controls/controlsd.py`

### Device services

- [Process manager](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/system/manager/manager.py): `system/manager/manager.py`
- [Pub/sub messaging](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/cereal/messaging/__init__.py): `cereal/messaging/__init__.py`
- [Camera capture](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/system/camerad/main.cc): `system/camerad/main.cc`
- [Sensors and GPS](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/system/sensord/sensord.py): `system/sensord/sensord.py`
- [Drive logger](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/system/loggerd/loggerd.cc): `system/loggerd/loggerd.cc`
- [Persistent parameters](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/common/params.h): `common/params.h`

### Vehicle and UI

- [Vehicle interface](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/selfdrive/car/card.py): `selfdrive/car/card.py`
- [Panda hardware](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/selfdrive/pandad/pandad.py): `selfdrive/pandad/pandad.py`
- [Tesla HW1 support](https://github.com/p6g9yhk6/sunnypilot-teslahw1/tree/master/selfdrive/car): `selfdrive/car`
- [On-device UI](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/selfdrive/ui/ui.py): `selfdrive/ui/ui.py`

### Operations and support

- [PitStop web service](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/pitstop/server.py): `pitstop/server.py`
- [Vehicle diagnostics](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/pitstop/diagnostics.py): `pitstop/diagnostics.py`
- [Model management](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/sunnypilot/models/manager.py): `sunnypilot/models/manager.py`
- [SunnyLink services](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/sunnypilot/sunnylink/athena/sunnylinkd.py): `sunnypilot/sunnylink/athena/sunnylinkd.py`
- [Config backups](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/sunnypilot/sunnylink/backups/manager.py): `sunnypilot/sunnylink/backups/manager.py`
- [OS fork management](https://github.com/p6g9yhk6/sunnypilot-teslahw1/blob/master/system/updated/updated.py): `system/updated/updated.py`

### Other components

- **Driver**

## Connections

- Driver → On-device UI: interacts with (evidence: `README.md`)
- Process manager → Pub/sub messaging: subscribes and publishes (evidence: `system/manager/manager.py`)
- Camera capture → Driving perception: provides frames
- Sensors and GPS → Localization: provides measurements
- Driving perception → Trajectory planning: provides perception
- Localization → Trajectory planning: provides pose
- Map services → Trajectory planning: provides map data
- Trajectory planning → Motion control: provides plan
- Motion control → Vehicle interface: commands
- Vehicle interface → Panda hardware: uses hardware
- Tesla HW1 support → Vehicle interface: extends support (evidence: `README.md`)
- Motion control → On-device UI: driving status
- Camera capture → Drive logger: records video
- Process manager → Drive logger: manages process
- PitStop web service → Vehicle diagnostics: routes diagnostics (evidence: `pitstop/server.py`)
- PitStop web service → Model management: routes model actions (evidence: `pitstop/server.py`)
- Model management → Pub/sub messaging: reports status (evidence: `sunnypilot/models/manager.py`)
- SunnyLink services → Config backups: supports backups
- Driver → PitStop web service: uses local service
- Process manager → Persistent parameters: stores device state
- OS fork management → Process manager: updates device OS (evidence: `README.md`)
