# letta-ai/letta-code architecture

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

- Interactive diagram: https://gitdiagram.com/letta-ai/letta-code
- Repository: https://github.com/letta-ai/letta-code

## Overview

Letta Code is a stateful agent harness accessed through a terminal, desktop, browser, or messaging channel. A typical interaction enters through the CLI or a channel, reaches a local or Letta Cloud backend, and produces an agent response; agents can also use tools and subagents. Agent memory, identity, prompts, and skills support long-term adaptation, with MemFS providing Git-tracked context. The README documents major capabilities and entry points; sampled source excerpts are partial, so uncertain internal wiring is omitted.

Main entry points: [`src/agent/context.ts`](https://github.com/letta-ai/letta-code/blob/main/src/agent/context.ts) (Agent Runtime), [`src/backend/backend.ts`](https://github.com/letta-ai/letta-code/blob/main/src/backend/backend.ts) (Backend API), [`src/cli/App.tsx`](https://github.com/letta-ai/letta-code/blob/main/src/cli/App.tsx) (CLI), [`src/channels/service.ts`](https://github.com/letta-ai/letta-code/blob/main/src/channels/service.ts) (Messaging Channels)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_cli["CLI<br/>[App.tsx]"]
  node_channels["Messaging Channels<br/>[service.ts]"]
  node_channel_routes["Channel Routing<br/>[registry-routes.ts]"]
  node_browser_clients(("Browser &amp; Desktop"))
end

subgraph group_runtime["Agent Runtime"]
  node_agent_runtime["Agent Runtime<br/>[context.ts]"]
  node_backend["Backend API<br/>[backend.ts]"]
  node_local_backend["Local Backend<br/>[local-backend.ts]"]
end

subgraph group_state["Agent State"]
  node_memory["Memory &amp; Skills<br/>[memory.ts]"]
  node_memfs[("Git-Tracked Context<br/>[memory-git.ts]")]
  node_settings[("Settings &amp; Secrets")]
end

subgraph group_capabilities["Agent Capabilities"]
  node_tools["Tool Execution<br/>[manager.ts]"]
  node_subagents["Subagents<br/>[manager.ts]"]
  node_workflow["Workflows<br/>[workflow-engine.ts]"]
  node_search["Message Search<br/>[message-search.ts]"]
  node_schedules["Schedules<br/>[schedules.ts]"]
  node_hooks["Execution Hooks<br/>[writer.ts]"]
  node_mods["Mods<br/>[mod-engine.ts]"]
end

subgraph group_connectivity["Services"]
  node_cloud_service["Letta Cloud"]
  node_model_provider["Model Provider"]
  node_remote_computers["Remote Computers<br/>[environments.ts]"]
end

node_user(("User"))

node_user -->|"interacts"| node_cli
node_user -->|"messages"| node_channels
node_browser_clients -->|"accesses agents"| node_cloud_service
node_channels -->|"routes messages"| node_channel_routes
node_channel_routes -->|"creates conversations"| node_backend
node_cli -->|"requests agent turns"| node_backend
node_backend -->|"dispatches locally"| node_local_backend
node_backend -->|"dispatches remotely"| node_cloud_service
node_agent_runtime -->|"uses backend"| node_backend
node_agent_runtime -->|"requests inference"| node_model_provider
node_agent_runtime -->|"reads and updates"| node_memory
node_memory -->|"tracks context"| node_memfs
node_agent_runtime -->|"executes tools"| node_tools
node_tools -->|"launches agents"| node_subagents
node_workflow -->|"schedules calls"| node_subagents
node_agent_runtime -->|"searches messages"| node_search
node_agent_runtime -->|"configures schedules"| node_schedules
node_agent_runtime -->|"runs hooks"| node_hooks
node_agent_runtime -->|"loads extensions"| node_mods
node_cli -->|"reads configuration"| node_settings
node_backend -.->|"routes to computers"| node_remote_computers

click node_cli "https://github.com/letta-ai/letta-code/blob/main/src/cli/App.tsx"
click node_channels "https://github.com/letta-ai/letta-code/blob/main/src/channels/service.ts"
click node_channel_routes "https://github.com/letta-ai/letta-code/blob/main/src/channels/registry-routes.ts"
click node_agent_runtime "https://github.com/letta-ai/letta-code/blob/main/src/agent/context.ts"
click node_backend "https://github.com/letta-ai/letta-code/blob/main/src/backend/backend.ts"
click node_local_backend "https://github.com/letta-ai/letta-code/blob/main/src/backend/local/local-backend.ts"
click node_tools "https://github.com/letta-ai/letta-code/blob/main/src/tools/manager.ts"
click node_subagents "https://github.com/letta-ai/letta-code/blob/main/src/agent/subagents/manager.ts"
click node_workflow "https://github.com/letta-ai/letta-code/blob/main/src/tools/workflow/workflow-engine.ts"
click node_memory "https://github.com/letta-ai/letta-code/blob/main/src/agent/memory.ts"
click node_memfs "https://github.com/letta-ai/letta-code/blob/main/src/agent/memory-git.ts"
click node_settings "https://github.com/letta-ai/letta-code/blob/main/src/settings-manager.ts"
click node_search "https://github.com/letta-ai/letta-code/blob/main/src/backend/message-search.ts"
click node_schedules "https://github.com/letta-ai/letta-code/blob/main/src/backend/api/schedules.ts"
click node_hooks "https://github.com/letta-ai/letta-code/blob/main/src/hooks/writer.ts"
click node_mods "https://github.com/letta-ai/letta-code/blob/main/src/mods/mod-engine.ts"
click node_remote_computers "https://github.com/letta-ai/letta-code/blob/main/src/backend/api/environments.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_cli,node_channels,node_channel_routes,node_browser_clients,node_user toneBlue
class node_agent_runtime,node_backend,node_local_backend toneAmber
class node_memory,node_memfs,node_settings toneMint
class node_tools,node_subagents,node_workflow,node_search,node_schedules,node_hooks,node_mods toneRose
class node_cloud_service,node_model_provider,node_remote_computers toneIndigo
```

## Components

### User Interfaces

- [CLI](https://github.com/letta-ai/letta-code/blob/main/src/cli/App.tsx): `src/cli/App.tsx`
- [Messaging Channels](https://github.com/letta-ai/letta-code/blob/main/src/channels/service.ts): `src/channels/service.ts`
- [Channel Routing](https://github.com/letta-ai/letta-code/blob/main/src/channels/registry-routes.ts): `src/channels/registry-routes.ts`
- **Browser & Desktop**

### Agent Runtime

- [Agent Runtime](https://github.com/letta-ai/letta-code/blob/main/src/agent/context.ts): `src/agent/context.ts`
- [Backend API](https://github.com/letta-ai/letta-code/blob/main/src/backend/backend.ts): `src/backend/backend.ts`
- [Local Backend](https://github.com/letta-ai/letta-code/blob/main/src/backend/local/local-backend.ts): `src/backend/local/local-backend.ts`

### Agent State

- [Memory & Skills](https://github.com/letta-ai/letta-code/blob/main/src/agent/memory.ts): `src/agent/memory.ts`
- [Git-Tracked Context](https://github.com/letta-ai/letta-code/blob/main/src/agent/memory-git.ts): `src/agent/memory-git.ts`
- [Settings & Secrets](https://github.com/letta-ai/letta-code/blob/main/src/settings-manager.ts): `src/settings-manager.ts`

### Agent Capabilities

- [Tool Execution](https://github.com/letta-ai/letta-code/blob/main/src/tools/manager.ts): `src/tools/manager.ts`
- [Subagents](https://github.com/letta-ai/letta-code/blob/main/src/agent/subagents/manager.ts): `src/agent/subagents/manager.ts`
- [Workflows](https://github.com/letta-ai/letta-code/blob/main/src/tools/workflow/workflow-engine.ts): `src/tools/workflow/workflow-engine.ts`
- [Message Search](https://github.com/letta-ai/letta-code/blob/main/src/backend/message-search.ts): `src/backend/message-search.ts`
- [Schedules](https://github.com/letta-ai/letta-code/blob/main/src/backend/api/schedules.ts): `src/backend/api/schedules.ts`
- [Execution Hooks](https://github.com/letta-ai/letta-code/blob/main/src/hooks/writer.ts): `src/hooks/writer.ts`
- [Mods](https://github.com/letta-ai/letta-code/blob/main/src/mods/mod-engine.ts): `src/mods/mod-engine.ts`

### Services

- **Letta Cloud**
- **Model Provider**
- [Remote Computers](https://github.com/letta-ai/letta-code/blob/main/src/backend/api/environments.ts): `src/backend/api/environments.ts`

### Other components

- **User**

## Connections

- User → CLI: interacts
- User → Messaging Channels: messages
- Browser & Desktop → Letta Cloud: accesses agents
- Messaging Channels → Channel Routing: routes messages
- Channel Routing → Backend API: creates conversations
- CLI → Backend API: requests agent turns
- Backend API → Local Backend: dispatches locally
- Backend API → Letta Cloud: dispatches remotely
- Agent Runtime → Backend API: uses backend
- Agent Runtime → Model Provider: requests inference
- Agent Runtime → Memory & Skills: reads and updates
- Memory & Skills → Git-Tracked Context: tracks context
- Agent Runtime → Tool Execution: executes tools
- Tool Execution → Subagents: launches agents
- Workflows → Subagents: schedules calls
- Agent Runtime → Message Search: searches messages
- Agent Runtime → Schedules: configures schedules
- Agent Runtime → Execution Hooks: runs hooks
- Agent Runtime → Mods: loads extensions
- CLI → Settings & Secrets: reads configuration
- Backend API → Remote Computers: routes to computers
