# rnaveenpatil/depression.ai architecture

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

- Interactive diagram: https://gitdiagram.com/rnaveenpatil/depression.ai
- Repository: https://github.com/rnaveenpatil/depression.ai

## Overview

depression.ai is a local-first terminal agent for coding, system work, and cloud operations. A user enters a request through the terminal interface; the dual-agent harness plans and runs an action loop, drawing on project context, a configured model, and registered tools. Tool results can inform further actions and verification before the agent reports back. The README also documents permissions, MCP, AWS, browser, Git, and session capabilities. Edges cite the README or indexed source references; dashed links mark documented but unsampled connections.

Main entry points: [`src/agent/agent/loop.py`](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/agent/loop.py) (Action loop), [`src/agent/agent/dual_agent.py`](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/agent/dual_agent.py) (Dual-agent harness), [`src/agent/context/manager.py`](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/context/manager.py) (Project context), [`src/agent/tools/registry.py`](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/tools/registry.py) (Tool registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Terminal interaction"]
  node_terminal["Terminal UI<br/>[app.py]"]
  node_cli["CLI commands<br/>[commands.py]"]
  node_result["Agent report"]
end

subgraph group_agent["Agent workflow"]
  node_dual["Dual-agent harness<br/>[dual_agent.py]"]
  node_loop["Action loop<br/>[loop.py]"]
  node_planner["Planner<br/>[planner.py]"]
  node_verification["Verification<br/>[verification.py]"]
  node_subagents["Subagents<br/>[subagent.py]"]
end

subgraph group_context["Context and state"]
  node_context["Project context<br/>[manager.py]"]
  node_context_runtime["Context runtime<br/>[runtime.py]"]
  node_workspace["Workspace<br/>[workspace.py]"]
  node_sessions["Sessions<br/>[session.py]"]
  node_database[("Local database<br/>[database.py]")]
end

subgraph group_execution["Tools and integrations"]
  node_registry["Tool registry<br/>[registry.py]"]
  node_permissions["Permission gate<br/>[manager.py]"]
  node_mcp["MCP client<br/>[client.py]"]
  node_aws["AWS integration<br/>[aws_config.py]"]
  node_plugins["Plugin loader<br/>[loader.py]"]
end

subgraph group_foundation["Configuration and models"]
  node_config["Configuration<br/>[loader.py]"]
  node_llm_runtime["Model runtime<br/>[runtime.py]"]
  node_provider["Model provider<br/>[provider.py]"]
  node_credentials[("Local credentials<br/>[env_manager.py]")]
end

node_user(("User"))
node_model_service{{"Model endpoint"}}

node_user -->|"enters request"| node_terminal
node_user -->|"starts agent"| node_cli
node_terminal -->|"runs harness"| node_dual
node_cli -.->|"starts workflow"| node_dual
node_dual -->|"creates loop"| node_loop
node_loop -->|"uses planner"| node_planner
node_loop -->|"verifies work"| node_verification
node_loop -->|"requests completion"| node_provider
node_loop -->|"dispatches tools"| node_registry
node_loop -->|"manages runtime context"| node_context_runtime
node_dual -->|"creates manager"| node_subagents
node_dual -->|"loads plugins"| node_plugins
node_context -->|"refreshes project context"| node_workspace
node_context -->|"uses context runtime"| node_context_runtime
node_context_runtime -->|"uses manager"| node_context
node_sessions -.->|"saves context"| node_context
node_sessions -.->|"persists session data"| node_database
node_registry -.->|"checks authorization"| node_permissions
node_mcp -->|"registers tools"| node_registry
node_aws -->|"configures AWS"| node_mcp
node_config -.->|"supplies settings"| node_dual
node_llm_runtime -->|"installs adapters"| node_provider
node_llm_runtime -->|"reads credentials"| node_credentials
node_model_service -.->|"serves inference"| node_provider
node_verification -->|"reports outcome"| node_result
node_registry -.->|"returns tool outcomes"| node_result

click node_terminal "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/tui/app.py"
click node_cli "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/cli/commands.py"
click node_dual "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/agent/dual_agent.py"
click node_loop "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/agent/loop.py"
click node_planner "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/agent/planner.py"
click node_verification "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/agent/verification.py"
click node_subagents "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/agent/subagent.py"
click node_context "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/context/manager.py"
click node_context_runtime "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/context/runtime.py"
click node_workspace "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/project/workspace.py"
click node_sessions "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/session/session.py"
click node_database "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/storage/database.py"
click node_registry "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/tools/registry.py"
click node_permissions "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/permissions/manager.py"
click node_mcp "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/mcp/client.py"
click node_aws "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/mcp/aws_config.py"
click node_plugins "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/plugins/loader.py"
click node_config "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/config/loader.py"
click node_llm_runtime "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/llm/runtime.py"
click node_provider "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/llm/provider.py"
click node_credentials "https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/utils/env_manager.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_terminal,node_cli,node_result,node_user toneBlue
class node_dual,node_loop,node_planner,node_verification,node_subagents toneAmber
class node_context,node_context_runtime,node_workspace,node_sessions,node_database toneMint
class node_registry,node_permissions,node_mcp,node_aws,node_plugins toneRose
class node_config,node_llm_runtime,node_provider,node_credentials,node_model_service toneIndigo
```

## Components

### Terminal interaction

- [Terminal UI](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/tui/app.py): `src/agent/tui/app.py`
- [CLI commands](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/cli/commands.py): `src/agent/cli/commands.py`
- **Agent report**

### Agent workflow

- [Dual-agent harness](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/agent/dual_agent.py): `src/agent/agent/dual_agent.py`
- [Action loop](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/agent/loop.py): `src/agent/agent/loop.py`
- [Planner](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/agent/planner.py): `src/agent/agent/planner.py`
- [Verification](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/agent/verification.py): `src/agent/agent/verification.py`
- [Subagents](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/agent/subagent.py): `src/agent/agent/subagent.py`

### Context and state

- [Project context](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/context/manager.py): `src/agent/context/manager.py`
- [Context runtime](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/context/runtime.py): `src/agent/context/runtime.py`
- [Workspace](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/project/workspace.py): `src/agent/project/workspace.py`
- [Sessions](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/session/session.py): `src/agent/session/session.py`
- [Local database](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/storage/database.py): `src/agent/storage/database.py`

### Tools and integrations

- [Tool registry](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/tools/registry.py): `src/agent/tools/registry.py`
- [Permission gate](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/permissions/manager.py): `src/agent/permissions/manager.py`
- [MCP client](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/mcp/client.py): `src/agent/mcp/client.py`
- [AWS integration](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/mcp/aws_config.py): `src/agent/mcp/aws_config.py`
- [Plugin loader](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/plugins/loader.py): `src/agent/plugins/loader.py`

### Configuration and models

- [Configuration](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/config/loader.py): `src/agent/config/loader.py`
- [Model runtime](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/llm/runtime.py): `src/agent/llm/runtime.py`
- [Model provider](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/llm/provider.py): `src/agent/llm/provider.py`
- [Local credentials](https://github.com/rnaveenpatil/depression.ai/blob/main/src/agent/utils/env_manager.py): `src/agent/utils/env_manager.py`

### Other components

- **User**
- **Model endpoint**

## Connections

- User → Terminal UI: enters request
- User → CLI commands: starts agent
- Terminal UI → Dual-agent harness: runs harness (evidence: `src/agent/tui/app.py`)
- CLI commands → Dual-agent harness: starts workflow
- Dual-agent harness → Action loop: creates loop (evidence: `src/agent/agent/dual_agent.py`)
- Action loop → Planner: uses planner (evidence: `src/agent/agent/loop.py`)
- Action loop → Verification: verifies work (evidence: `src/agent/agent/loop.py`)
- Action loop → Model provider: requests completion (evidence: `src/agent/agent/loop.py`)
- Action loop → Tool registry: dispatches tools (evidence: `src/agent/agent/loop.py`)
- Action loop → Context runtime: manages runtime context (evidence: `src/agent/agent/loop.py`)
- Dual-agent harness → Subagents: creates manager (evidence: `src/agent/agent/dual_agent.py`)
- Dual-agent harness → Plugin loader: loads plugins (evidence: `src/agent/agent/dual_agent.py`)
- Project context → Workspace: refreshes project context (evidence: `src/agent/context/manager.py`)
- Project context → Context runtime: uses context runtime (evidence: `src/agent/context/manager.py`)
- Context runtime → Project context: uses manager (evidence: `src/agent/context/runtime.py`)
- Sessions → Project context: saves context
- Sessions → Local database: persists session data
- Tool registry → Permission gate: checks authorization
- MCP client → Tool registry: registers tools (evidence: `src/agent/mcp/client.py`)
- AWS integration → MCP client: configures AWS (evidence: `src/agent/mcp/client.py`)
- Configuration → Dual-agent harness: supplies settings (evidence: `src/agent/agent/dual_agent.py`)
- Model runtime → Model provider: installs adapters (evidence: `src/agent/llm/runtime.py`)
- Model runtime → Local credentials: reads credentials (evidence: `src/agent/llm/runtime.py`)
- Model endpoint → Model provider: serves inference
- Verification → Agent report: reports outcome
- Tool registry → Agent report: returns tool outcomes
