# quantyle/can-shark architecture

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

- Interactive diagram: https://gitdiagram.com/quantyle/can-shark
- Repository: https://github.com/quantyle/can-shark

## Overview

CAN-Shark is a vehicle CAN-bus monitoring/injection project: its documented use is a Python serial client with Arduino firmware and either a Sparkfun or Seeed CAN shield. The sampled web UI sends PID requests over a local WebSocket and renders returned values as a table. The Python client, firmware sketch, and full server/protocol wiring were not sampled, so those runtime links are shown only where documentation supports them; UI source does not establish the server implementation.

Main entry points: [`can-shark/src/views/home/Home.jsx`](https://github.com/quantyle/can-shark/blob/master/can-shark/src/views/home/Home.jsx) (CAN dashboard), [`firmware/src/Sparkfun_Shield_Custom/mcp2515.c`](https://github.com/quantyle/can-shark/blob/master/firmware/src/Sparkfun_Shield_Custom/mcp2515.c) (MCP2515 SPI driver), [`firmware/CAN_Shark.ino`](https://github.com/quantyle/can-shark/blob/master/firmware/CAN_Shark.ino) (CAN firmware), [`firmware/src/Sparkfun_Shield_Custom/mcp2515.h`](https://github.com/quantyle/can-shark/blob/master/firmware/src/Sparkfun_Shield_Custom/mcp2515.h) (MCP2515 interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Browser dashboard"]
  node_dashboard["CAN dashboard<br/>[Home.jsx]"]
  node_router["View routing<br/>[routes.jsx]"]
  node_app["App container<br/>[App.jsx]"]
  node_loading["Route loading<br/>[Loading.jsx]"]
  node_ui_styles["UI styles<br/>[homeStyle.jsx]"]
end

subgraph group_host["Host communication"]
  node_python["Python serial client<br/>[can.py]"]
  node_websocket["WebSocket endpoint"]
end

subgraph group_firmware["Arduino firmware"]
  node_sketch["CAN firmware<br/>[CAN_Shark.ino]"]
end

subgraph group_drivers["Shield drivers"]
  node_seeed_api["Seeed CAN API<br/>[mcp_can.h]"]
  node_seeed_impl["Seeed CAN driver<br/>[mcp_can.cpp]"]
  node_seeed_defs["Seeed controller definitions<br/>[mcp_can_dfs.h]"]
  node_spark_api["Sparkfun CAN API<br/>[Canbus.h]"]
  node_spark_impl["Sparkfun CAN driver<br/>[Canbus.cpp]"]
  node_mcp_driver["MCP2515 SPI driver<br/>[mcp2515.c]"]
  node_mcp_api["MCP2515 interface<br/>[mcp2515.h]"]
  node_mcp_defs["MCP2515 definitions<br/>[mcp2515_defs.h]"]
  node_gpio["GPIO mapping<br/>[global.h]"]
  node_pins["Shield pin defaults<br/>[defaults.h]"]
end

node_driver(("Vehicle operator"))
node_vehicle["Toyota Prius CAN bus"]

node_driver -.->|"uses"| node_dashboard
node_app -->|"renders routes"| node_router
node_router -->|"loads view"| node_dashboard
node_router -->|"shows while loading"| node_loading
node_dashboard -->|"uses styles"| node_ui_styles
node_dashboard -->|"sends PID requests"| node_websocket
node_websocket -.->|"returns readings"| node_dashboard
node_python -.->|"serves connection"| node_websocket
node_python -.->|"communicates serially"| node_sketch
node_sketch -.->|"uses driver"| node_seeed_api
node_sketch -.->|"uses driver"| node_spark_api
node_seeed_impl -->|"implements API"| node_seeed_api
node_seeed_api -->|"uses definitions"| node_seeed_defs
node_spark_impl -->|"implements API"| node_spark_api
node_spark_impl -->|"calls controller"| node_mcp_api
node_mcp_driver -->|"implements interface"| node_mcp_api
node_mcp_driver -->|"uses definitions"| node_mcp_defs
node_mcp_driver -->|"uses GPIO macros"| node_gpio
node_mcp_driver -->|"uses pin mapping"| node_pins
node_mcp_api -->|"uses definitions"| node_mcp_defs
node_mcp_api -->|"uses GPIO macros"| node_gpio
node_sketch -.->|"reads and injects CAN"| node_vehicle

click node_dashboard "https://github.com/quantyle/can-shark/blob/master/can-shark/src/views/home/Home.jsx"
click node_router "https://github.com/quantyle/can-shark/blob/master/can-shark/src/routes/routes.jsx"
click node_app "https://github.com/quantyle/can-shark/blob/master/can-shark/src/containers/App.jsx"
click node_loading "https://github.com/quantyle/can-shark/blob/master/can-shark/src/components/loading/Loading.jsx"
click node_ui_styles "https://github.com/quantyle/can-shark/blob/master/can-shark/src/variables/styles/homeStyle.jsx"
click node_python "https://github.com/quantyle/can-shark/blob/master/can.py"
click node_sketch "https://github.com/quantyle/can-shark/blob/master/firmware/CAN_Shark.ino"
click node_seeed_api "https://github.com/quantyle/can-shark/blob/master/firmware/src/Seeed_Shield_Custom/mcp_can.h"
click node_seeed_impl "https://github.com/quantyle/can-shark/blob/master/firmware/src/Seeed_Shield_Custom/mcp_can.cpp"
click node_seeed_defs "https://github.com/quantyle/can-shark/blob/master/firmware/src/Seeed_Shield_Custom/mcp_can_dfs.h"
click node_spark_api "https://github.com/quantyle/can-shark/blob/master/firmware/src/Sparkfun_Shield_Custom/Canbus.h"
click node_spark_impl "https://github.com/quantyle/can-shark/blob/master/firmware/src/Sparkfun_Shield_Custom/Canbus.cpp"
click node_mcp_driver "https://github.com/quantyle/can-shark/blob/master/firmware/src/Sparkfun_Shield_Custom/mcp2515.c"
click node_mcp_api "https://github.com/quantyle/can-shark/blob/master/firmware/src/Sparkfun_Shield_Custom/mcp2515.h"
click node_mcp_defs "https://github.com/quantyle/can-shark/blob/master/firmware/src/Sparkfun_Shield_Custom/mcp2515_defs.h"
click node_gpio "https://github.com/quantyle/can-shark/blob/master/firmware/src/Sparkfun_Shield_Custom/global.h"
click node_pins "https://github.com/quantyle/can-shark/blob/master/firmware/src/Sparkfun_Shield_Custom/defaults.h"

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_router,node_app,node_loading,node_ui_styles toneBlue
class node_python,node_websocket toneAmber
class node_sketch toneMint
class node_seeed_api,node_seeed_impl,node_seeed_defs,node_spark_api,node_spark_impl,node_mcp_driver,node_mcp_api,node_mcp_defs,node_gpio,node_pins toneRose
class node_driver,node_vehicle toneIndigo
```

## Components

### Browser dashboard

- [CAN dashboard](https://github.com/quantyle/can-shark/blob/master/can-shark/src/views/home/Home.jsx): `can-shark/src/views/home/Home.jsx`
- [View routing](https://github.com/quantyle/can-shark/blob/master/can-shark/src/routes/routes.jsx): `can-shark/src/routes/routes.jsx`
- [App container](https://github.com/quantyle/can-shark/blob/master/can-shark/src/containers/App.jsx): `can-shark/src/containers/App.jsx`
- [Route loading](https://github.com/quantyle/can-shark/blob/master/can-shark/src/components/loading/Loading.jsx): `can-shark/src/components/loading/Loading.jsx`
- [UI styles](https://github.com/quantyle/can-shark/blob/master/can-shark/src/variables/styles/homeStyle.jsx): `can-shark/src/variables/styles/homeStyle.jsx`

### Host communication

- [Python serial client](https://github.com/quantyle/can-shark/blob/master/can.py): `can.py`
- **WebSocket endpoint**

### Arduino firmware

- [CAN firmware](https://github.com/quantyle/can-shark/blob/master/firmware/CAN_Shark.ino): `firmware/CAN_Shark.ino`

### Shield drivers

- [Seeed CAN API](https://github.com/quantyle/can-shark/blob/master/firmware/src/Seeed_Shield_Custom/mcp_can.h): `firmware/src/Seeed_Shield_Custom/mcp_can.h`
- [Seeed CAN driver](https://github.com/quantyle/can-shark/blob/master/firmware/src/Seeed_Shield_Custom/mcp_can.cpp): `firmware/src/Seeed_Shield_Custom/mcp_can.cpp`
- [Seeed controller definitions](https://github.com/quantyle/can-shark/blob/master/firmware/src/Seeed_Shield_Custom/mcp_can_dfs.h): `firmware/src/Seeed_Shield_Custom/mcp_can_dfs.h`
- [Sparkfun CAN API](https://github.com/quantyle/can-shark/blob/master/firmware/src/Sparkfun_Shield_Custom/Canbus.h): `firmware/src/Sparkfun_Shield_Custom/Canbus.h`
- [Sparkfun CAN driver](https://github.com/quantyle/can-shark/blob/master/firmware/src/Sparkfun_Shield_Custom/Canbus.cpp): `firmware/src/Sparkfun_Shield_Custom/Canbus.cpp`
- [MCP2515 SPI driver](https://github.com/quantyle/can-shark/blob/master/firmware/src/Sparkfun_Shield_Custom/mcp2515.c): `firmware/src/Sparkfun_Shield_Custom/mcp2515.c`
- [MCP2515 interface](https://github.com/quantyle/can-shark/blob/master/firmware/src/Sparkfun_Shield_Custom/mcp2515.h): `firmware/src/Sparkfun_Shield_Custom/mcp2515.h`
- [MCP2515 definitions](https://github.com/quantyle/can-shark/blob/master/firmware/src/Sparkfun_Shield_Custom/mcp2515_defs.h): `firmware/src/Sparkfun_Shield_Custom/mcp2515_defs.h`
- [GPIO mapping](https://github.com/quantyle/can-shark/blob/master/firmware/src/Sparkfun_Shield_Custom/global.h): `firmware/src/Sparkfun_Shield_Custom/global.h`
- [Shield pin defaults](https://github.com/quantyle/can-shark/blob/master/firmware/src/Sparkfun_Shield_Custom/defaults.h): `firmware/src/Sparkfun_Shield_Custom/defaults.h`

### Other components

- **Vehicle operator**
- **Toyota Prius CAN bus**

## Connections

- Vehicle operator → CAN dashboard: uses (evidence: `README.md`)
- App container → View routing: renders routes (evidence: `can-shark/src/containers/App.jsx`)
- View routing → CAN dashboard: loads view (evidence: `can-shark/src/routes/routes.jsx`)
- View routing → Route loading: shows while loading (evidence: `can-shark/src/routes/routes.jsx`)
- CAN dashboard → UI styles: uses styles (evidence: `can-shark/src/views/home/Home.jsx`)
- CAN dashboard → WebSocket endpoint: sends PID requests (evidence: `can-shark/src/views/home/Home.jsx`)
- WebSocket endpoint → CAN dashboard: returns readings
- Python serial client → WebSocket endpoint: serves connection
- Python serial client → CAN firmware: communicates serially (evidence: `README.md`)
- CAN firmware → Seeed CAN API: uses driver
- CAN firmware → Sparkfun CAN API: uses driver
- Seeed CAN driver → Seeed CAN API: implements API (evidence: `firmware/src/Seeed_Shield_Custom/mcp_can.cpp`)
- Seeed CAN API → Seeed controller definitions: uses definitions (evidence: `firmware/src/Seeed_Shield_Custom/mcp_can.h`)
- Sparkfun CAN driver → Sparkfun CAN API: implements API (evidence: `firmware/src/Sparkfun_Shield_Custom/Canbus.cpp`)
- Sparkfun CAN driver → MCP2515 interface: calls controller (evidence: `firmware/src/Sparkfun_Shield_Custom/Canbus.cpp`)
- MCP2515 SPI driver → MCP2515 interface: implements interface (evidence: `firmware/src/Sparkfun_Shield_Custom/mcp2515.c`)
- MCP2515 SPI driver → MCP2515 definitions: uses definitions (evidence: `firmware/src/Sparkfun_Shield_Custom/mcp2515.c`)
- MCP2515 SPI driver → GPIO mapping: uses GPIO macros (evidence: `firmware/src/Sparkfun_Shield_Custom/mcp2515.c`)
- MCP2515 SPI driver → Shield pin defaults: uses pin mapping (evidence: `firmware/src/Sparkfun_Shield_Custom/mcp2515.c`)
- MCP2515 interface → MCP2515 definitions: uses definitions (evidence: `firmware/src/Sparkfun_Shield_Custom/mcp2515.h`)
- MCP2515 interface → GPIO mapping: uses GPIO macros (evidence: `firmware/src/Sparkfun_Shield_Custom/mcp2515.h`)
- CAN firmware → Toyota Prius CAN bus: reads and injects CAN (evidence: `README.md`)
