# useshape/shape architecture

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

- Interactive diagram: https://gitdiagram.com/useshape/shape
- Repository: https://github.com/useshape/shape

## Overview

Shape is a desktop coding agent built with a React/Next.js frontend and a Tauri/Rust runtime. The user opens a project into the agent workspace, where chat, editing, preview, terminal, and Git tools support coding tasks; the frontend also exposes onboarding, settings, and a standalone Git manager. The README additionally highlights model choice and plugin integrations. Several capabilities are represented by tree paths but their runtime wiring was not sampled, so those links are marked unverified rather than asserted as calls.

Main entry points: [`app/client-layout.tsx`](https://github.com/useshape/shape/blob/main/app/client-layout.tsx) (Client shell), [`features/agent/layout.tsx`](https://github.com/useshape/shape/blob/main/features/agent/layout.tsx) (Agent workspace), [`src-tauri/src/agent/mod.rs`](https://github.com/useshape/shape/blob/main/src-tauri/src/agent/mod.rs) (Agent runtime), [`lib/backend/commands.ts`](https://github.com/useshape/shape/blob/main/lib/backend/commands.ts) (Backend bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App workflow"]
  node_client["Client shell<br/>[client-layout.tsx]"]
  node_main["Project host<br/>[main.tsx]"]
  node_gitroute["Git manager route<br/>[page.tsx]"]
  node_settings["Settings<br/>[settings.tsx]"]
end

subgraph group_work["Coding workspace"]
  node_agentlayout["Agent workspace<br/>[layout.tsx]"]
  node_editor["Code editor<br/>[editor.tsx]"]
  node_workspace["Workspace views<br/>[index.tsx]"]
  node_preview["Preview panel<br/>[preview-panel.tsx]"]
  node_terminal["Terminal<br/>[terminal.tsx]"]
  node_gitmanager["Git manager<br/>[git-manager.tsx]"]
end

subgraph group_agent["Agent capabilities"]
  node_chat["Chat session"]
  node_stream["Chat stream"]
  node_agentcore["Agent runtime<br/>[mod.rs]"]
  node_modelrouter["Model routing<br/>[model_router.rs]"]
end

subgraph group_platform["Desktop platform"]
  node_backend["Backend bridge<br/>[commands.ts]"]
  node_tauri["Tauri runtime<br/>[lib.rs]"]
end

subgraph group_account["Account integrations"]
  node_mcp["MCP integrations<br/>[client.rs]"]
  node_plugins["Plugin support<br/>[api.ts]"]
  node_cloud["Account services<br/>[store.ts]"]
end

node_user(("User"))
node_cloudapi["Shape API"]

node_user -.->|"opens app"| node_client
node_client -->|"renders"| node_main
node_main -->|"renders"| node_agentlayout
node_main -->|"uses commands"| node_backend
node_user -.->|"opens Git"| node_gitroute
node_gitroute -->|"renders"| node_gitmanager
node_agentlayout -.->|"hosts chat"| node_chat
node_chat -.->|"updates stream"| node_stream
node_agentlayout -.->|"hosts views"| node_workspace
node_workspace -.->|"shows editor"| node_editor
node_workspace -.->|"shows preview"| node_preview
node_agentlayout -.->|"hosts terminal"| node_terminal
node_gitmanager -->|"uses project state"| node_backend
node_backend -.->|"invokes desktop commands"| node_tauri
node_tauri -->|"registers runtime"| node_agentcore
node_agentcore -.->|"routes models"| node_modelrouter
node_agentcore -.->|"uses MCP"| node_mcp
node_agentcore -.->|"uses plugins"| node_plugins
node_client -.->|"hosts settings"| node_settings
node_client -->|"initializes account store"| node_cloud
node_cloud -->|"calls account API"| node_cloudapi
node_cloud -->|"persists tokens"| node_backend

click node_client "https://github.com/useshape/shape/blob/main/app/client-layout.tsx"
click node_main "https://github.com/useshape/shape/blob/main/components/layout/main.tsx"
click node_agentlayout "https://github.com/useshape/shape/blob/main/features/agent/layout.tsx"
click node_chat "https://github.com/useshape/shape/blob/main/features/chat/lib/use-chat-session.ts"
click node_stream "https://github.com/useshape/shape/blob/main/features/chat/lib/chat-stream-store.tsx"
click node_editor "https://github.com/useshape/shape/blob/main/features/editor/ui/main/editor.tsx"
click node_workspace "https://github.com/useshape/shape/blob/main/features/agent/workspace/index.tsx"
click node_preview "https://github.com/useshape/shape/blob/main/features/preview/ui/preview-panel.tsx"
click node_terminal "https://github.com/useshape/shape/blob/main/features/terminal/ui/terminal.tsx"
click node_gitroute "https://github.com/useshape/shape/blob/main/app/git/page.tsx"
click node_gitmanager "https://github.com/useshape/shape/blob/main/features/git/ui/manager/git-manager.tsx"
click node_settings "https://github.com/useshape/shape/blob/main/features/settings/ui/settings.tsx"
click node_backend "https://github.com/useshape/shape/blob/main/lib/backend/commands.ts"
click node_tauri "https://github.com/useshape/shape/blob/main/src-tauri/src/lib.rs"
click node_agentcore "https://github.com/useshape/shape/blob/main/src-tauri/src/agent/mod.rs"
click node_modelrouter "https://github.com/useshape/shape/blob/main/src-tauri/src/agent/model_router.rs"
click node_mcp "https://github.com/useshape/shape/blob/main/src-tauri/src/mcp/client.rs"
click node_plugins "https://github.com/useshape/shape/blob/main/lib/plugins/api.ts"
click node_cloud "https://github.com/useshape/shape/blob/main/lib/cloud/store.ts"

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_client,node_main,node_gitroute,node_settings,node_user toneBlue
class node_agentlayout,node_editor,node_workspace,node_preview,node_terminal,node_gitmanager toneAmber
class node_chat,node_stream,node_agentcore,node_modelrouter,node_cloudapi toneMint
class node_backend,node_tauri toneRose
class node_mcp,node_plugins,node_cloud toneIndigo
```

## Components

### App workflow

- [Client shell](https://github.com/useshape/shape/blob/main/app/client-layout.tsx): `app/client-layout.tsx`
- [Project host](https://github.com/useshape/shape/blob/main/components/layout/main.tsx): `components/layout/main.tsx`
- [Git manager route](https://github.com/useshape/shape/blob/main/app/git/page.tsx): `app/git/page.tsx`
- [Settings](https://github.com/useshape/shape/blob/main/features/settings/ui/settings.tsx): `features/settings/ui/settings.tsx`

### Coding workspace

- [Agent workspace](https://github.com/useshape/shape/blob/main/features/agent/layout.tsx): `features/agent/layout.tsx`
- [Code editor](https://github.com/useshape/shape/blob/main/features/editor/ui/main/editor.tsx): `features/editor/ui/main/editor.tsx`
- [Workspace views](https://github.com/useshape/shape/blob/main/features/agent/workspace/index.tsx): `features/agent/workspace/index.tsx`
- [Preview panel](https://github.com/useshape/shape/blob/main/features/preview/ui/preview-panel.tsx): `features/preview/ui/preview-panel.tsx`
- [Terminal](https://github.com/useshape/shape/blob/main/features/terminal/ui/terminal.tsx): `features/terminal/ui/terminal.tsx`
- [Git manager](https://github.com/useshape/shape/blob/main/features/git/ui/manager/git-manager.tsx): `features/git/ui/manager/git-manager.tsx`

### Agent capabilities

- [Chat session](https://github.com/useshape/shape/blob/main/features/chat/lib/use-chat-session.ts): `features/chat/lib/use-chat-session.ts`
- [Chat stream](https://github.com/useshape/shape/blob/main/features/chat/lib/chat-stream-store.tsx): `features/chat/lib/chat-stream-store.tsx`
- [Agent runtime](https://github.com/useshape/shape/blob/main/src-tauri/src/agent/mod.rs): `src-tauri/src/agent/mod.rs`
- [Model routing](https://github.com/useshape/shape/blob/main/src-tauri/src/agent/model_router.rs): `src-tauri/src/agent/model_router.rs`

### Desktop platform

- [Backend bridge](https://github.com/useshape/shape/blob/main/lib/backend/commands.ts): `lib/backend/commands.ts`
- [Tauri runtime](https://github.com/useshape/shape/blob/main/src-tauri/src/lib.rs): `src-tauri/src/lib.rs`

### Account integrations

- [MCP integrations](https://github.com/useshape/shape/blob/main/src-tauri/src/mcp/client.rs): `src-tauri/src/mcp/client.rs`
- [Plugin support](https://github.com/useshape/shape/blob/main/lib/plugins/api.ts): `lib/plugins/api.ts`
- [Account services](https://github.com/useshape/shape/blob/main/lib/cloud/store.ts): `lib/cloud/store.ts`

### Other components

- **User**
- **Shape API**

## Connections

- User → Client shell: opens app
- Client shell → Project host: renders (evidence: `app/client-layout.tsx`)
- Project host → Agent workspace: renders (evidence: `components/layout/main.tsx`)
- Project host → Backend bridge: uses commands (evidence: `components/layout/main.tsx`)
- User → Git manager route: opens Git
- Git manager route → Git manager: renders (evidence: `app/git/page.tsx`)
- Agent workspace → Chat session: hosts chat
- Chat session → Chat stream: updates stream
- Agent workspace → Workspace views: hosts views
- Workspace views → Code editor: shows editor
- Workspace views → Preview panel: shows preview
- Agent workspace → Terminal: hosts terminal
- Git manager → Backend bridge: uses project state (evidence: `features/git/ui/manager/git-manager.tsx`)
- Backend bridge → Tauri runtime: invokes desktop commands
- Tauri runtime → Agent runtime: registers runtime (evidence: `src-tauri/src/lib.rs`)
- Agent runtime → Model routing: routes models
- Agent runtime → MCP integrations: uses MCP
- Agent runtime → Plugin support: uses plugins
- Client shell → Settings: hosts settings
- Client shell → Account services: initializes account store (evidence: `app/client-layout.tsx`)
- Account services → Shape API: calls account API (evidence: `lib/cloud/store.ts`)
- Account services → Backend bridge: persists tokens (evidence: `lib/cloud/store.ts`)
