# sunilgentyala/laptopai-agent architecture

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

- Interactive diagram: https://gitdiagram.com/sunilgentyala/laptopai-agent
- Repository: https://github.com/sunilgentyala/laptopai-agent

## Overview

LaptopAI-Agent is a local laptop-management assistant with CLI and MCP entry points. Its primary workflow takes a user query through a LangGraph/Ollama reasoning loop, invokes guarded system or knowledge tools, and returns a response; tool activity is recorded in a chained audit log. Separate CLI workflows ingest documents, verify audit integrity, and clean browser history. The README also documents MCP research-analysis and SignalTrim tools. Their detailed handlers are not fully excerpted, so those capabilities are represented within the MCP surface without asserting unsampled internals.

Main entry points: [`src/mcp/server.py`](https://github.com/sunilgentyala/laptopai-agent/blob/master/src/mcp/server.py) (MCP Server), [`main.py`](https://github.com/sunilgentyala/laptopai-agent/blob/master/main.py) (CLI Commands), [`src/agent/tools.py`](https://github.com/sunilgentyala/laptopai-agent/blob/master/src/agent/tools.py) (System Tools), [`src/privacy/history_cleaner.py`](https://github.com/sunilgentyala/laptopai-agent/blob/master/src/privacy/history_cleaner.py) (History Cleaner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User Entry"]
  node_cli["CLI Commands<br/>[main.py]"]
  node_mcp["MCP Server<br/>[server.py]"]
end

subgraph group_agent["Agent Runtime"]
  node_reasoner["Agent Loop<br/>[graph.py]"]
  node_tools["System Tools<br/>[tools.py]"]
  node_ollama["Local Ollama"]
end

subgraph group_knowledge["Local Knowledge"]
  node_rag["Knowledge Base<br/>[knowledge_base.py]"]
  node_chroma[("ChromaDB Store")]
end

subgraph group_security["Security"]
  node_guard["Permission Guard<br/>[permissions.py]"]
  node_audit[("Chained Audit Log<br/>[audit.py]")]
end

subgraph group_privacy["Privacy Hygiene"]
  node_history["History Cleaner<br/>[history_cleaner.py]"]
  node_browser_data[("Browser Profiles")]
end

node_user(("User"))
node_mcp_client(("MCP Client"))
node_signaltrim["SignalTrim"]

node_user -->|"submits query"| node_cli
node_cli -->|"runs chat"| node_reasoner
node_reasoner -->|"invokes model"| node_ollama
node_reasoner -->|"dispatches tools"| node_tools
node_tools -->|"queries knowledge"| node_rag
node_tools -->|"checks access"| node_guard
node_tools -->|"records actions"| node_audit
node_cli -->|"ingests documents"| node_rag
node_rag -->|"stores and searches"| node_chroma
node_mcp_client -->|"calls tools"| node_mcp
node_mcp -->|"queries knowledge"| node_rag
node_mcp -->|"checks access"| node_guard
node_mcp -->|"records actions"| node_audit
node_cli -->|"verifies chain"| node_audit
node_cli -->|"runs cleanup"| node_history
node_mcp -->|"runs cleanup"| node_history
node_history -->|"backs up and clears"| node_browser_data
node_history -->|"records run"| node_audit
node_mcp -->|"runs commands"| node_signaltrim

click node_cli "https://github.com/sunilgentyala/laptopai-agent/blob/master/main.py"
click node_mcp "https://github.com/sunilgentyala/laptopai-agent/blob/master/src/mcp/server.py"
click node_reasoner "https://github.com/sunilgentyala/laptopai-agent/blob/master/src/agent/graph.py"
click node_tools "https://github.com/sunilgentyala/laptopai-agent/blob/master/src/agent/tools.py"
click node_rag "https://github.com/sunilgentyala/laptopai-agent/blob/master/src/rag/knowledge_base.py"
click node_guard "https://github.com/sunilgentyala/laptopai-agent/blob/master/src/security/permissions.py"
click node_audit "https://github.com/sunilgentyala/laptopai-agent/blob/master/src/security/audit.py"
click node_history "https://github.com/sunilgentyala/laptopai-agent/blob/master/src/privacy/history_cleaner.py"

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_mcp,node_user,node_mcp_client toneBlue
class node_reasoner,node_tools,node_ollama toneAmber
class node_rag,node_chroma toneMint
class node_guard,node_audit toneRose
class node_history,node_browser_data,node_signaltrim toneIndigo
```

## Components

### User Entry

- [CLI Commands](https://github.com/sunilgentyala/laptopai-agent/blob/master/main.py): `main.py`
- [MCP Server](https://github.com/sunilgentyala/laptopai-agent/blob/master/src/mcp/server.py): `src/mcp/server.py`

### Agent Runtime

- [Agent Loop](https://github.com/sunilgentyala/laptopai-agent/blob/master/src/agent/graph.py): `src/agent/graph.py`
- [System Tools](https://github.com/sunilgentyala/laptopai-agent/blob/master/src/agent/tools.py): `src/agent/tools.py`
- **Local Ollama**

### Local Knowledge

- [Knowledge Base](https://github.com/sunilgentyala/laptopai-agent/blob/master/src/rag/knowledge_base.py): `src/rag/knowledge_base.py`
- **ChromaDB Store**

### Security

- [Permission Guard](https://github.com/sunilgentyala/laptopai-agent/blob/master/src/security/permissions.py): `src/security/permissions.py`
- [Chained Audit Log](https://github.com/sunilgentyala/laptopai-agent/blob/master/src/security/audit.py): `src/security/audit.py`

### Privacy Hygiene

- [History Cleaner](https://github.com/sunilgentyala/laptopai-agent/blob/master/src/privacy/history_cleaner.py): `src/privacy/history_cleaner.py`
- **Browser Profiles**

### Other components

- **User**
- **MCP Client**
- **SignalTrim**

## Connections

- User → CLI Commands: submits query (evidence: `README.md`)
- CLI Commands → Agent Loop: runs chat (evidence: `main.py`)
- Agent Loop → Local Ollama: invokes model (evidence: `src/agent/graph.py`)
- Agent Loop → System Tools: dispatches tools (evidence: `src/agent/graph.py`)
- System Tools → Knowledge Base: queries knowledge (evidence: `src/agent/tools.py`)
- System Tools → Permission Guard: checks access (evidence: `src/agent/tools.py`)
- System Tools → Chained Audit Log: records actions (evidence: `src/agent/tools.py`)
- CLI Commands → Knowledge Base: ingests documents (evidence: `main.py`)
- Knowledge Base → ChromaDB Store: stores and searches (evidence: `src/rag/knowledge_base.py`)
- MCP Client → MCP Server: calls tools (evidence: `README.md`)
- MCP Server → Knowledge Base: queries knowledge (evidence: `src/mcp/server.py`)
- MCP Server → Permission Guard: checks access (evidence: `src/mcp/server.py`)
- MCP Server → Chained Audit Log: records actions (evidence: `src/mcp/server.py`)
- CLI Commands → Chained Audit Log: verifies chain (evidence: `main.py`)
- CLI Commands → History Cleaner: runs cleanup (evidence: `main.py`)
- MCP Server → History Cleaner: runs cleanup (evidence: `src/mcp/server.py`)
- History Cleaner → Browser Profiles: backs up and clears (evidence: `src/privacy/history_cleaner.py`)
- History Cleaner → Chained Audit Log: records run (evidence: `src/privacy/history_cleaner.py`)
- MCP Server → SignalTrim: runs commands (evidence: `src/mcp/server.py`)
