# arsenialiakseichyk/robot-web-controller architecture

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

- Interactive diagram: https://gitdiagram.com/arsenialiakseichyk/robot-web-controller
- Repository: https://github.com/arsenialiakseichyk/robot-web-controller

## Overview

This is a Raspberry Pi rover controller: a browser connects to the C server, joins as a viewer or PIN-authenticated pilot, and sends driving input that reaches motor control while ultrasonic sensing can block unsafe motion. The same UI exposes camera and system settings, and camera video is delivered to the browser through a documented WebRTC/WHEP pipeline. The graph combines excerpts, SOURCE INDEX references, and README-described capabilities; some subsystem links rely on README documentation because their implementation was not excerpted.

Main entry points: [`hardware/controller.c`](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/hardware/controller.c) (Motion controller), [`web/js/app.js`](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/web/js/app.js) (UI coordinator), [`main.c`](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/main.c) (Startup and config), [`server/routes.c`](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/server/routes.c) (REST settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and server"]
  node_main["Startup and config<br/>[main.c]"]
  node_config["Environment config<br/>[config.c]"]
  node_server["HTTP server<br/>[server.c]"]
  node_routes["REST settings<br/>[routes.c]"]
  node_websocket["WS sessions<br/>[websocket.c]"]
  node_whep["WHEP proxy<br/>[whep.c]"]
  node_shell["System commands<br/>[shell.c]"]
end

subgraph group_hardware["Robot hardware"]
  node_controller["Motion controller<br/>[controller.c]"]
  node_motors["Motor stepping<br/>[motors.c]"]
  node_gpio["GPIO access<br/>[gpio.c]"]
  node_sensors["Ultrasonic safety<br/>[sensors.c]"]
  node_leds["LED status<br/>[leds.c]"]
  node_tilt["Tilt receiver<br/>[rpi_tilt_recv.c]"]
end

subgraph group_browser["Browser interface"]
  node_app["UI coordinator<br/>[app.js]"]
  node_connection["WS connection<br/>[connection.js]"]
  node_controls["Drive controls<br/>[controls.js]"]
  node_camera_ui["Camera UI<br/>[camera.js]"]
  node_system_ui["System settings UI<br/>[system.js]"]
  node_tilt_ui["Tilt UI<br/>[tilt.js]"]
  node_state["Shared UI state<br/>[state.js]"]
end

subgraph group_video["Video delivery"]
  node_camera["Camera lifecycle<br/>[camera.c]"]
  node_camera_tools["Camera and encoder"]
  node_mediamtx["MediaMTX"]
end

node_browser_user(("Viewer / pilot"))

node_browser_user -->|"uses"| node_app
node_main -->|"loads"| node_config
node_main -->|"initializes"| node_controller
node_main -->|"initializes"| node_camera
node_main -->|"starts"| node_server
node_main -->|"bridges status"| node_websocket
node_server -->|"routes HTTP"| node_routes
node_server -->|"serves WS"| node_websocket
node_server -->|"proxies WHEP"| node_whep
node_routes -->|"updates config"| node_camera
node_routes -->|"persists settings"| node_config
node_routes -->|"reads GPIO info"| node_controller
node_routes -->|"runs commands"| node_shell
node_websocket -->|"dispatches drive"| node_controller
node_controller -->|"initializes GPIO"| node_gpio
node_controller -->|"starts receiver"| node_tilt
node_controller -->|"drives motors"| node_motors
node_controller -->|"uses safety sensing"| node_sensors
node_controller -->|"updates indicators"| node_leds
node_sensors -->|"blocks unsafe motion"| node_motors
node_camera -->|"starts capture pipeline"| node_camera_tools
node_camera_tools -->|"streams RTSP"| node_mediamtx
node_mediamtx -->|"serves WebRTC"| node_whep
node_whep -->|"delivers video"| node_browser_user
node_app -->|"initializes"| node_connection
node_app -->|"initializes"| node_controls
node_app -->|"initializes"| node_camera_ui
node_app -->|"initializes"| node_system_ui
node_app -->|"initializes"| node_tilt_ui
node_app -->|"reads state"| node_state
node_controls -->|"sends commands"| node_connection
node_camera_ui -->|"reads state"| node_state
node_system_ui -->|"reconnects via"| node_connection
node_system_ui -->|"reads state"| node_state
node_tilt_ui -->|"updates state"| node_state

click node_main "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/main.c"
click node_config "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/utils/config.c"
click node_server "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/server/server.c"
click node_routes "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/server/routes.c"
click node_websocket "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/server/websocket.c"
click node_whep "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/server/whep.c"
click node_shell "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/utils/shell.c"
click node_controller "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/hardware/controller.c"
click node_motors "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/hardware/motors.c"
click node_gpio "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/hardware/gpio.c"
click node_sensors "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/hardware/sensors.c"
click node_leds "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/hardware/leds.c"
click node_tilt "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/hardware/rpi_tilt_recv.c"
click node_camera "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/hardware/camera.c"
click node_app "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/web/js/app.js"
click node_connection "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/web/js/connection.js"
click node_controls "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/web/js/controls.js"
click node_camera_ui "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/web/js/camera.js"
click node_system_ui "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/web/js/system.js"
click node_tilt_ui "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/web/js/tilt.js"
click node_state "https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/web/js/state.js"

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_main,node_config,node_server,node_routes,node_websocket,node_whep,node_shell,node_browser_user toneBlue
class node_controller,node_motors,node_gpio,node_sensors,node_leds,node_tilt toneAmber
class node_app,node_connection,node_controls,node_camera_ui,node_system_ui,node_tilt_ui,node_state toneMint
class node_camera,node_camera_tools,node_mediamtx toneRose
```

## Components

### Runtime and server

- [Startup and config](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/main.c): `main.c`
- [Environment config](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/utils/config.c): `utils/config.c`
- [HTTP server](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/server/server.c): `server/server.c`
- [REST settings](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/server/routes.c): `server/routes.c`
- [WS sessions](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/server/websocket.c): `server/websocket.c`
- [WHEP proxy](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/server/whep.c): `server/whep.c`
- [System commands](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/utils/shell.c): `utils/shell.c`

### Robot hardware

- [Motion controller](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/hardware/controller.c): `hardware/controller.c`
- [Motor stepping](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/hardware/motors.c): `hardware/motors.c`
- [GPIO access](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/hardware/gpio.c): `hardware/gpio.c`
- [Ultrasonic safety](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/hardware/sensors.c): `hardware/sensors.c`
- [LED status](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/hardware/leds.c): `hardware/leds.c`
- [Tilt receiver](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/hardware/rpi_tilt_recv.c): `hardware/rpi_tilt_recv.c`

### Browser interface

- [UI coordinator](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/web/js/app.js): `web/js/app.js`
- [WS connection](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/web/js/connection.js): `web/js/connection.js`
- [Drive controls](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/web/js/controls.js): `web/js/controls.js`
- [Camera UI](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/web/js/camera.js): `web/js/camera.js`
- [System settings UI](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/web/js/system.js): `web/js/system.js`
- [Tilt UI](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/web/js/tilt.js): `web/js/tilt.js`
- [Shared UI state](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/web/js/state.js): `web/js/state.js`

### Video delivery

- [Camera lifecycle](https://github.com/arsenialiakseichyk/robot-web-controller/blob/main/hardware/camera.c): `hardware/camera.c`
- **Camera and encoder**
- **MediaMTX**

### Other components

- **Viewer / pilot**

## Connections

- Viewer / pilot → UI coordinator: uses (evidence: `README.md`)
- Startup and config → Environment config: loads (evidence: `main.c`)
- Startup and config → Motion controller: initializes (evidence: `main.c`)
- Startup and config → Camera lifecycle: initializes (evidence: `main.c`)
- Startup and config → HTTP server: starts (evidence: `main.c`)
- Startup and config → WS sessions: bridges status (evidence: `main.c`)
- HTTP server → REST settings: routes HTTP (evidence: `README.md`)
- HTTP server → WS sessions: serves WS (evidence: `README.md`)
- HTTP server → WHEP proxy: proxies WHEP (evidence: `README.md`)
- REST settings → Camera lifecycle: updates config (evidence: `server/routes.c`)
- REST settings → Environment config: persists settings (evidence: `server/routes.c`)
- REST settings → Motion controller: reads GPIO info (evidence: `server/routes.c`)
- REST settings → System commands: runs commands (evidence: `server/routes.c`)
- WS sessions → Motion controller: dispatches drive (evidence: `README.md`)
- Motion controller → GPIO access: initializes GPIO (evidence: `hardware/controller.c`)
- Motion controller → Tilt receiver: starts receiver (evidence: `hardware/controller.c`)
- Motion controller → Motor stepping: drives motors (evidence: `README.md`)
- Motion controller → Ultrasonic safety: uses safety sensing (evidence: `README.md`)
- Motion controller → LED status: updates indicators (evidence: `README.md`)
- Ultrasonic safety → Motor stepping: blocks unsafe motion (evidence: `README.md`)
- Camera lifecycle → Camera and encoder: starts capture pipeline (evidence: `README.md`)
- Camera and encoder → MediaMTX: streams RTSP (evidence: `README.md`)
- MediaMTX → WHEP proxy: serves WebRTC (evidence: `README.md`)
- WHEP proxy → Viewer / pilot: delivers video (evidence: `README.md`)
- UI coordinator → WS connection: initializes (evidence: `web/js/app.js`)
- UI coordinator → Drive controls: initializes (evidence: `web/js/app.js`)
- UI coordinator → Camera UI: initializes (evidence: `web/js/app.js`)
- UI coordinator → System settings UI: initializes (evidence: `web/js/app.js`)
- UI coordinator → Tilt UI: initializes (evidence: `web/js/app.js`)
- UI coordinator → Shared UI state: reads state (evidence: `web/js/app.js`)
- Drive controls → WS connection: sends commands (evidence: `web/js/controls.js`)
- Camera UI → Shared UI state: reads state (evidence: `web/js/camera.js`)
- System settings UI → WS connection: reconnects via (evidence: `web/js/system.js`)
- System settings UI → Shared UI state: reads state (evidence: `web/js/system.js`)
- Tilt UI → Shared UI state: updates state (evidence: `web/js/tilt.js`)
