# suitedaces/computer-agent architecture

> Architecture diagram of the GitHub repository suitedaces/computer-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/suitedaces/computer-agent
- Repository: https://github.com/suitedaces/computer-agent

## Overview

##### Project type and purpose
- This is a self-hosted desktop application written in Python (3.10+), using PyQt for the GUI.
- Purpose: let an AI agent (Anthropic Claude with “computer use” capability) drive your mouse/keyboard to perform arbitrary tasks on your machine.

##### File structure
Top level
- run.py            ← application entrypoint
- requirements.txt  ← Python dependencies (PyQt, anthropic SDK, automation libs)
- README.md, LICENSE, .gitignore

src/
- main.py           ← orchestrator: initializes UI, ties modules together
- anthropic.py      ← wrapper around Anthropic API calls (compute-use endpoint)
- prompt_manager.py ← assembles user instructions + context into prompts
- computer.py       ← low-level OS automation (mouse moves, keyboard events)
- window.py         ← GUI code (PyQt window, screenshot capture, UI element detection)
- voice_control.py  ← optional speech-to-text input and event handler
- store.py          ← persistence/logging of sessions, prompts, actions

##### README for additional insights
- External dependency: Anthropic API key, remote service in the cloud
- UI interactions via keyboard shortcuts (Ctrl+Enter, Ctrl+C, etc.)
- Emphasis on safety disclaimers, capturing screenshots, and logging actions
- Multi-platform support: MacOS, Windows, Linux

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Entry Point
    EntryPoint["run.py"]:::misc
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        Window["PyQt Window"]:::ui
        VoiceInput["Voice/Text Input Handler"]:::ui
    end
    %% Business Logic
    subgraph "Business Logic"
        direction TB
        Main["Application Bootstrap & Controller"]:::logic
        PromptManager["Prompt Assembly & Context Management"]:::logic
    end
    %% External Service
    subgraph "External AI Service"
        direction TB
        AnthropicWrapper["Anthropic Claude API Wrapper"]:::external
        Cloud["Anthropic Cloud"]:::external
    end
    %% Action Execution
    subgraph "Action Execution"
        direction TB
        Computer["OS Automation (mouse/keyboard)"]:::os
        Screenshot["Screenshot & UI-Element Detection"]:::os
    end
    %% Persistence
    Store["Session Logs & Actions Store"]:::storage
    %% Dependencies & Docs
    subgraph "Project Metadata"
        direction TB
        Requirements["requirements.txt"]:::misc
        Readme["README.md"]:::misc
        License["LICENSE"]:::misc
    end

    %% Relationships
    EntryPoint -->|"initializes"| Main
    %% User Inputs
    User -->|Text/Voice| Window
    User -->|Voice Command| VoiceInput
    Window -->|"UI Event"| Main
    VoiceInput -->|"Input Event"| Main
    Main -->|"assemble prompt"| PromptManager
    PromptManager -->|"HTTP JSON"| AnthropicWrapper
    AnthropicWrapper -->|"HTTPS"| Cloud
    Cloud -->|"JSON Response"| AnthropicWrapper
    AnthropicWrapper -->|"response data"| PromptManager
    PromptManager -->|"context update"| Main
    Main -->|"execute action"| Computer
    Main -->|"capture/process"| Screenshot
    Computer -->|"OS Events"| OS
    Screenshot -->|"PIL Image"| OS
    %% Logging
    EntryPoint -->|"log init"| Store
    Window -->|"log UI event"| Store
    VoiceInput -->|"log input"| Store
    Main -->|"log actions"| Store
    PromptManager -->|"log prompts"| Store
    AnthropicWrapper -->|"log API calls"| Store
    Computer -->|"log execution"| Store
    Screenshot -->|"log screenshots"| Store

    %% Click Events
    click EntryPoint "https://github.com/suitedaces/computer-agent/blob/main/run.py"
    click Window "https://github.com/suitedaces/computer-agent/blob/main/src/window.py"
    click VoiceInput "https://github.com/suitedaces/computer-agent/blob/main/src/voice_control.py"
    click Main "https://github.com/suitedaces/computer-agent/blob/main/src/main.py"
    click PromptManager "https://github.com/suitedaces/computer-agent/blob/main/src/prompt_manager.py"
    click AnthropicWrapper "https://github.com/suitedaces/computer-agent/blob/main/src/anthropic.py"
    click Computer "https://github.com/suitedaces/computer-agent/blob/main/src/computer.py"
    click Screenshot "https://github.com/suitedaces/computer-agent/blob/main/src/window.py"
    click Store "https://github.com/suitedaces/computer-agent/blob/main/src/store.py"
    click Requirements "https://github.com/suitedaces/computer-agent/blob/main/requirements.txt"
    click Readme "https://github.com/suitedaces/computer-agent/blob/main/README.md"
    click License "https://github.com/suitedaces/computer-agent/tree/main/LICENSE"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef logic fill:#98FB98,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef os fill:#DDA0DD,stroke:#333,stroke-width:1px
    classDef storage fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef misc fill:#F0F0F0,stroke:#333,stroke-width:1px
```
