# ndx707/localagent architecture

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

- Interactive diagram: https://gitdiagram.com/ndx707/localagent
- Repository: https://github.com/ndx707/localagent

## Overview

Local Agent Studio is a private, locally hosted chat and file-agent application. A user sends requests through the browser; the app consults a local llama.cpp model, handles proposed tool calls with approval for changes and terminal checks, and returns rendered replies. The server also provides conversation history, workspace-scoped file operations, and model-process controls. The excerpts show the server routes and some implementation details; several browser-to-server interactions and tool workflows are supported by the README rather than fully sampled source.

Main entry points: [`src/App.tsx`](https://github.com/ndx707/localagent/blob/main/src/App.tsx) (Chat interface), [`server/index.ts`](https://github.com/ndx707/localagent/blob/main/server/index.ts) (HTTP API), [`src/main.tsx`](https://github.com/ndx707/localagent/blob/main/src/main.tsx) (React entry), [`src/tools.ts`](https://github.com/ndx707/localagent/blob/main/src/tools.ts) (Agent tool schemas)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser experience"]
  node_app["Chat interface<br/>[App.tsx]"]
  node_entry["React entry<br/>[main.tsx]"]
  node_markdown["Markdown replies<br/>[App.tsx]"]
end

subgraph group_agent["Agent interaction"]
  node_approval["Tool approval<br/>[App.tsx]"]
  node_tooldefs["Agent tool schemas<br/>[tools.ts]"]
end

subgraph group_server["Local server"]
  node_api["HTTP API<br/>[index.ts]"]
  node_history[("Chat history<br/>[index.ts]")]
  node_completion["Model completion<br/>[index.ts]"]
  node_toolrunner["Tool execution<br/>[index.ts]"]
  node_launcher["Model launcher<br/>[index.ts]"]
end

subgraph group_local["Local resources"]
  node_workspace["Workspace files<br/>[index.ts]"]
  node_terminal["Approved checks<br/>[index.ts]"]
  node_model["llama.cpp server"]
end

node_user(("User"))

node_user -->|"requests work"| node_app
node_entry -->|"renders"| node_app
node_app -->|"renders replies"| node_markdown
node_app -->|"requests approval"| node_approval
node_app -->|"uses schemas"| node_tooldefs
node_app -->|"calls API"| node_api
node_api -->|"reads and writes"| node_history
node_api -->|"routes completion"| node_completion
node_completion -->|"sends completion"| node_model
node_api -->|"routes execution"| node_toolrunner
node_toolrunner -->|"operates on files"| node_workspace
node_toolrunner -->|"runs approved checks"| node_terminal
node_api -->|"handles controls"| node_launcher
node_launcher -->|"starts and stops"| node_model

click node_app "https://github.com/ndx707/localagent/blob/main/src/App.tsx"
click node_entry "https://github.com/ndx707/localagent/blob/main/src/main.tsx"
click node_markdown "https://github.com/ndx707/localagent/blob/main/src/App.tsx"
click node_approval "https://github.com/ndx707/localagent/blob/main/src/App.tsx"
click node_tooldefs "https://github.com/ndx707/localagent/blob/main/src/tools.ts"
click node_api "https://github.com/ndx707/localagent/blob/main/server/index.ts"
click node_history "https://github.com/ndx707/localagent/blob/main/server/index.ts"
click node_completion "https://github.com/ndx707/localagent/blob/main/server/index.ts"
click node_toolrunner "https://github.com/ndx707/localagent/blob/main/server/index.ts"
click node_workspace "https://github.com/ndx707/localagent/blob/main/server/index.ts"
click node_terminal "https://github.com/ndx707/localagent/blob/main/server/index.ts"
click node_launcher "https://github.com/ndx707/localagent/blob/main/server/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_app,node_entry,node_markdown,node_user toneBlue
class node_approval,node_tooldefs toneAmber
class node_api,node_history,node_completion,node_toolrunner,node_launcher toneMint
class node_workspace,node_terminal,node_model toneRose
```

## Components

### Browser experience

- [Chat interface](https://github.com/ndx707/localagent/blob/main/src/App.tsx): `src/App.tsx`
- [React entry](https://github.com/ndx707/localagent/blob/main/src/main.tsx): `src/main.tsx`
- [Markdown replies](https://github.com/ndx707/localagent/blob/main/src/App.tsx): `src/App.tsx`

### Agent interaction

- [Tool approval](https://github.com/ndx707/localagent/blob/main/src/App.tsx): `src/App.tsx`
- [Agent tool schemas](https://github.com/ndx707/localagent/blob/main/src/tools.ts): `src/tools.ts`

### Local server

- [HTTP API](https://github.com/ndx707/localagent/blob/main/server/index.ts): `server/index.ts`
- [Chat history](https://github.com/ndx707/localagent/blob/main/server/index.ts): `server/index.ts`
- [Model completion](https://github.com/ndx707/localagent/blob/main/server/index.ts): `server/index.ts`
- [Tool execution](https://github.com/ndx707/localagent/blob/main/server/index.ts): `server/index.ts`
- [Model launcher](https://github.com/ndx707/localagent/blob/main/server/index.ts): `server/index.ts`

### Local resources

- [Workspace files](https://github.com/ndx707/localagent/blob/main/server/index.ts): `server/index.ts`
- [Approved checks](https://github.com/ndx707/localagent/blob/main/server/index.ts): `server/index.ts`
- **llama.cpp server**

### Other components

- **User**

## Connections

- User → Chat interface: requests work (evidence: `README.md`)
- React entry → Chat interface: renders (evidence: `src/main.tsx`)
- Chat interface → Markdown replies: renders replies (evidence: `src/App.tsx`)
- Chat interface → Tool approval: requests approval (evidence: `src/App.tsx`)
- Chat interface → Agent tool schemas: uses schemas (evidence: `src/App.tsx`)
- Chat interface → HTTP API: calls API (evidence: `README.md`)
- HTTP API → Chat history: reads and writes (evidence: `server/index.ts`)
- HTTP API → Model completion: routes completion (evidence: `server/index.ts`)
- Model completion → llama.cpp server: sends completion (evidence: `server/index.ts`)
- HTTP API → Tool execution: routes execution (evidence: `server/index.ts`)
- Tool execution → Workspace files: operates on files (evidence: `server/index.ts`)
- Tool execution → Approved checks: runs approved checks (evidence: `README.md`)
- HTTP API → Model launcher: handles controls (evidence: `server/index.ts`)
- Model launcher → llama.cpp server: starts and stops (evidence: `server/index.ts`)
