# ghhghhghh/autochat architecture

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

- Interactive diagram: https://gitdiagram.com/ghhghhghh/autochat
- Repository: https://github.com/ghhghhghh/autochat

## Overview

AutoChat is a desktop customer-service workspace combining a Vue interface, Electron-embedded shop browsers, and a Python API/automation backend. The main workflow is platform selection and login, followed by per-platform message polling, customer-memory lookup, reply generation, and automatic or human-approved sending. The README documents model, platform, script, browser-query, and real-time-event capabilities. Several of those implementation details are unsampled, so their links are documented at subsystem level; only evidenced calls are drawn as solid edges.

Main entry points: [`python_backend/agent/agent_service.py`](https://github.com/ghhghhghh/autochat/blob/main/python_backend/agent/agent_service.py) (Agent orchestrator), [`python_backend/main.py`](https://github.com/ghhghhghh/autochat/blob/main/python_backend/main.py) (FastAPI app), [`python_backend/controllers/agent_controller.py`](https://github.com/ghhghhghh/autochat/blob/main/python_backend/controllers/agent_controller.py) (Agent controller), [`src/stores/platform.ts`](https://github.com/ghhghhghh/autochat/blob/main/src/stores/platform.ts) (Platform state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop shell"]
  node_electron["Electron main<br/>[main.ts]"]
  node_browser_views["Shop BrowserViews"]
  node_ipc["IPC handlers<br/>[ipc-handlers.ts]"]
  node_python_process["Python process<br/>[python-manager.ts]"]
end

subgraph group_frontend["Workspace UI"]
  node_vue_app["Vue workspace<br/>[App.vue]"]
  node_platform_ui["Platform management<br/>[Platforms.vue]"]
  node_platform_state["Platform state<br/>[platform.ts]"]
  node_settings_ui["Model settings<br/>[Settings.vue]"]
  node_scripts_ui["Script manager<br/>[ScriptManager.vue]"]
  node_browser_toolbar["Browser controls<br/>[BrowserToolbar.vue]"]
  node_api["Frontend API<br/>[index.ts]"]
end

subgraph group_backend["API and configuration"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_platform_api["Platform service"]
  node_model_api["Model service"]
  node_script_api["Script service"]
  node_config_db[("SQLite configuration<br/>[database.py]")]
  node_script_runner["Script executor<br/>[script_runner.py]"]
end

subgraph group_automation["Reply automation"]
  node_agent_service["Agent orchestrator<br/>[agent_service.py]"]
  node_detector["Message detector"]
  node_chat_agent["Chat agent<br/>[chat_agent.py]"]
  node_browser_tools["Browser tools<br/>[browser_tools.py]"]
  node_playwright["Playwright client"]
  node_memory[("Customer memory<br/>[memory_service.py]")]
  node_tool_server["MCP tools<br/>[tools.py]"]
  node_agent_controller["Agent controller"]
  node_agent_routes["Agent routes<br/>[agent_view.py]"]
  node_websocket["Live events<br/>[websocket_view.py]"]
end

node_operator(("Operator"))
node_shop_sites{{"E-commerce sites"}}
node_model_provider{{"Model provider"}}

node_operator -->|"uses"| node_vue_app
node_vue_app -->|"loads platforms"| node_platform_state
node_platform_ui -->|"manages platforms"| node_platform_state
node_platform_state -->|"requests data"| node_api
node_platform_state -->|"switches browser"| node_ipc
node_browser_toolbar -.->|"controls browser"| node_ipc
node_ipc -.->|"dispatches controls"| node_browser_views
node_electron -->|"starts backend"| node_python_process
node_python_process -->|"launches"| node_fastapi
node_browser_views -->|"embeds sessions"| node_shop_sites
node_api -.->|"HTTP requests"| node_fastapi
node_settings_ui -.->|"configures models"| node_api
node_scripts_ui -.->|"manages scripts"| node_api
node_fastapi -->|"initializes"| node_config_db
node_fastapi -->|"registers routes"| node_platform_api
node_fastapi -->|"registers routes"| node_model_api
node_fastapi -->|"registers routes"| node_script_api
node_fastapi -->|"registers routes"| node_agent_routes
node_fastapi -->|"initializes"| node_agent_service
node_platform_api -->|"reads and writes"| node_config_db
node_model_api -->|"reads and writes"| node_config_db
node_script_api -->|"reads and writes"| node_config_db
node_script_api -->|"runs scripts"| node_script_runner
node_agent_routes -.->|"routes requests"| node_agent_controller
node_agent_controller -->|"gets default model"| node_model_api
node_agent_controller -->|"sends replies"| node_tool_server
node_agent_controller -->|"pushes preview"| node_websocket
node_agent_service -->|"starts client"| node_playwright
node_agent_service -->|"initializes memory"| node_memory
node_agent_service -->|"polls messages"| node_detector
node_agent_service -->|"requests replies"| node_chat_agent
node_chat_agent -->|"uses tools"| node_browser_tools
node_agent_service -.->|"automates conversations"| node_shop_sites
node_agent_service -.->|"retrieves and saves"| node_memory
node_chat_agent -.->|"generates replies"| node_model_provider
node_agent_service -.->|"publishes events"| node_websocket

click node_electron "https://github.com/ghhghhghh/autochat/blob/main/electron/main.ts"
click node_browser_views "https://github.com/ghhghhghh/autochat/blob/main/electron/browser-view-manager.ts"
click node_ipc "https://github.com/ghhghhghh/autochat/blob/main/electron/ipc-handlers.ts"
click node_python_process "https://github.com/ghhghhghh/autochat/blob/main/electron/python-manager.ts"
click node_vue_app "https://github.com/ghhghhghh/autochat/blob/main/src/App.vue"
click node_platform_ui "https://github.com/ghhghhghh/autochat/blob/main/src/views/platforms/Platforms.vue"
click node_platform_state "https://github.com/ghhghhghh/autochat/blob/main/src/stores/platform.ts"
click node_settings_ui "https://github.com/ghhghhghh/autochat/blob/main/src/views/settings/Settings.vue"
click node_scripts_ui "https://github.com/ghhghhghh/autochat/blob/main/src/views/scripts/ScriptManager.vue"
click node_browser_toolbar "https://github.com/ghhghhghh/autochat/blob/main/src/components/BrowserToolbar.vue"
click node_api "https://github.com/ghhghhghh/autochat/blob/main/src/api/index.ts"
click node_fastapi "https://github.com/ghhghhghh/autochat/blob/main/python_backend/main.py"
click node_platform_api "https://github.com/ghhghhghh/autochat/blob/main/python_backend/controllers/platform_controller.py"
click node_model_api "https://github.com/ghhghhghh/autochat/blob/main/python_backend/controllers/model_controller.py"
click node_script_api "https://github.com/ghhghhghh/autochat/blob/main/python_backend/controllers/script_controller.py"
click node_config_db "https://github.com/ghhghhghh/autochat/blob/main/python_backend/models/database.py"
click node_script_runner "https://github.com/ghhghhghh/autochat/blob/main/python_backend/services/script_runner.py"
click node_agent_service "https://github.com/ghhghhghh/autochat/blob/main/python_backend/agent/agent_service.py"
click node_detector "https://github.com/ghhghhghh/autochat/blob/main/python_backend/agent/message_detector.py"
click node_chat_agent "https://github.com/ghhghhghh/autochat/blob/main/python_backend/agent/chat_agent.py"
click node_browser_tools "https://github.com/ghhghhghh/autochat/blob/main/python_backend/agent/browser_tools.py"
click node_playwright "https://github.com/ghhghhghh/autochat/blob/main/python_backend/mcp/playwright_client.py"
click node_memory "https://github.com/ghhghhghh/autochat/blob/main/python_backend/services/memory_service.py"
click node_tool_server "https://github.com/ghhghhghh/autochat/blob/main/python_backend/mcp_server/tools.py"
click node_agent_controller "https://github.com/ghhghhghh/autochat/blob/main/python_backend/controllers/agent_controller.py"
click node_agent_routes "https://github.com/ghhghhghh/autochat/blob/main/python_backend/views/agent_view.py"
click node_websocket "https://github.com/ghhghhghh/autochat/blob/main/python_backend/views/websocket_view.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_electron,node_browser_views,node_ipc,node_python_process toneBlue
class node_vue_app,node_platform_ui,node_platform_state,node_settings_ui,node_scripts_ui,node_browser_toolbar,node_api toneAmber
class node_fastapi,node_platform_api,node_model_api,node_script_api,node_config_db,node_script_runner toneMint
class node_agent_service,node_detector,node_chat_agent,node_browser_tools,node_playwright,node_memory,node_tool_server,node_agent_controller,node_agent_routes,node_websocket toneRose
class node_operator,node_shop_sites,node_model_provider toneIndigo
```

## Components

### Desktop shell

- [Electron main](https://github.com/ghhghhghh/autochat/blob/main/electron/main.ts): `electron/main.ts`
- [Shop BrowserViews](https://github.com/ghhghhghh/autochat/blob/main/electron/browser-view-manager.ts): `electron/browser-view-manager.ts`
- [IPC handlers](https://github.com/ghhghhghh/autochat/blob/main/electron/ipc-handlers.ts): `electron/ipc-handlers.ts`
- [Python process](https://github.com/ghhghhghh/autochat/blob/main/electron/python-manager.ts): `electron/python-manager.ts`

### Workspace UI

- [Vue workspace](https://github.com/ghhghhghh/autochat/blob/main/src/App.vue): `src/App.vue`
- [Platform management](https://github.com/ghhghhghh/autochat/blob/main/src/views/platforms/Platforms.vue): `src/views/platforms/Platforms.vue`
- [Platform state](https://github.com/ghhghhghh/autochat/blob/main/src/stores/platform.ts): `src/stores/platform.ts`
- [Model settings](https://github.com/ghhghhghh/autochat/blob/main/src/views/settings/Settings.vue): `src/views/settings/Settings.vue`
- [Script manager](https://github.com/ghhghhghh/autochat/blob/main/src/views/scripts/ScriptManager.vue): `src/views/scripts/ScriptManager.vue`
- [Browser controls](https://github.com/ghhghhghh/autochat/blob/main/src/components/BrowserToolbar.vue): `src/components/BrowserToolbar.vue`
- [Frontend API](https://github.com/ghhghhghh/autochat/blob/main/src/api/index.ts): `src/api/index.ts`

### API and configuration

- [FastAPI app](https://github.com/ghhghhghh/autochat/blob/main/python_backend/main.py): `python_backend/main.py`
- [Platform service](https://github.com/ghhghhghh/autochat/blob/main/python_backend/controllers/platform_controller.py): `python_backend/controllers/platform_controller.py`
- [Model service](https://github.com/ghhghhghh/autochat/blob/main/python_backend/controllers/model_controller.py): `python_backend/controllers/model_controller.py`
- [Script service](https://github.com/ghhghhghh/autochat/blob/main/python_backend/controllers/script_controller.py): `python_backend/controllers/script_controller.py`
- [SQLite configuration](https://github.com/ghhghhghh/autochat/blob/main/python_backend/models/database.py): `python_backend/models/database.py`
- [Script executor](https://github.com/ghhghhghh/autochat/blob/main/python_backend/services/script_runner.py): `python_backend/services/script_runner.py`

### Reply automation

- [Agent orchestrator](https://github.com/ghhghhghh/autochat/blob/main/python_backend/agent/agent_service.py): `python_backend/agent/agent_service.py`
- [Message detector](https://github.com/ghhghhghh/autochat/blob/main/python_backend/agent/message_detector.py): `python_backend/agent/message_detector.py`
- [Chat agent](https://github.com/ghhghhghh/autochat/blob/main/python_backend/agent/chat_agent.py): `python_backend/agent/chat_agent.py`
- [Browser tools](https://github.com/ghhghhghh/autochat/blob/main/python_backend/agent/browser_tools.py): `python_backend/agent/browser_tools.py`
- [Playwright client](https://github.com/ghhghhghh/autochat/blob/main/python_backend/mcp/playwright_client.py): `python_backend/mcp/playwright_client.py`
- [Customer memory](https://github.com/ghhghhghh/autochat/blob/main/python_backend/services/memory_service.py): `python_backend/services/memory_service.py`
- [MCP tools](https://github.com/ghhghhghh/autochat/blob/main/python_backend/mcp_server/tools.py): `python_backend/mcp_server/tools.py`
- [Agent controller](https://github.com/ghhghhghh/autochat/blob/main/python_backend/controllers/agent_controller.py): `python_backend/controllers/agent_controller.py`
- [Agent routes](https://github.com/ghhghhghh/autochat/blob/main/python_backend/views/agent_view.py): `python_backend/views/agent_view.py`
- [Live events](https://github.com/ghhghhghh/autochat/blob/main/python_backend/views/websocket_view.py): `python_backend/views/websocket_view.py`

### Other components

- **Operator**
- **E-commerce sites**
- **Model provider**

## Connections

- Operator → Vue workspace: uses
- Vue workspace → Platform state: loads platforms (evidence: `src/App.vue`)
- Platform management → Platform state: manages platforms (evidence: `src/views/platforms/Platforms.vue`)
- Platform state → Frontend API: requests data (evidence: `src/stores/platform.ts`)
- Platform state → IPC handlers: switches browser (evidence: `src/stores/platform.ts`)
- Browser controls → IPC handlers: controls browser
- IPC handlers → Shop BrowserViews: dispatches controls
- Electron main → Python process: starts backend (evidence: `electron/main.ts`)
- Python process → FastAPI app: launches (evidence: `electron/python-manager.ts`)
- Shop BrowserViews → E-commerce sites: embeds sessions
- Frontend API → FastAPI app: HTTP requests
- Model settings → Frontend API: configures models
- Script manager → Frontend API: manages scripts
- FastAPI app → SQLite configuration: initializes (evidence: `python_backend/main.py`)
- FastAPI app → Platform service: registers routes (evidence: `python_backend/main.py`)
- FastAPI app → Model service: registers routes (evidence: `python_backend/main.py`)
- FastAPI app → Script service: registers routes (evidence: `python_backend/main.py`)
- FastAPI app → Agent routes: registers routes (evidence: `python_backend/main.py`)
- FastAPI app → Agent orchestrator: initializes (evidence: `python_backend/main.py`)
- Platform service → SQLite configuration: reads and writes (evidence: `python_backend/controllers/platform_controller.py`)
- Model service → SQLite configuration: reads and writes (evidence: `python_backend/controllers/model_controller.py`)
- Script service → SQLite configuration: reads and writes (evidence: `python_backend/controllers/script_controller.py`)
- Script service → Script executor: runs scripts (evidence: `python_backend/controllers/script_controller.py`)
- Agent routes → Agent controller: routes requests
- Agent controller → Model service: gets default model (evidence: `python_backend/controllers/agent_controller.py`)
- Agent controller → MCP tools: sends replies (evidence: `python_backend/controllers/agent_controller.py`)
- Agent controller → Live events: pushes preview (evidence: `python_backend/controllers/agent_controller.py`)
- Agent orchestrator → Playwright client: starts client (evidence: `python_backend/agent/agent_service.py`)
- Agent orchestrator → Customer memory: initializes memory (evidence: `python_backend/agent/agent_service.py`)
- Agent orchestrator → Message detector: polls messages (evidence: `python_backend/agent/agent_service.py`)
- Agent orchestrator → Chat agent: requests replies (evidence: `python_backend/agent/agent_service.py`)
- Chat agent → Browser tools: uses tools (evidence: `python_backend/agent/chat_agent.py`)
- Agent orchestrator → E-commerce sites: automates conversations
- Agent orchestrator → Customer memory: retrieves and saves (evidence: `python_backend/agent/agent_service.py`)
- Chat agent → Model provider: generates replies
- Agent orchestrator → Live events: publishes events
