# rohansx/workz architecture

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

- Interactive diagram: https://gitdiagram.com/rohansx/workz
- Repository: https://github.com/rohansx/workz

## Overview

workz is a Rust CLI that provisions agent-created Git worktrees so they can run independently. The principal workflow is setup/configuration, worktree creation, dependency and environment synchronization, then optional port/database/Compose isolation; `run` starts a dev server and `preview` reports live worktrees. The CLI also provides lifecycle, diagnostics, hook, and MCP capabilities. Edges reflect README-documented behavior and visible source references; unsampled command-handler details are not inferred.

Main entry points: [`src/main.rs`](https://github.com/rohansx/workz/blob/main/src/main.rs) (Command dispatcher), [`src/isolation.rs`](https://github.com/rohansx/workz/blob/main/src/isolation.rs) (Isolation setup), [`src/mcp.rs`](https://github.com/rohansx/workz/blob/main/src/mcp.rs) (MCP server), [`src/doctor.rs`](https://github.com/rohansx/workz/blob/main/src/doctor.rs) (Diagnostics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and integration"]
  node_cli["CLI commands<br/>[cli.rs]"]
  node_dispatcher["Command dispatcher<br/>[main.rs]"]
  node_hook["Hook recipes<br/>[hook.rs]"]
  node_mcp["MCP server<br/>[mcp.rs]"]
end

subgraph group_provision["Worktree provisioning"]
  node_init["Setup wizard<br/>[init.rs]"]
  node_config["Configuration<br/>[config.rs]"]
  node_git["Git worktrees<br/>[git.rs]"]
  node_sync["Worktree sync<br/>[sync.rs]"]
end

subgraph group_isolation["Environment isolation"]
  node_isolation["Isolation setup<br/>[isolation.rs]"]
  node_portregistry[("Port registry<br/>[isolation.rs]")]
end

subgraph group_runtime["Runtime and operations"]
  node_doctor["Diagnostics<br/>[doctor.rs]"]
  node_run["Dev server runner<br/>[run.rs]"]
  node_status["Lifecycle and status<br/>[main.rs]"]
end

node_user(("Developer or agent"))
node_host(("Editor or agent host"))
node_postgres["Postgres or Docker"]

node_user -->|"invokes"| node_cli
node_cli -->|"dispatches"| node_dispatcher
node_dispatcher -->|"runs setup"| node_init
node_init -->|"writes config"| node_config
node_dispatcher -->|"creates worktree"| node_git
node_dispatcher -->|"provisions worktree"| node_sync
node_sync -->|"reads settings"| node_config
node_dispatcher -->|"sets isolation"| node_isolation
node_isolation -->|"reads settings"| node_config
node_isolation -->|"tracks allocations"| node_portregistry
node_isolation -->|"creates or drops DB"| node_postgres
node_dispatcher -->|"starts server"| node_run
node_run -->|"reads allocation"| node_portregistry
node_dispatcher -->|"runs diagnostics"| node_doctor
node_doctor -->|"checks worktrees"| node_git
node_doctor -->|"checks allocations"| node_isolation
node_dispatcher -->|"lists and cleans"| node_status
node_host -->|"requests recipe"| node_hook
node_hook -->|"configures hook"| node_dispatcher
node_host -->|"sends requests"| node_mcp
node_mcp -->|"lists worktrees"| node_git
node_mcp -->|"provisions worktree"| node_sync
node_mcp -->|"sets isolation"| node_isolation

click node_cli "https://github.com/rohansx/workz/blob/main/src/cli.rs"
click node_dispatcher "https://github.com/rohansx/workz/blob/main/src/main.rs"
click node_hook "https://github.com/rohansx/workz/blob/main/src/hook.rs"
click node_mcp "https://github.com/rohansx/workz/blob/main/src/mcp.rs"
click node_init "https://github.com/rohansx/workz/blob/main/src/init.rs"
click node_config "https://github.com/rohansx/workz/blob/main/src/config.rs"
click node_git "https://github.com/rohansx/workz/blob/main/src/git.rs"
click node_sync "https://github.com/rohansx/workz/blob/main/src/sync.rs"
click node_isolation "https://github.com/rohansx/workz/blob/main/src/isolation.rs"
click node_portregistry "https://github.com/rohansx/workz/blob/main/src/isolation.rs"
click node_doctor "https://github.com/rohansx/workz/blob/main/src/doctor.rs"
click node_run "https://github.com/rohansx/workz/blob/main/src/run.rs"
click node_status "https://github.com/rohansx/workz/blob/main/src/main.rs"

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_dispatcher,node_hook,node_mcp toneBlue
class node_init,node_config,node_git,node_sync,node_postgres toneAmber
class node_isolation,node_portregistry toneMint
class node_doctor,node_run,node_status toneRose
class node_user,node_host toneIndigo
```

## Components

### CLI and integration

- [CLI commands](https://github.com/rohansx/workz/blob/main/src/cli.rs): `src/cli.rs`
- [Command dispatcher](https://github.com/rohansx/workz/blob/main/src/main.rs): `src/main.rs`
- [Hook recipes](https://github.com/rohansx/workz/blob/main/src/hook.rs): `src/hook.rs`
- [MCP server](https://github.com/rohansx/workz/blob/main/src/mcp.rs): `src/mcp.rs`

### Worktree provisioning

- [Setup wizard](https://github.com/rohansx/workz/blob/main/src/init.rs): `src/init.rs`
- [Configuration](https://github.com/rohansx/workz/blob/main/src/config.rs): `src/config.rs`
- [Git worktrees](https://github.com/rohansx/workz/blob/main/src/git.rs): `src/git.rs`
- [Worktree sync](https://github.com/rohansx/workz/blob/main/src/sync.rs): `src/sync.rs`

### Environment isolation

- [Isolation setup](https://github.com/rohansx/workz/blob/main/src/isolation.rs): `src/isolation.rs`
- [Port registry](https://github.com/rohansx/workz/blob/main/src/isolation.rs): `src/isolation.rs`

### Runtime and operations

- [Diagnostics](https://github.com/rohansx/workz/blob/main/src/doctor.rs): `src/doctor.rs`
- [Dev server runner](https://github.com/rohansx/workz/blob/main/src/run.rs): `src/run.rs`
- [Lifecycle and status](https://github.com/rohansx/workz/blob/main/src/main.rs): `src/main.rs`

### Other components

- **Developer or agent**
- **Editor or agent host**
- **Postgres or Docker**

## Connections

- Developer or agent → CLI commands: invokes (evidence: `README.md`)
- CLI commands → Command dispatcher: dispatches (evidence: `README.md`)
- Command dispatcher → Setup wizard: runs setup (evidence: `README.md`)
- Setup wizard → Configuration: writes config (evidence: `src/init.rs`)
- Command dispatcher → Git worktrees: creates worktree (evidence: `README.md`)
- Command dispatcher → Worktree sync: provisions worktree (evidence: `README.md`)
- Worktree sync → Configuration: reads settings (evidence: `src/sync.rs`)
- Command dispatcher → Isolation setup: sets isolation (evidence: `README.md`)
- Isolation setup → Configuration: reads settings (evidence: `src/isolation.rs`)
- Isolation setup → Port registry: tracks allocations (evidence: `src/isolation.rs`)
- Isolation setup → Postgres or Docker: creates or drops DB (evidence: `README.md`)
- Command dispatcher → Dev server runner: starts server (evidence: `README.md`)
- Dev server runner → Port registry: reads allocation (evidence: `src/run.rs`)
- Command dispatcher → Diagnostics: runs diagnostics (evidence: `README.md`)
- Diagnostics → Git worktrees: checks worktrees (evidence: `src/doctor.rs`)
- Diagnostics → Isolation setup: checks allocations (evidence: `src/doctor.rs`)
- Command dispatcher → Lifecycle and status: lists and cleans (evidence: `README.md`)
- Editor or agent host → Hook recipes: requests recipe (evidence: `README.md`)
- Hook recipes → Command dispatcher: configures hook (evidence: `src/hook.rs`)
- Editor or agent host → MCP server: sends requests (evidence: `src/mcp.rs`)
- MCP server → Git worktrees: lists worktrees (evidence: `src/mcp.rs`)
- MCP server → Worktree sync: provisions worktree (evidence: `src/mcp.rs`)
- MCP server → Isolation setup: sets isolation (evidence: `src/mcp.rs`)
