# m4raa/mage architecture

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

- Interactive diagram: https://gitdiagram.com/m4raa/mage
- Repository: https://github.com/m4raa/mage

## Overview

Mage is an Electron desktop workbench for managing and supervising coding-agent conversations; it does not normally supply the agent model. The user works in a multi-pane UI, starts a conversation with a provider, reviews permission requests, and can inspect or reopen transcripts. Separate branches cover accounts and usage, shared MCP configuration, browser tools, Git/worktrees, scheduled tasks, and artifacts. The README documents these capabilities; sampled source confirms key renderer and session responsibilities, but many runtime links are shown only at the product level.

Main entry points: [`src/renderer/src/App.tsx`](https://github.com/m4raa/mage/blob/main/src/renderer/src/App.tsx) (Workbench UI), [`src/renderer/src/workbench/engineBlocks.ts`](https://github.com/m4raa/mage/blob/main/src/renderer/src/workbench/engineBlocks.ts) (Permission review), [`src/main/engine/providerAdapter.ts`](https://github.com/m4raa/mage/blob/main/src/main/engine/providerAdapter.ts) (Provider adapters), [`src/renderer/src/workbench/tasks/ScheduledTasksView.tsx`](https://github.com/m4raa/mage/blob/main/src/renderer/src/workbench/tasks/ScheduledTasksView.tsx) (Scheduled tasks UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workbench["Desktop workbench"]
  node_renderer["Workbench UI<br/>[App.tsx]"]
  node_renderer_entry["Renderer entry<br/>[main.tsx]"]
  node_workbench_state["Workbench state<br/>[workbenchStore.ts]"]
  node_permission_ui["Permission review<br/>[engineBlocks.ts]"]
  node_tasks_ui["Scheduled tasks UI"]
end

subgraph group_agents["Agent execution"]
  node_session_manager["Session manager<br/>[sessionManager.ts]"]
  node_provider_adapter["Provider adapters<br/>[providerAdapter.ts]"]
  node_agent_cli["Agent CLIs"]
  node_own_runtime["OpenAI runtime<br/>[agentLoop.ts]"]
end

subgraph group_management["Conversation management"]
  node_accounts["Accounts and login<br/>[accountService.ts]"]
  node_usage["Usage tracking<br/>[usageService.ts]"]
  node_transcripts["Transcript history"]
  node_conversation_store[("Conversation storage")]
  node_tasks_main["Scheduled task service<br/>[taskService.ts]"]
end

subgraph group_extensions["Tools and integrations"]
  node_mcp_config["MCP configuration<br/>[mcpResolved.ts]"]
  node_mcp_server["MCP server<br/>[server.ts]"]
  node_browser["Browser tools<br/>[browserAgent.ts]"]
  node_git["Git and worktrees<br/>[gitService.ts]"]
  node_artifacts["Artifacts"]
end

node_user(("User"))

node_renderer_entry -->|"mounts"| node_renderer
node_user -->|"uses"| node_renderer
node_renderer -->|"reads state"| node_workbench_state
node_renderer -.->|"starts sessions"| node_session_manager
node_session_manager -.->|"resolves provider"| node_provider_adapter
node_provider_adapter -.->|"launches CLI"| node_agent_cli
node_provider_adapter -.->|"selects runtime"| node_own_runtime
node_agent_cli -.->|"requests approval"| node_permission_ui
node_own_runtime -.->|"requests approval"| node_permission_ui
node_renderer -->|"shows requests"| node_permission_ui
node_user -->|"approves actions"| node_permission_ui
node_user -->|"adds accounts"| node_accounts
node_accounts -.->|"tracks limits"| node_usage
node_renderer -.->|"browses history"| node_transcripts
node_transcripts -.->|"reads conversations"| node_conversation_store
node_user -->|"manages servers"| node_mcp_config
node_mcp_config -.->|"configures tools"| node_mcp_server
node_mcp_server -->|"exposes tools"| node_browser
node_user -->|"manages worktrees"| node_git
node_renderer -->|"opens tasks"| node_tasks_ui
node_tasks_ui -.->|"runs tasks"| node_tasks_main
node_user -->|"views artifacts"| node_artifacts

click node_renderer "https://github.com/m4raa/mage/blob/main/src/renderer/src/App.tsx"
click node_renderer_entry "https://github.com/m4raa/mage/blob/main/src/renderer/src/main.tsx"
click node_workbench_state "https://github.com/m4raa/mage/blob/main/src/renderer/src/workbench/workbenchStore.ts"
click node_session_manager "https://github.com/m4raa/mage/blob/main/src/main/engine/sessionManager.ts"
click node_provider_adapter "https://github.com/m4raa/mage/blob/main/src/main/engine/providerAdapter.ts"
click node_own_runtime "https://github.com/m4raa/mage/blob/main/src/main/runtime/agentLoop.ts"
click node_permission_ui "https://github.com/m4raa/mage/blob/main/src/renderer/src/workbench/engineBlocks.ts"
click node_accounts "https://github.com/m4raa/mage/blob/main/src/main/accounts/accountService.ts"
click node_usage "https://github.com/m4raa/mage/blob/main/src/main/usage/usageService.ts"
click node_transcripts "https://github.com/m4raa/mage/blob/main/src/main/transcripts/transcriptService.ts"
click node_conversation_store "https://github.com/m4raa/mage/blob/main/src/main/conversations/conversationsService.ts"
click node_mcp_config "https://github.com/m4raa/mage/blob/main/src/main/config/mcpResolved.ts"
click node_mcp_server "https://github.com/m4raa/mage/blob/main/src/main/mcpServer/server.ts"
click node_browser "https://github.com/m4raa/mage/blob/main/src/main/browser/browserAgent.ts"
click node_git "https://github.com/m4raa/mage/blob/main/src/main/git/gitService.ts"
click node_tasks_ui "https://github.com/m4raa/mage/blob/main/src/renderer/src/workbench/tasks/ScheduledTasksView.tsx"
click node_tasks_main "https://github.com/m4raa/mage/blob/main/src/main/tasks/taskService.ts"
click node_artifacts "https://github.com/m4raa/mage/blob/main/src/main/artifacts/artifactsService.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_renderer,node_renderer_entry,node_workbench_state,node_permission_ui,node_tasks_ui,node_user toneBlue
class node_session_manager,node_provider_adapter,node_agent_cli,node_own_runtime toneAmber
class node_accounts,node_usage,node_transcripts,node_conversation_store,node_tasks_main toneMint
class node_mcp_config,node_mcp_server,node_browser,node_git,node_artifacts toneRose
```

## Components

### Desktop workbench

- [Workbench UI](https://github.com/m4raa/mage/blob/main/src/renderer/src/App.tsx): `src/renderer/src/App.tsx`
- [Renderer entry](https://github.com/m4raa/mage/blob/main/src/renderer/src/main.tsx): `src/renderer/src/main.tsx`
- [Workbench state](https://github.com/m4raa/mage/blob/main/src/renderer/src/workbench/workbenchStore.ts): `src/renderer/src/workbench/workbenchStore.ts`
- [Permission review](https://github.com/m4raa/mage/blob/main/src/renderer/src/workbench/engineBlocks.ts): `src/renderer/src/workbench/engineBlocks.ts`
- [Scheduled tasks UI](https://github.com/m4raa/mage/blob/main/src/renderer/src/workbench/tasks/ScheduledTasksView.tsx): `src/renderer/src/workbench/tasks/ScheduledTasksView.tsx`

### Agent execution

- [Session manager](https://github.com/m4raa/mage/blob/main/src/main/engine/sessionManager.ts): `src/main/engine/sessionManager.ts`
- [Provider adapters](https://github.com/m4raa/mage/blob/main/src/main/engine/providerAdapter.ts): `src/main/engine/providerAdapter.ts`
- **Agent CLIs**
- [OpenAI runtime](https://github.com/m4raa/mage/blob/main/src/main/runtime/agentLoop.ts): `src/main/runtime/agentLoop.ts`

### Conversation management

- [Accounts and login](https://github.com/m4raa/mage/blob/main/src/main/accounts/accountService.ts): `src/main/accounts/accountService.ts`
- [Usage tracking](https://github.com/m4raa/mage/blob/main/src/main/usage/usageService.ts): `src/main/usage/usageService.ts`
- [Transcript history](https://github.com/m4raa/mage/blob/main/src/main/transcripts/transcriptService.ts): `src/main/transcripts/transcriptService.ts`
- [Conversation storage](https://github.com/m4raa/mage/blob/main/src/main/conversations/conversationsService.ts): `src/main/conversations/conversationsService.ts`
- [Scheduled task service](https://github.com/m4raa/mage/blob/main/src/main/tasks/taskService.ts): `src/main/tasks/taskService.ts`

### Tools and integrations

- [MCP configuration](https://github.com/m4raa/mage/blob/main/src/main/config/mcpResolved.ts): `src/main/config/mcpResolved.ts`
- [MCP server](https://github.com/m4raa/mage/blob/main/src/main/mcpServer/server.ts): `src/main/mcpServer/server.ts`
- [Browser tools](https://github.com/m4raa/mage/blob/main/src/main/browser/browserAgent.ts): `src/main/browser/browserAgent.ts`
- [Git and worktrees](https://github.com/m4raa/mage/blob/main/src/main/git/gitService.ts): `src/main/git/gitService.ts`
- [Artifacts](https://github.com/m4raa/mage/blob/main/src/main/artifacts/artifactsService.ts): `src/main/artifacts/artifactsService.ts`

### Other components

- **User**

## Connections

- Renderer entry → Workbench UI: mounts (evidence: `src/renderer/src/main.tsx`)
- User → Workbench UI: uses (evidence: `README.md`)
- Workbench UI → Workbench state: reads state (evidence: `src/renderer/src/App.tsx`)
- Workbench UI → Session manager: starts sessions
- Session manager → Provider adapters: resolves provider (evidence: `src/main/engine/sessionManager.ts`)
- Provider adapters → Agent CLIs: launches CLI
- Provider adapters → OpenAI runtime: selects runtime
- Agent CLIs → Permission review: requests approval
- OpenAI runtime → Permission review: requests approval
- Workbench UI → Permission review: shows requests (evidence: `src/renderer/src/App.tsx`)
- User → Permission review: approves actions (evidence: `README.md`)
- User → Accounts and login: adds accounts (evidence: `README.md`)
- Accounts and login → Usage tracking: tracks limits
- Workbench UI → Transcript history: browses history
- Transcript history → Conversation storage: reads conversations
- User → MCP configuration: manages servers (evidence: `README.md`)
- MCP configuration → MCP server: configures tools
- MCP server → Browser tools: exposes tools (evidence: `src/main/mcpServer/server.ts`)
- User → Git and worktrees: manages worktrees (evidence: `README.md`)
- Workbench UI → Scheduled tasks UI: opens tasks (evidence: `src/renderer/src/App.tsx`)
- Scheduled tasks UI → Scheduled task service: runs tasks
- User → Artifacts: views artifacts (evidence: `README.md`)
