# lasithhaputhanthri/chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/lasithhaputhanthri/chatbot
- Repository: https://github.com/lasithhaputhanthri/chatbot

## Overview

This is an autonomous Windows desktop AI assistant: a user chats through a floating Tauri/React UI, the backend streams lifecycle updates while an agent plans and executes tools, and results may include workspace changes, documents, presentations, research, database operations, or retrieval-grounded answers. The graph preserves these major product branches and the approval, verification, and persistence layers. Evidence is limited to README statements and SOURCE INDEX references; unsampled implementation details and some runtime wiring are not inferred.

Main entry points: [`backend/app/services/tools/registry.py`](https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/services/tools/registry.py) (Tool registry), [`desktop/src/App.tsx`](https://github.com/lasithhaputhanthri/chatbot/blob/main/desktop/src/App.tsx) (Desktop application), [`backend/app/orchestration/service.py`](https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/orchestration/service.py) (Agent orchestration), [`desktop/src/components/PermissionManager/PermissionManager.tsx`](https://github.com/lasithhaputhanthri/chatbot/blob/main/desktop/src/components/PermissionManager/PermissionManager.tsx) (Permissions inbox)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop experience"]
  node_desktop_app["Desktop application<br/>[App.tsx]"]
  node_chat_ui["Chat panel<br/>[ChatPanel.tsx]"]
  node_permissions_ui["Permissions inbox"]
  node_state_machine["Assistant state"]
  node_backend_client["Backend client<br/>[backendClient.ts]"]
end

subgraph group_agent["Agent orchestration"]
  node_chat_service["Chat service<br/>[chat_service.py]"]
  node_orchestration["Agent orchestration<br/>[service.py]"]
  node_agent_graph["Agent graph<br/>[graph.py]"]
  node_tool_registry["Tool registry<br/>[registry.py]"]
  node_approval["Approval and recovery<br/>[approvals.py]"]
end

subgraph group_workspace["Workspace operations"]
  node_workspace_service["Workspace security<br/>[workspace.py]"]
  node_filesystem["Filesystem tools"]
  node_documents["Document automation"]
  node_presentations["Presentation automation"]
end

subgraph group_knowledge["Knowledge and research"]
  node_research["Internet research"]
  node_rag["RAG retrieval"]
end

subgraph group_platform["Backend platform"]
  node_api["Backend API<br/>[main.py]"]
  node_database_ops["Database management"]
  node_audit["Audit logging<br/>[audit.py]"]
  node_app_database[("Application database<br/>[database.py]")]
end

node_user(("Desktop user"))

node_user -->|"uses"| node_desktop_app
node_desktop_app -->|"renders"| node_chat_ui
node_desktop_app -->|"opens"| node_permissions_ui
node_desktop_app -->|"owns state"| node_state_machine
node_desktop_app -->|"sends chat"| node_backend_client
node_backend_client -->|"streams events"| node_api
node_api -->|"routes chat"| node_chat_service
node_chat_service -.->|"starts tasks"| node_orchestration
node_orchestration -->|"runs graph"| node_agent_graph
node_orchestration -->|"uses tools"| node_tool_registry
node_orchestration -->|"manages approval"| node_approval
node_tool_registry -->|"dispatches"| node_filesystem
node_tool_registry -->|"dispatches"| node_documents
node_tool_registry -->|"dispatches"| node_presentations
node_tool_registry -->|"dispatches"| node_research
node_tool_registry -->|"dispatches"| node_database_ops
node_tool_registry -.->|"dispatches"| node_rag
node_filesystem -->|"confines access"| node_workspace_service
node_documents -->|"checks permissions"| node_workspace_service
node_presentations -->|"checks permissions"| node_workspace_service
node_database_ops -->|"uses catalog"| node_app_database
node_permissions_ui -->|"submits decisions"| node_backend_client
node_tool_registry -->|"records calls"| node_audit
node_permissions_ui -.->|"manages workspaces"| node_api

click node_desktop_app "https://github.com/lasithhaputhanthri/chatbot/blob/main/desktop/src/App.tsx"
click node_chat_ui "https://github.com/lasithhaputhanthri/chatbot/blob/main/desktop/src/components/ChatPanel/ChatPanel.tsx"
click node_permissions_ui "https://github.com/lasithhaputhanthri/chatbot/blob/main/desktop/src/components/PermissionManager/PermissionManager.tsx"
click node_state_machine "https://github.com/lasithhaputhanthri/chatbot/blob/main/desktop/src/state/assistantMachine.ts"
click node_backend_client "https://github.com/lasithhaputhanthri/chatbot/blob/main/desktop/src/api/backendClient.ts"
click node_api "https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/main.py"
click node_chat_service "https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/services/chat_service.py"
click node_orchestration "https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/orchestration/service.py"
click node_agent_graph "https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/orchestration/graph.py"
click node_tool_registry "https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/services/tools/registry.py"
click node_approval "https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/orchestration/approvals.py"
click node_workspace_service "https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/services/workspace.py"
click node_filesystem "https://github.com/lasithhaputhanthri/chatbot/tree/main/backend/app/services/filesystem"
click node_documents "https://github.com/lasithhaputhanthri/chatbot/tree/main/backend/app/services/documents"
click node_presentations "https://github.com/lasithhaputhanthri/chatbot/tree/main/backend/app/services/presentations"
click node_research "https://github.com/lasithhaputhanthri/chatbot/tree/main/backend/app/services/research"
click node_rag "https://github.com/lasithhaputhanthri/chatbot/tree/main/backend/app/services/rag"
click node_database_ops "https://github.com/lasithhaputhanthri/chatbot/tree/main/backend/app/services/database"
click node_audit "https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/services/audit.py"
click node_app_database "https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/core/database.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_desktop_app,node_chat_ui,node_permissions_ui,node_state_machine,node_backend_client,node_user toneBlue
class node_chat_service,node_orchestration,node_agent_graph,node_tool_registry,node_approval toneAmber
class node_workspace_service,node_filesystem,node_documents,node_presentations toneMint
class node_research,node_rag toneRose
class node_api,node_database_ops,node_audit,node_app_database toneIndigo
```

## Components

### Desktop experience

- [Desktop application](https://github.com/lasithhaputhanthri/chatbot/blob/main/desktop/src/App.tsx): `desktop/src/App.tsx`
- [Chat panel](https://github.com/lasithhaputhanthri/chatbot/blob/main/desktop/src/components/ChatPanel/ChatPanel.tsx): `desktop/src/components/ChatPanel/ChatPanel.tsx`
- [Permissions inbox](https://github.com/lasithhaputhanthri/chatbot/blob/main/desktop/src/components/PermissionManager/PermissionManager.tsx): `desktop/src/components/PermissionManager/PermissionManager.tsx`
- [Assistant state](https://github.com/lasithhaputhanthri/chatbot/blob/main/desktop/src/state/assistantMachine.ts): `desktop/src/state/assistantMachine.ts`
- [Backend client](https://github.com/lasithhaputhanthri/chatbot/blob/main/desktop/src/api/backendClient.ts): `desktop/src/api/backendClient.ts`

### Agent orchestration

- [Chat service](https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/services/chat_service.py): `backend/app/services/chat_service.py`
- [Agent orchestration](https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/orchestration/service.py): `backend/app/orchestration/service.py`
- [Agent graph](https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/orchestration/graph.py): `backend/app/orchestration/graph.py`
- [Tool registry](https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/services/tools/registry.py): `backend/app/services/tools/registry.py`
- [Approval and recovery](https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/orchestration/approvals.py): `backend/app/orchestration/approvals.py`

### Workspace operations

- [Workspace security](https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/services/workspace.py): `backend/app/services/workspace.py`
- [Filesystem tools](https://github.com/lasithhaputhanthri/chatbot/tree/main/backend/app/services/filesystem): `backend/app/services/filesystem`
- [Document automation](https://github.com/lasithhaputhanthri/chatbot/tree/main/backend/app/services/documents): `backend/app/services/documents`
- [Presentation automation](https://github.com/lasithhaputhanthri/chatbot/tree/main/backend/app/services/presentations): `backend/app/services/presentations`

### Knowledge and research

- [Internet research](https://github.com/lasithhaputhanthri/chatbot/tree/main/backend/app/services/research): `backend/app/services/research`
- [RAG retrieval](https://github.com/lasithhaputhanthri/chatbot/tree/main/backend/app/services/rag): `backend/app/services/rag`

### Backend platform

- [Backend API](https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/main.py): `backend/app/main.py`
- [Database management](https://github.com/lasithhaputhanthri/chatbot/tree/main/backend/app/services/database): `backend/app/services/database`
- [Audit logging](https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/services/audit.py): `backend/app/services/audit.py`
- [Application database](https://github.com/lasithhaputhanthri/chatbot/blob/main/backend/app/core/database.py): `backend/app/core/database.py`

### Other components

- **Desktop user**

## Connections

- Desktop user → Desktop application: uses (evidence: `README.md`)
- Desktop application → Chat panel: renders (evidence: `desktop/src/App.tsx`)
- Desktop application → Permissions inbox: opens (evidence: `desktop/src/App.tsx`)
- Desktop application → Assistant state: owns state (evidence: `desktop/src/App.tsx`)
- Desktop application → Backend client: sends chat (evidence: `desktop/src/App.tsx`)
- Backend client → Backend API: streams events (evidence: `README.md`)
- Backend API → Chat service: routes chat (evidence: `backend/app/main.py`)
- Chat service → Agent orchestration: starts tasks
- Agent orchestration → Agent graph: runs graph (evidence: `backend/app/orchestration/service.py`)
- Agent orchestration → Tool registry: uses tools (evidence: `backend/app/orchestration/service.py`)
- Agent orchestration → Approval and recovery: manages approval (evidence: `README.md`)
- Tool registry → Filesystem tools: dispatches (evidence: `backend/app/services/tools/registry.py`)
- Tool registry → Document automation: dispatches (evidence: `backend/app/services/tools/registry.py`)
- Tool registry → Presentation automation: dispatches (evidence: `backend/app/services/tools/registry.py`)
- Tool registry → Internet research: dispatches (evidence: `backend/app/services/tools/registry.py`)
- Tool registry → Database management: dispatches (evidence: `backend/app/services/tools/registry.py`)
- Tool registry → RAG retrieval: dispatches
- Filesystem tools → Workspace security: confines access (evidence: `README.md`)
- Document automation → Workspace security: checks permissions (evidence: `README.md`)
- Presentation automation → Workspace security: checks permissions (evidence: `README.md`)
- Database management → Application database: uses catalog (evidence: `backend/app/services/database/catalog.py`)
- Permissions inbox → Backend client: submits decisions (evidence: `desktop/src/components/PermissionManager/PermissionManager.tsx`)
- Tool registry → Audit logging: records calls (evidence: `backend/app/services/tools/registry.py`)
- Permissions inbox → Backend API: manages workspaces
