# tddworks/baguette architecture

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

- Interactive diagram: https://gitdiagram.com/tddworks/baguette
- Repository: https://github.com/tddworks/baguette

## Overview

Baguette is a macOS CLI and local web control plane for headless iOS simulators, with a companion path for physical-device streaming. Users boot and manage devices, inject input and simulated-world state, inspect accessibility and logs, and capture or stream results. The graph groups those user-facing workflows around simulator adapters and server routes. README capabilities fill in several unsampled branches; their paths are represented by existing feature modules, while uncertain internal call wiring is omitted.

Main entry points: [`Sources/Baguette/Infrastructure/Server/Server.swift`](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Infrastructure/Server/Server.swift) (HTTP and WS server), [`Sources/Baguette/App/Commands/BootCommand.swift`](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/App/Commands/BootCommand.swift) (Command handlers), [`Sources/Baguette/Infrastructure/Server/ServerDeviceTwinRoutes.swift`](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Infrastructure/Server/ServerDeviceTwinRoutes.swift) (Twin routes), [`Sources/Baguette/App/RootCommand.swift`](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/App/RootCommand.swift) (baguette CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry points"]
  node_cli["baguette CLI<br/>[RootCommand.swift]"]
  node_commands["Command handlers<br/>[BootCommand.swift]"]
end

subgraph group_devices["Simulator control"]
  node_simulators["Simulator lifecycle<br/>[Simulators.swift]"]
  node_sim_adapter["CoreSimulator adapter"]
  node_input["Input injection<br/>[Input.swift]"]
  node_accessibility["Accessibility inspection"]
  node_settings["Device settings<br/>[Interface.swift]"]
  node_world["Simulated world<br/>[Location.swift]"]
  node_camera["Camera session"]
  node_motion["Motion session"]
end

subgraph group_capture["Capture and rendering"]
  node_stream["Video streaming<br/>[Stream.swift]"]
  node_record["Screen recording"]
  node_render["3D rendering"]
end

subgraph group_web["Web control plane"]
  node_server["HTTP and WS server<br/>[Server.swift]"]
  node_webui["Simulator web UI<br/>[simulator.js]"]
  node_farm["Device farm<br/>[farm-app.js]"]
  node_plugins["Plugin system<br/>[Plugins.swift]"]
  node_apps["Apps and deep links<br/>[Apps.swift]"]
end

subgraph group_twin["Physical device twin"]
  node_twin_routes["Twin routes"]
  node_twin_session["Twin session<br/>[TwinSession.swift]"]
  node_twin_broadcast["Broadcast sender"]
  node_twin_transport["Twin transport"]
end

node_operator(("CLI operator"))
node_browser(("Browser user"))
node_companion(("Twin broadcast"))

node_operator -->|"runs commands"| node_cli
node_cli -->|"dispatches"| node_commands
node_commands -->|"manages devices"| node_simulators
node_simulators -->|"uses adapter"| node_sim_adapter
node_commands -->|"injects gestures"| node_input
node_commands -->|"reads tree"| node_accessibility
node_commands -->|"sets preferences"| node_settings
node_commands -->|"sets conditions"| node_world
node_commands -->|"starts capture"| node_camera
node_commands -->|"publishes motion"| node_motion
node_commands -->|"streams frames"| node_stream
node_commands -->|"records screen"| node_record
node_commands -->|"renders device"| node_render
node_operator -->|"starts service"| node_server
node_browser -->|"controls simulator"| node_webui
node_browser -->|"views devices"| node_farm
node_webui -->|"sends requests"| node_server
node_farm -->|"loads device views"| node_server
node_server -->|"dispatches input"| node_input
node_server -->|"serves inspection"| node_accessibility
node_server -->|"applies settings"| node_settings
node_server -->|"serves streams"| node_stream
node_server -->|"dispatches plugin actions"| node_plugins
node_server -->|"handles app actions"| node_apps
node_server -->|"registers twin routes"| node_twin_routes
node_companion -->|"starts broadcast"| node_twin_broadcast
node_twin_broadcast -->|"sends video"| node_twin_transport
node_twin_transport -->|"connects websocket"| node_twin_routes
node_twin_routes -->|"handles protocol"| node_twin_session
node_server -->|"captures recording"| node_record
node_server -->|"serves 3D render"| node_render

click node_cli "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/App/RootCommand.swift"
click node_commands "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/App/Commands/BootCommand.swift"
click node_simulators "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Simulator/Simulators.swift"
click node_sim_adapter "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Infrastructure/Simulator/CoreSimulators.swift"
click node_input "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Input/Input.swift"
click node_accessibility "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Accessibility/Accessibility.swift"
click node_settings "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Interface/Interface.swift"
click node_world "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Location/Location.swift"
click node_camera "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Camera/CameraSession.swift"
click node_motion "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Motion/MotionSession.swift"
click node_stream "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Stream/Stream.swift"
click node_record "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Recording/ScreenRecorder.swift"
click node_render "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Render/DeviceRenderer.swift"
click node_server "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Infrastructure/Server/Server.swift"
click node_webui "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Resources/Web/baguette/simulator.js"
click node_farm "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Resources/Web/farm/farm-app.js"
click node_plugins "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Plugin/Plugins.swift"
click node_apps "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Apps/Apps.swift"
click node_twin_routes "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Infrastructure/Server/ServerDeviceTwinRoutes.swift"
click node_twin_session "https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Device/TwinSession.swift"
click node_twin_broadcast "https://github.com/tddworks/baguette/blob/main/Companion/DeviceTwin/Broadcast/Sources/SampleHandler.swift"
click node_twin_transport "https://github.com/tddworks/baguette/blob/main/Companion/DeviceTwin/Wire/Sources/TwinTransport.swift"

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_cli,node_commands,node_browser toneBlue
class node_simulators,node_sim_adapter,node_input,node_accessibility,node_settings,node_world,node_camera,node_motion toneAmber
class node_stream,node_record,node_render toneMint
class node_server,node_webui,node_farm,node_plugins,node_apps toneRose
class node_twin_routes,node_twin_session,node_twin_broadcast,node_twin_transport,node_operator,node_companion toneIndigo
```

## Components

### User entry points

- [baguette CLI](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/App/RootCommand.swift): `Sources/Baguette/App/RootCommand.swift`
- [Command handlers](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/App/Commands/BootCommand.swift): `Sources/Baguette/App/Commands/BootCommand.swift`

### Simulator control

- [Simulator lifecycle](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Simulator/Simulators.swift): `Sources/Baguette/Domain/Simulator/Simulators.swift`
- [CoreSimulator adapter](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Infrastructure/Simulator/CoreSimulators.swift): `Sources/Baguette/Infrastructure/Simulator/CoreSimulators.swift`
- [Input injection](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Input/Input.swift): `Sources/Baguette/Domain/Input/Input.swift`
- [Accessibility inspection](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Accessibility/Accessibility.swift): `Sources/Baguette/Domain/Accessibility/Accessibility.swift`
- [Device settings](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Interface/Interface.swift): `Sources/Baguette/Domain/Interface/Interface.swift`
- [Simulated world](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Location/Location.swift): `Sources/Baguette/Domain/Location/Location.swift`
- [Camera session](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Camera/CameraSession.swift): `Sources/Baguette/Domain/Camera/CameraSession.swift`
- [Motion session](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Motion/MotionSession.swift): `Sources/Baguette/Domain/Motion/MotionSession.swift`

### Capture and rendering

- [Video streaming](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Stream/Stream.swift): `Sources/Baguette/Domain/Stream/Stream.swift`
- [Screen recording](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Recording/ScreenRecorder.swift): `Sources/Baguette/Domain/Recording/ScreenRecorder.swift`
- [3D rendering](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Render/DeviceRenderer.swift): `Sources/Baguette/Domain/Render/DeviceRenderer.swift`

### Web control plane

- [HTTP and WS server](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Infrastructure/Server/Server.swift): `Sources/Baguette/Infrastructure/Server/Server.swift`
- [Simulator web UI](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Resources/Web/baguette/simulator.js): `Sources/Baguette/Resources/Web/baguette/simulator.js`
- [Device farm](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Resources/Web/farm/farm-app.js): `Sources/Baguette/Resources/Web/farm/farm-app.js`
- [Plugin system](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Plugin/Plugins.swift): `Sources/Baguette/Domain/Plugin/Plugins.swift`
- [Apps and deep links](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Apps/Apps.swift): `Sources/Baguette/Domain/Apps/Apps.swift`

### Physical device twin

- [Twin routes](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Infrastructure/Server/ServerDeviceTwinRoutes.swift): `Sources/Baguette/Infrastructure/Server/ServerDeviceTwinRoutes.swift`
- [Twin session](https://github.com/tddworks/baguette/blob/main/Sources/Baguette/Domain/Device/TwinSession.swift): `Sources/Baguette/Domain/Device/TwinSession.swift`
- [Broadcast sender](https://github.com/tddworks/baguette/blob/main/Companion/DeviceTwin/Broadcast/Sources/SampleHandler.swift): `Companion/DeviceTwin/Broadcast/Sources/SampleHandler.swift`
- [Twin transport](https://github.com/tddworks/baguette/blob/main/Companion/DeviceTwin/Wire/Sources/TwinTransport.swift): `Companion/DeviceTwin/Wire/Sources/TwinTransport.swift`

### Other components

- **CLI operator**
- **Browser user**
- **Twin broadcast**

## Connections

- CLI operator → baguette CLI: runs commands
- baguette CLI → Command handlers: dispatches
- Command handlers → Simulator lifecycle: manages devices
- Simulator lifecycle → CoreSimulator adapter: uses adapter
- Command handlers → Input injection: injects gestures
- Command handlers → Accessibility inspection: reads tree
- Command handlers → Device settings: sets preferences
- Command handlers → Simulated world: sets conditions
- Command handlers → Camera session: starts capture
- Command handlers → Motion session: publishes motion
- Command handlers → Video streaming: streams frames
- Command handlers → Screen recording: records screen
- Command handlers → 3D rendering: renders device
- CLI operator → HTTP and WS server: starts service
- Browser user → Simulator web UI: controls simulator
- Browser user → Device farm: views devices
- Simulator web UI → HTTP and WS server: sends requests
- Device farm → HTTP and WS server: loads device views
- HTTP and WS server → Input injection: dispatches input
- HTTP and WS server → Accessibility inspection: serves inspection
- HTTP and WS server → Device settings: applies settings
- HTTP and WS server → Video streaming: serves streams
- HTTP and WS server → Plugin system: dispatches plugin actions
- HTTP and WS server → Apps and deep links: handles app actions
- HTTP and WS server → Twin routes: registers twin routes
- Twin broadcast → Broadcast sender: starts broadcast
- Broadcast sender → Twin transport: sends video
- Twin transport → Twin routes: connects websocket
- Twin routes → Twin session: handles protocol
- HTTP and WS server → Screen recording: captures recording
- HTTP and WS server → 3D rendering: serves 3D render
