# jetbrains/thinkrail architecture

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

- Interactive diagram: https://gitdiagram.com/jetbrains/thinkrail
- Repository: https://github.com/jetbrains/thinkrail

## Overview

ThinkRail is an agentic IDE built around the pi coding agent. The primary workflow is to open a project, work in an isolated workspace, chat with an agent that can use project tools, then inspect and review the resulting changes. The README also describes specs, skills, terminals, MCP, notifications, and native/browser delivery as important product capabilities. Several backend connections are documented rather than visible in the sampled source, so those edges cite the README; unsampled implementation details are not inferred.

Main entry points: [`apps/web/src/chat/ChatView.tsx`](https://github.com/jetbrains/thinkrail/blob/main/apps/web/src/chat/ChatView.tsx) (Agent chat), [`apps/web/src/panels`](https://github.com/jetbrains/thinkrail/tree/main/apps/web/src/panels) (Workspaces), [`packages/server/src/host/server.ts`](https://github.com/jetbrains/thinkrail/blob/main/packages/server/src/host/server.ts) (Host server), [`packages/server/src/agent/agentSessionManager.ts`](https://github.com/jetbrains/thinkrail/blob/main/packages/server/src/agent/agentSessionManager.ts) (Session manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workbench["IDE workbench"]
  node_shell["Workbench shell<br/>[Shell.tsx]"]
  node_workspace["Workspaces"]
  node_chat["Agent chat<br/>[ChatView.tsx]"]
  node_review["Changes review<br/>[ChangesPanel.tsx]"]
  node_renderers["Resource renderers<br/>[host.tsx]"]
  node_state["Client state<br/>[appStore.ts]"]
  node_transport["Host transport<br/>[wireTransport.ts]"]
end

subgraph group_agent["Agent runtime"]
  node_sessions["Session manager"]
  node_host["Host server<br/>[server.ts]"]
  node_persistence[("Project persistence<br/>[persistence.ts]")]
end

subgraph group_capabilities["Project capabilities"]
  node_terminal["Workspace terminals<br/>[terminalManager.ts]"]
  node_specs["Living specs<br/>[query.ts]"]
  node_delegation["Subagent delegation<br/>[service.ts]"]
  node_mcp["MCP tools<br/>[engine.ts]"]
  node_skills["Skills and workflows<br/>[index.ts]"]
  node_notifications["Attention notifications"]
end

subgraph group_delivery["App delivery"]
  node_desktop["Native desktop<br/>[index.ts]"]
  node_cli["Browser CLI<br/>[index.ts]"]
end

node_user(("Engineer"))
node_provider(("Model provider"))

node_user -->|"opens IDE"| node_shell
node_shell -->|"selects workspace"| node_workspace
node_workspace -->|"starts session"| node_chat
node_chat -->|"sends requests"| node_transport
node_transport -->|"calls host"| node_host
node_host -->|"routes sessions"| node_sessions
node_sessions -->|"runs agent"| node_provider
node_sessions -->|"stores session data"| node_persistence
node_workspace -->|"provides terminals"| node_terminal
node_workspace -->|"shows changes"| node_review
node_review -->|"renders diffs"| node_renderers
node_chat -->|"reads session state"| node_state
node_chat -->|"uses spec tools"| node_specs
node_chat -->|"delegates work"| node_delegation
node_chat -->|"calls MCP tools"| node_mcp
node_chat -->|"loads skills"| node_skills
node_chat -->|"signals attention"| node_notifications
node_user -->|"runs desktop app"| node_desktop
node_user -->|"launches browser app"| node_cli
node_desktop -->|"embeds engine host"| node_host
node_cli -->|"opens same host"| node_host

click node_shell "https://github.com/jetbrains/thinkrail/blob/main/apps/web/src/shell/Shell.tsx"
click node_workspace "https://github.com/jetbrains/thinkrail/tree/main/apps/web/src/panels"
click node_chat "https://github.com/jetbrains/thinkrail/blob/main/apps/web/src/chat/ChatView.tsx"
click node_review "https://github.com/jetbrains/thinkrail/blob/main/apps/web/src/panels/ChangesPanel.tsx"
click node_renderers "https://github.com/jetbrains/thinkrail/blob/main/packages/resource-renderers/src/host.tsx"
click node_state "https://github.com/jetbrains/thinkrail/blob/main/apps/web/src/store/appStore.ts"
click node_transport "https://github.com/jetbrains/thinkrail/blob/main/apps/web/src/transport/wireTransport.ts"
click node_sessions "https://github.com/jetbrains/thinkrail/blob/main/packages/server/src/agent/agentSessionManager.ts"
click node_host "https://github.com/jetbrains/thinkrail/blob/main/packages/server/src/host/server.ts"
click node_persistence "https://github.com/jetbrains/thinkrail/blob/main/packages/server/src/persistence/persistence.ts"
click node_terminal "https://github.com/jetbrains/thinkrail/blob/main/packages/server/src/terminal/terminalManager.ts"
click node_specs "https://github.com/jetbrains/thinkrail/blob/main/packages/spec-graph/core/query.ts"
click node_delegation "https://github.com/jetbrains/thinkrail/blob/main/packages/pi-delegation/src/service.ts"
click node_mcp "https://github.com/jetbrains/thinkrail/blob/main/packages/server/src/agent/mcp/engine.ts"
click node_skills "https://github.com/jetbrains/thinkrail/blob/main/packages/pi-thinkrail-workflow/index.ts"
click node_notifications "https://github.com/jetbrains/thinkrail/blob/main/apps/web/src/notifications/attentionNotificationEngine.ts"
click node_desktop "https://github.com/jetbrains/thinkrail/blob/main/apps/desktop/src/index.ts"
click node_cli "https://github.com/jetbrains/thinkrail/blob/main/apps/cli/src/index.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_shell,node_workspace,node_chat,node_review,node_renderers,node_state,node_transport toneBlue
class node_sessions,node_host,node_persistence toneAmber
class node_terminal,node_specs,node_delegation,node_mcp,node_skills,node_notifications toneMint
class node_desktop,node_cli toneRose
class node_user,node_provider toneIndigo
```

## Components

### IDE workbench

- [Workbench shell](https://github.com/jetbrains/thinkrail/blob/main/apps/web/src/shell/Shell.tsx): `apps/web/src/shell/Shell.tsx`
- [Workspaces](https://github.com/jetbrains/thinkrail/tree/main/apps/web/src/panels): `apps/web/src/panels`
- [Agent chat](https://github.com/jetbrains/thinkrail/blob/main/apps/web/src/chat/ChatView.tsx): `apps/web/src/chat/ChatView.tsx`
- [Changes review](https://github.com/jetbrains/thinkrail/blob/main/apps/web/src/panels/ChangesPanel.tsx): `apps/web/src/panels/ChangesPanel.tsx`
- [Resource renderers](https://github.com/jetbrains/thinkrail/blob/main/packages/resource-renderers/src/host.tsx): `packages/resource-renderers/src/host.tsx`
- [Client state](https://github.com/jetbrains/thinkrail/blob/main/apps/web/src/store/appStore.ts): `apps/web/src/store/appStore.ts`
- [Host transport](https://github.com/jetbrains/thinkrail/blob/main/apps/web/src/transport/wireTransport.ts): `apps/web/src/transport/wireTransport.ts`

### Agent runtime

- [Session manager](https://github.com/jetbrains/thinkrail/blob/main/packages/server/src/agent/agentSessionManager.ts): `packages/server/src/agent/agentSessionManager.ts`
- [Host server](https://github.com/jetbrains/thinkrail/blob/main/packages/server/src/host/server.ts): `packages/server/src/host/server.ts`
- [Project persistence](https://github.com/jetbrains/thinkrail/blob/main/packages/server/src/persistence/persistence.ts): `packages/server/src/persistence/persistence.ts`

### Project capabilities

- [Workspace terminals](https://github.com/jetbrains/thinkrail/blob/main/packages/server/src/terminal/terminalManager.ts): `packages/server/src/terminal/terminalManager.ts`
- [Living specs](https://github.com/jetbrains/thinkrail/blob/main/packages/spec-graph/core/query.ts): `packages/spec-graph/core/query.ts`
- [Subagent delegation](https://github.com/jetbrains/thinkrail/blob/main/packages/pi-delegation/src/service.ts): `packages/pi-delegation/src/service.ts`
- [MCP tools](https://github.com/jetbrains/thinkrail/blob/main/packages/server/src/agent/mcp/engine.ts): `packages/server/src/agent/mcp/engine.ts`
- [Skills and workflows](https://github.com/jetbrains/thinkrail/blob/main/packages/pi-thinkrail-workflow/index.ts): `packages/pi-thinkrail-workflow/index.ts`
- [Attention notifications](https://github.com/jetbrains/thinkrail/blob/main/apps/web/src/notifications/attentionNotificationEngine.ts): `apps/web/src/notifications/attentionNotificationEngine.ts`

### App delivery

- [Native desktop](https://github.com/jetbrains/thinkrail/blob/main/apps/desktop/src/index.ts): `apps/desktop/src/index.ts`
- [Browser CLI](https://github.com/jetbrains/thinkrail/blob/main/apps/cli/src/index.ts): `apps/cli/src/index.ts`

### Other components

- **Engineer**
- **Model provider**

## Connections

- Engineer → Workbench shell: opens IDE (evidence: `README.md`)
- Workbench shell → Workspaces: selects workspace (evidence: `README.md`)
- Workspaces → Agent chat: starts session (evidence: `README.md`)
- Agent chat → Host transport: sends requests (evidence: `README.md`)
- Host transport → Host server: calls host (evidence: `README.md`)
- Host server → Session manager: routes sessions (evidence: `README.md`)
- Session manager → Model provider: runs agent (evidence: `README.md`)
- Session manager → Project persistence: stores session data (evidence: `packages/server/src/agent/agentSessionManager.ts`)
- Workspaces → Workspace terminals: provides terminals (evidence: `README.md`)
- Workspaces → Changes review: shows changes (evidence: `README.md`)
- Changes review → Resource renderers: renders diffs
- Agent chat → Client state: reads session state
- Agent chat → Living specs: uses spec tools (evidence: `README.md`)
- Agent chat → Subagent delegation: delegates work (evidence: `README.md`)
- Agent chat → MCP tools: calls MCP tools (evidence: `README.md`)
- Agent chat → Skills and workflows: loads skills (evidence: `README.md`)
- Agent chat → Attention notifications: signals attention (evidence: `README.md`)
- Engineer → Native desktop: runs desktop app (evidence: `README.md`)
- Engineer → Browser CLI: launches browser app (evidence: `README.md`)
- Native desktop → Host server: embeds engine host (evidence: `README.md`)
- Browser CLI → Host server: opens same host (evidence: `README.md`)
