Carrot Web Reference
Structure reference for selfdrive/carrot.
System Shape
Runtime shape:
Main Entry Points
| Path |
Role |
carrot_server.py |
Starts aiohttp web server on port 7000. |
server/app.py |
Backend composition root. Creates app, runtime hubs, background tasks, routes. |
server/features/__init__.py |
Registers backend feature modules. |
server/config.py |
Shared backend paths and constants. |
web/index.html |
Single HTML shell containing all page sections and script/style load order. |
web/js/app.js |
Final frontend bootstrap and browser history restore. |
recovery/server.py |
Standalone recovery server on port 6999. |
Backend Tree
Backend Core Files
| Path |
Role |
server/app.py |
Creates aiohttp.Application, ClientSession, RealtimeBroker, CameraWsHub, RawWsHub, heartbeat task, git status task, route registration, static serving. |
server/config.py |
WEB_DIR, settings paths, state paths, dashcam paths, WebRTC URL, tmux session, backup paths. |
server/features/__init__.py |
Calls each feature module's register(app). |
server/live_runtime/broker.py |
Owns the realtime SubMaster broker used by /api/live_runtime. |
server/live_runtime/snapshot.py |
Builds live runtime snapshots for frontend polling. |
server/live_runtime/normalize.py |
Converts raw cereal/openpilot values into JSON-safe values. |
realtime/transports/camera_ws.py |
Camera frame WebSocket hub. |
realtime/transports/raw_ws.py |
Raw capnp WebSocket hub. |
Backend Services
| Path |
Used by |
Role |
services/params.py |
features/params.py, tools backup/restore |
Params read/write, bulk backup values. |
services/settings.py |
features/settings.py, static bootstrap |
carrot_settings.json cache and parsing. |
services/git_state.py |
tools, metadata |
Persisted git pull state such as last pull time. |
services/git_status.py |
features/tools/routes.py, startup loop |
Cached git fetch/status info for update badges. |
services/heartbeat.py |
server/app.py, features/system.py |
Heartbeat/register loop and status. |
services/device_info.py |
features/system.py |
Device network and calibration helpers. |
services/time_sync.py |
features/system.py |
Browser-to-device time sync. |
services/tmux.py |
features/terminal.py |
tmux session create, capture, input, clear. |
services/ssh_keys.py |
features/ssh_keys.py |
SSH key fetch/store helpers. |
services/setting_favorites.py |
features/setting_favorites.py |
Favorite setting names. |
services/setting_profiles.py |
features/setting_profiles.py |
Setting profile CRUD/import/export. |
services/web_settings.py |
features/web_settings.py |
Server-backed web settings. |
Backend Feature Routes
| Feature |
Main paths |
Files |
| Static/bootstrap |
/, static fallback |
features/static.py |
| WebRTC proxy |
/stream |
features/stream.py |
| Raw/camera WebSocket |
/ws/raw/{service}, /ws/raw_multiplex, /ws/camera/{camera} |
features/ws.py, realtime/transports/* |
| Settings |
/api/settings |
features/settings.py, services/settings.py |
| Params |
/api/params_bulk, /api/param_set, restore/backup/download endpoints |
features/params.py, services/params.py |
| Favorites |
/api/setting_favorites |
features/setting_favorites.py |
| Profiles |
/api/setting_profiles, import/export endpoints |
features/setting_profiles.py |
| Web settings |
/api/web_settings |
features/web_settings.py, services/web_settings.py |
| SSH keys |
/api/ssh_keys |
features/ssh_keys.py, services/ssh_keys.py |
| Cars |
/api/cars |
features/cars.py |
| System |
heartbeat, live runtime, reboot, poweroff, recalibrate, network, calibration |
features/system.py, services/device_info.py, services/heartbeat.py |
| Terminal |
/ws/terminal, /download/tmux.log |
features/terminal.py, services/tmux.py |
| Tools |
/api/tools, /api/tools/start, /api/tools/job, /api/tools/jobs, /api/tools/git_status |
features/tools/*, services/git_status.py |
| Dashcam |
/api/dashcam/* |
features/dashcam/* |
| Screenrecord |
/api/screenrecord/* |
features/screenrecord/* |
Tools Backend
| File |
Role |
actions.py |
Known tool action names and shell command allowlist. |
routes.py |
HTTP routes for sync actions, async jobs, job history, git status. |
jobs.py |
In-memory/persisted tool job state, log snapshots, async process helpers. |
dispatcher.py |
Actual action implementations: git pull/sync/reset, branch, logs, backup, reboot, install, shell command. |
Dashcam Backend
| File |
Role |
paths.py |
Dashcam filesystem paths. |
catalog.py |
Route/segment listing and metadata. |
ffmpeg.py |
Thumbnail/preview/video processing helpers. |
routes.py |
HTTP route registration and handlers. |
upload.py |
Upload request handling. |
upload_jobs.py |
Upload job state and progress. |
Screenrecord Backend
| File |
Role |
catalog.py |
Screenrecord file listing and metadata. |
routes.py |
HTTP route registration and handlers. |
Realtime Tree
| Path |
Role |
raw_services.py |
Raw cereal service list definitions. |
raw_protocol.py |
Raw capnp packet/protocol helpers. |
raw_runner.py |
Async raw stream runner. |
transports/camera_ws.py |
Camera stream lifecycle and WebSocket broadcasting. |
transports/raw_ws.py |
Raw service and multiplex WebSocket broadcasting. |
Frontend Tree
Frontend CSS
| Path |
Scope |
tokens.css |
Color, typography, motion, elevation, z-index tokens. |
layout_tokens.css |
Layout sizing and spacing variables. |
hud_card.css |
Drive HUD card. |
base.css |
Base reset, nav, global app chrome. |
layout.css |
Page containers, headers, common layout blocks. |
components.css |
Shared dialogs, buttons, chips, toasts, generic components. |
responsive.css |
Cross-page responsive adjustments loaded near the end. |
pages/drive.css |
Drive stage, video, overlay canvas, vision controls. |
pages/logs.css |
Logs, dashcam, screenrecord views. |
pages/terminal.css |
Terminal page. |
pages/settings/* |
Setting page split by base/panels/device. |
pages/tools/* |
Tools page split by base/QR/main notification layout. |
Frontend JavaScript
Shared JS
| Path |
Scope |
shared/api.js |
JSON API helpers and Params helpers. |
shared/dom.js |
Shared DOM references from index.html. |
shared/i18n.js |
Language state and UI text rendering. |
shared/utils.js |
String/HTML/copy/math helpers. |
shared/activity.js |
Cross-page activity state and nav badges. |
shared/setting_diff.js |
Setting diff rendering helpers. |
shared/ui/dialog.js |
App dialogs, prompts, confirms, toasts. |
shared/ui/navigation.js |
Page switching, nav state, transitions. |
shared/ui/viewport.js |
Viewport variables and Drive HUD layout sync. |
shared/ui/focus_trap.js |
Focus trapping for overlays. |
shared/ui/effects.js |
Shared pointer/visual effects. |
Page JS
| Path |
Scope |
pages/car.js |
Car picker, current car label, record state. |
pages/branch.js |
Branch page and branch picker modal. |
pages/setting.js |
CarrotPilot setting groups/items/search/favorites/profiles. |
pages/setting_device_config.js |
Device setting group definitions and option data. |
pages/setting_device_render.js |
Device setting row/panel rendering. |
pages/setting_device_network.js |
Device network refresh flow. |
pages/setting_device_actions.js |
Device setting action handlers. |
pages/setting_device.js |
Device tab coordinator and tab state. |
pages/tools.js |
Tools page state, metadata, action runner, button binding. |
pages/tools_notifications.js |
Tools log/notification card renderer. |
pages/tools_web_settings.js |
Web settings dialog and auto update setting. |
pages/tools_settings_qr.js |
Settings QR backup/restore UI. |
pages/logs/shared.js |
Logs tab state, player, lazy image helpers. |
pages/logs/dashcam.js |
Dashcam route/segment list, upload flow. |
pages/logs/screenrecord.js |
Screenrecord list and thumbnails. |
pages/terminal.js |
tmux WebSocket terminal UI. |
pages/vision_background.js |
Non-realtime page background state. |
Realtime JS
| Path |
Scope |
realtime/app_realtime.js |
Live runtime polling/raw stream wiring and HUD bridge. |
realtime/home_drive.js |
Drive/Carrot Vision renderer and overlay canvas. |
realtime/hud_card.js |
HUD card data rendering. |
realtime/raw_capnp.js |
Raw capnp decode entry. |
realtime/raw_capnp_worker.js |
Worker-side decode entry. |
realtime/vision_state.js |
Shared vision/HUD state object. |
realtime/vision_rtc.js |
WebRTC stream client. |
realtime/vision_raw.js |
Raw WebSocket client and worker bridge. |
HTML Page Sections
All primary pages live in web/index.html.
| Section ID |
Page |
pageCarrot |
Drive/Home |
pageSetting |
Setting |
pageTools |
Tools |
pageLogs |
Logs |
pageTerminal |
Terminal |
pageCar |
Car Select |
pageBranch |
Branch Select |
Common overlay/dialog hosts in index.html:
| ID |
Scope |
driveHudCard |
Shared Drive HUD card DOM. |
rtcVideo |
Shared RTC video element. |
appToastHost |
Toast host. |
appDialog |
Generic app dialog. |
appBranchPicker |
Branch picker modal. |
appCarPicker |
Car picker modal. |
Load Order Reference
CSS is loaded in web/index.html in this shape:
JavaScript is loaded in this shape:
Page Reference
| Page |
HTML |
JS |
CSS |
Backend |
| Drive/Home |
pageCarrot, driveHudCard, rtcVideo |
realtime/*, vision_background.js |
pages/drive.css, hud_card.css |
features/system.py, features/ws.py, features/stream.py, realtime/transports/* |
| Setting |
pageSetting |
setting.js, setting_device*.js, car.js |
pages/settings/* |
features/settings.py, features/params.py, features/system.py, features/setting_* |
| Tools |
pageTools |
tools.js, tools_notifications.js, tools_web_settings.js, tools_settings_qr.js, branch.js |
pages/tools/* |
features/tools/*, features/system.py, features/params.py, features/web_settings.py |
| Logs |
pageLogs |
pages/logs/shared.js, dashcam.js, screenrecord.js |
pages/logs.css |
features/dashcam/*, features/screenrecord/* |
| Terminal |
pageTerminal |
terminal.js |
pages/terminal.css |
features/terminal.py, services/tmux.py |
| Car Select |
pageCar, appCarPicker |
car.js |
layout.css, components.css |
features/cars.py, Params |
| Branch Select |
pageBranch, appBranchPicker |
branch.js |
components.css, pages/tools/* |
features/tools/* |
Feature Flow Reference
Drive / Home
Camera path:
Setting
Device tab:
Tools
Notification/log rendering:
Git status badge:
Logs
Dashcam upload:
Terminal
Branch / Git
Quick File Lookup
| Need |
File |
| Server startup |
carrot_server.py |
| App wiring |
server/app.py |
| Route registration |
server/features/__init__.py |
| Static/bootstrap payload |
server/features/static.py |
| Page HTML |
web/index.html |
| Page switching |
web/js/shared/ui/navigation.js |
| Final frontend boot |
web/js/app.js |
| API helpers |
web/js/shared/api.js |
| Dialogs/toasts |
web/js/shared/ui/dialog.js |
| Settings UI |
web/js/pages/setting.js |
| Device settings UI |
web/js/pages/setting_device*.js |
| Settings backend |
server/features/settings.py, server/features/params.py |
| Tools UI |
web/js/pages/tools.js |
| Tools notifications |
web/js/pages/tools_notifications.js |
| Tools backend routes |
server/features/tools/routes.py |
| Tools backend actions |
server/features/tools/dispatcher.py |
| Tool job state |
server/features/tools/jobs.py |
| Git status polling |
server/services/git_status.py |
| Drive realtime UI |
web/js/realtime/* |
| Drive backend data |
server/features/system.py, server/live_runtime/* |
| Raw WebSocket |
server/features/ws.py, realtime/transports/raw_ws.py |
| Camera WebSocket |
realtime/transports/camera_ws.py |
| Logs UI |
web/js/pages/logs/* |
| Dashcam backend |
server/features/dashcam/* |
| Screenrecord backend |
server/features/screenrecord/* |
| Terminal UI/backend |
web/js/pages/terminal.js, server/features/terminal.py |
| Recovery server |
recovery/server.py |