# wdauwen/picar architecture

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

- Interactive diagram: https://gitdiagram.com/wdauwen/picar
- Repository: https://github.com/wdauwen/picar

## Overview

This repository combines two Raspberry Pi applications: a camera web interface for live viewing, camera control, recording, media management, and scheduling; and a separate WebSocket-controlled robot. The camera workflow runs from the browser interface through PHP command/status endpoints to the camera runtime, while media and scheduling are separate capabilities. The robot workflow maps WebSocket commands to GPIO motor actions. Several camera runtime connections are inferred only from filenames and configuration, so they are omitted or marked unverified.

Main entry points: [`RPi_Cam_Web_Interface/bin/raspimjpeg`](https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/bin/raspimjpeg) (Camera Daemon), [`RPi_Cam_Web_Interface/www/index.php`](https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/index.php) (Live Camera Page), [`RPi_Cam_Web_Interface/www/js/script.js`](https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/js/script.js) (Browser Controls), [`server.py`](https://github.com/wdauwen/picar/blob/master/server.py) (Robot WebSocket Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_camera_ui["Camera Web Interface"]
  node_camera_page["Live Camera Page<br/>[index.php]"]
  node_camera_controls["Browser Controls<br/>[script.js]"]
  node_camera_config["Camera Configuration<br/>[config.php]"]
  node_camera_commands["Command Endpoint<br/>[cmd_pipe.php]"]
  node_camera_status["Status Endpoint<br/>[status_mjpeg.php]"]
  node_camera_image["Image Endpoint<br/>[cam_pic.php]"]
end

subgraph group_camera_runtime["Camera Runtime"]
  node_camera_mjpeg["Camera Daemon"]
  node_camera_daemon_config["Daemon Configuration"]
end

subgraph group_camera_media["Media and Scheduling"]
  node_media_library["Media Browser<br/>[preview.php]"]
  node_schedule_manager["Schedule Manager<br/>[schedule.php]"]
  node_motion_controls["Motion Controls<br/>[motion.php]"]
  node_media_files[("Captured Media")]
end

subgraph group_robot_control["Robot Control"]
  node_robot_server["Robot WebSocket Server<br/>[server.py]"]
  node_robot_page["Robot Control Page<br/>[index.html]"]
  node_robot_gpio["GPIO Motor Actions<br/>[robot3.py]"]
end

node_camera_user(("Camera User"))
node_robot_user(("Robot Operator"))

node_camera_user -->|"opens"| node_camera_page
node_camera_page -->|"loads"| node_camera_config
node_camera_user -->|"uses"| node_camera_controls
node_camera_controls -->|"sends commands"| node_camera_commands
node_camera_controls -->|"polls status"| node_camera_status
node_camera_page -->|"requests image"| node_camera_image
node_camera_commands -.->|"dispatches commands"| node_camera_mjpeg
node_camera_status -.->|"reads status"| node_camera_mjpeg
node_camera_mjpeg -.->|"writes captures"| node_media_files
node_camera_page -.->|"streams preview"| node_camera_mjpeg
node_camera_mjpeg -.->|"uses settings"| node_camera_daemon_config
node_camera_user -->|"manages recordings"| node_media_library
node_media_library -->|"reads and manages"| node_media_files
node_camera_user -->|"configures schedule"| node_schedule_manager
node_schedule_manager -->|"purges files"| node_media_files
node_camera_user -->|"configures motion"| node_motion_controls
node_robot_user -->|"sends commands"| node_robot_server
node_robot_server -->|"renders page"| node_robot_page
node_robot_server -->|"dispatches actions"| node_robot_gpio

click node_camera_page "https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/index.php"
click node_camera_controls "https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/js/script.js"
click node_camera_config "https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/config.php"
click node_camera_commands "https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/cmd_pipe.php"
click node_camera_status "https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/status_mjpeg.php"
click node_camera_image "https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/cam_pic.php"
click node_camera_mjpeg "https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/bin/raspimjpeg"
click node_camera_daemon_config "https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/etc/raspimjpeg/raspimjpeg"
click node_media_library "https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/preview.php"
click node_schedule_manager "https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/schedule.php"
click node_motion_controls "https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/motion.php"
click node_media_files "https://github.com/wdauwen/picar/tree/master/RPi_Cam_Web_Interface/www"
click node_robot_server "https://github.com/wdauwen/picar/blob/master/server.py"
click node_robot_page "https://github.com/wdauwen/picar/blob/master/index.html"
click node_robot_gpio "https://github.com/wdauwen/picar/blob/master/robotics/robot3.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_camera_page,node_camera_controls,node_camera_config,node_camera_commands,node_camera_status,node_camera_image,node_camera_user toneBlue
class node_camera_mjpeg,node_camera_daemon_config toneAmber
class node_media_library,node_schedule_manager,node_motion_controls,node_media_files toneMint
class node_robot_server,node_robot_page,node_robot_gpio toneRose
class node_robot_user toneIndigo
```

## Components

### Camera Web Interface

- [Live Camera Page](https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/index.php): `RPi_Cam_Web_Interface/www/index.php`
- [Browser Controls](https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/js/script.js): `RPi_Cam_Web_Interface/www/js/script.js`
- [Camera Configuration](https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/config.php): `RPi_Cam_Web_Interface/www/config.php`
- [Command Endpoint](https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/cmd_pipe.php): `RPi_Cam_Web_Interface/www/cmd_pipe.php`
- [Status Endpoint](https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/status_mjpeg.php): `RPi_Cam_Web_Interface/www/status_mjpeg.php`
- [Image Endpoint](https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/cam_pic.php): `RPi_Cam_Web_Interface/www/cam_pic.php`

### Camera Runtime

- [Camera Daemon](https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/bin/raspimjpeg): `RPi_Cam_Web_Interface/bin/raspimjpeg`
- [Daemon Configuration](https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/etc/raspimjpeg/raspimjpeg): `RPi_Cam_Web_Interface/etc/raspimjpeg/raspimjpeg`

### Media and Scheduling

- [Media Browser](https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/preview.php): `RPi_Cam_Web_Interface/www/preview.php`
- [Schedule Manager](https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/schedule.php): `RPi_Cam_Web_Interface/www/schedule.php`
- [Motion Controls](https://github.com/wdauwen/picar/blob/master/RPi_Cam_Web_Interface/www/motion.php): `RPi_Cam_Web_Interface/www/motion.php`
- [Captured Media](https://github.com/wdauwen/picar/tree/master/RPi_Cam_Web_Interface/www): `RPi_Cam_Web_Interface/www`

### Robot Control

- [Robot WebSocket Server](https://github.com/wdauwen/picar/blob/master/server.py): `server.py`
- [Robot Control Page](https://github.com/wdauwen/picar/blob/master/index.html): `index.html`
- [GPIO Motor Actions](https://github.com/wdauwen/picar/blob/master/robotics/robot3.py): `robotics/robot3.py`

### Other components

- **Camera User**
- **Robot Operator**

## Connections

- Camera User → Live Camera Page: opens
- Live Camera Page → Camera Configuration: loads (evidence: `RPi_Cam_Web_Interface/www/index.php`)
- Camera User → Browser Controls: uses
- Browser Controls → Command Endpoint: sends commands (evidence: `RPi_Cam_Web_Interface/www/js/script.js`)
- Browser Controls → Status Endpoint: polls status (evidence: `RPi_Cam_Web_Interface/www/js/script.js`)
- Live Camera Page → Image Endpoint: requests image (evidence: `RPi_Cam_Web_Interface/www/index.php`)
- Command Endpoint → Camera Daemon: dispatches commands
- Status Endpoint → Camera Daemon: reads status
- Camera Daemon → Captured Media: writes captures
- Live Camera Page → Camera Daemon: streams preview
- Camera Daemon → Daemon Configuration: uses settings
- Camera User → Media Browser: manages recordings
- Media Browser → Captured Media: reads and manages (evidence: `RPi_Cam_Web_Interface/www/preview.php`)
- Camera User → Schedule Manager: configures schedule
- Schedule Manager → Captured Media: purges files (evidence: `RPi_Cam_Web_Interface/www/schedule.php`)
- Camera User → Motion Controls: configures motion
- Robot Operator → Robot WebSocket Server: sends commands
- Robot WebSocket Server → Robot Control Page: renders page (evidence: `server.py`)
- Robot WebSocket Server → GPIO Motor Actions: dispatches actions (evidence: `server.py`)
