# drawthingsai/local-code-community architecture

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

- Interactive diagram: https://gitdiagram.com/drawthingsai/local-code-community
- Repository: https://github.com/drawthingsai/local-code-community

## Overview

Local Code is a sandboxed AI coding and productivity agent for Apple devices. The main workflow starts with a user task in chat, passes through a model-specific agent and inference, then uses in-app tools on permitted project files to produce results. Separate capabilities include durable project history and context, built-in runtimes and browser access, and optional cloud-model use. The README documents these product relationships; sampled source excerpts are limited, so unsampled runtime connections are not asserted.

Main entry points: [`Apps/LocalCode/Sources/Agent/CodeAgent.swift`](https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/CodeAgent.swift) (Code agent), [`Apps/LocalCode/Sources/Agent/ToolsRegistry.swift`](https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/ToolsRegistry.swift) (Tool registry), [`Apps/LocalCode/Sources/Chat/ChatWorkflow.swift`](https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Chat/ChatWorkflow.swift) (Chat workflow), [`Apps/LocalCode/Sources/Agent/TextGenerator.swift`](https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/TextGenerator.swift) (Text generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Task interaction"]
  node_chat["Chat workflow<br/>[ChatWorkflow.swift]"]
end

subgraph group_agent["Agent runtime"]
  node_scheduler["Agent scheduler"]
  node_codeagent["Code agent<br/>[CodeAgent.swift]"]
  node_modelagents["Model harnesses"]
  node_registry["Tool registry"]
end

subgraph group_inference["Model inference"]
  node_textgen["Text generation"]
  node_coreml["On-device models"]
  node_remote["Remote agent"]
end

subgraph group_workspace["Workspace tools"]
  node_filetools["File tools<br/>[FileTools.swift]"]
  node_shelltools["Shell tools<br/>[BashTools.swift]"]
  node_sandbox["Built-in runtimes"]
  node_browser["Web browser"]
end

subgraph group_state["Context and history"]
  node_project["Project context"]
  node_memory["Long-term memory"]
  node_history[("Project history")]
end

node_user(("User"))
node_modelprovider{{"Cloud model providers"}}
node_projectfiles["Allowed project files"]

node_user -->|"submits task"| node_chat
node_chat -->|"starts work"| node_scheduler
node_scheduler -->|"runs agent"| node_codeagent
node_codeagent -->|"selects harness"| node_modelagents
node_modelagents -->|"requests inference"| node_textgen
node_textgen -->|"runs on-device"| node_coreml
node_textgen -.->|"supports remote"| node_remote
node_remote -.->|"sends prompts"| node_modelprovider
node_codeagent -->|"invokes tools"| node_registry
node_registry -->|"dispatches"| node_filetools
node_registry -->|"dispatches"| node_shelltools
node_shelltools -->|"uses runtimes"| node_sandbox
node_registry -->|"dispatches"| node_browser
node_filetools -->|"reads and writes"| node_projectfiles
node_codeagent -->|"uses context"| node_project
node_codeagent -->|"uses context"| node_memory
node_chat -->|"persists threads"| node_history

click node_chat "https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Chat/ChatWorkflow.swift"
click node_scheduler "https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/AgentScheduler.swift"
click node_codeagent "https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/CodeAgent.swift"
click node_modelagents "https://github.com/drawthingsai/local-code-community/tree/main/Apps/LocalCode/Sources/Agent"
click node_registry "https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/ToolsRegistry.swift"
click node_textgen "https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/TextGenerator.swift"
click node_coreml "https://github.com/drawthingsai/local-code-community/blob/main/Libraries/SwiftDiffusion/Sources/CoreMLModelManager/CoreMLModelManager.swift"
click node_remote "https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/RemoteAgentTranscriptAdapter.swift"
click node_filetools "https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/FileTools.swift"
click node_shelltools "https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/BashTools.swift"
click node_sandbox "https://github.com/drawthingsai/local-code-community/tree/main/Apps/LocalCode/Resources/NodeMobile/Runtime"
click node_browser "https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Browser/BrowserWorkflow.swift"
click node_project "https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/ProjectContext.swift"
click node_memory "https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/MemoryContext.swift"
click node_history "https://github.com/drawthingsai/local-code-community/blob/main/Libraries/ProjectHistoryManager/Sources/ProjectHistoryManager.swift"

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_chat,node_user toneBlue
class node_scheduler,node_codeagent,node_modelagents,node_registry toneAmber
class node_textgen,node_coreml,node_remote toneMint
class node_filetools,node_shelltools,node_sandbox,node_browser toneRose
class node_project,node_memory,node_history,node_modelprovider,node_projectfiles toneIndigo
```

## Components

### Task interaction

- [Chat workflow](https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Chat/ChatWorkflow.swift): `Apps/LocalCode/Sources/Chat/ChatWorkflow.swift`

### Agent runtime

- [Agent scheduler](https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/AgentScheduler.swift): `Apps/LocalCode/Sources/Agent/AgentScheduler.swift`
- [Code agent](https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/CodeAgent.swift): `Apps/LocalCode/Sources/Agent/CodeAgent.swift`
- [Model harnesses](https://github.com/drawthingsai/local-code-community/tree/main/Apps/LocalCode/Sources/Agent): `Apps/LocalCode/Sources/Agent`
- [Tool registry](https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/ToolsRegistry.swift): `Apps/LocalCode/Sources/Agent/ToolsRegistry.swift`

### Model inference

- [Text generation](https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/TextGenerator.swift): `Apps/LocalCode/Sources/Agent/TextGenerator.swift`
- [On-device models](https://github.com/drawthingsai/local-code-community/blob/main/Libraries/SwiftDiffusion/Sources/CoreMLModelManager/CoreMLModelManager.swift): `Libraries/SwiftDiffusion/Sources/CoreMLModelManager/CoreMLModelManager.swift`
- [Remote agent](https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/RemoteAgentTranscriptAdapter.swift): `Apps/LocalCode/Sources/Agent/RemoteAgentTranscriptAdapter.swift`

### Workspace tools

- [File tools](https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/FileTools.swift): `Apps/LocalCode/Sources/Agent/FileTools.swift`
- [Shell tools](https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/BashTools.swift): `Apps/LocalCode/Sources/Agent/BashTools.swift`
- [Built-in runtimes](https://github.com/drawthingsai/local-code-community/tree/main/Apps/LocalCode/Resources/NodeMobile/Runtime): `Apps/LocalCode/Resources/NodeMobile/Runtime`
- [Web browser](https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Browser/BrowserWorkflow.swift): `Apps/LocalCode/Sources/Browser/BrowserWorkflow.swift`

### Context and history

- [Project context](https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/ProjectContext.swift): `Apps/LocalCode/Sources/Agent/ProjectContext.swift`
- [Long-term memory](https://github.com/drawthingsai/local-code-community/blob/main/Apps/LocalCode/Sources/Agent/MemoryContext.swift): `Apps/LocalCode/Sources/Agent/MemoryContext.swift`
- [Project history](https://github.com/drawthingsai/local-code-community/blob/main/Libraries/ProjectHistoryManager/Sources/ProjectHistoryManager.swift): `Libraries/ProjectHistoryManager/Sources/ProjectHistoryManager.swift`

### Other components

- **User**
- **Cloud model providers**
- **Allowed project files**

## Connections

- User → Chat workflow: submits task (evidence: `README.md`)
- Chat workflow → Agent scheduler: starts work (evidence: `README.md`)
- Agent scheduler → Code agent: runs agent (evidence: `README.md`)
- Code agent → Model harnesses: selects harness (evidence: `README.md`)
- Model harnesses → Text generation: requests inference (evidence: `README.md`)
- Text generation → On-device models: runs on-device (evidence: `README.md`)
- Text generation → Remote agent: supports remote (evidence: `README.md`)
- Remote agent → Cloud model providers: sends prompts (evidence: `README.md`)
- Code agent → Tool registry: invokes tools (evidence: `README.md`)
- Tool registry → File tools: dispatches (evidence: `README.md`)
- Tool registry → Shell tools: dispatches (evidence: `README.md`)
- Shell tools → Built-in runtimes: uses runtimes (evidence: `README.md`)
- Tool registry → Web browser: dispatches (evidence: `README.md`)
- File tools → Allowed project files: reads and writes (evidence: `README.md`)
- Code agent → Project context: uses context (evidence: `README.md`)
- Code agent → Long-term memory: uses context (evidence: `README.md`)
- Chat workflow → Project history: persists threads (evidence: `README.md`)
