# buildswithpaul/frappe_assistant_core architecture

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

- Interactive diagram: https://gitdiagram.com/buildswithpaul/frappe_assistant_core
- Repository: https://github.com/buildswithpaul/frappe_assistant_core

## Overview

Frappe Assistant Core provides two access paths to ERPNext: external MCP clients use OAuth-authenticated tool calls under the ERP user's permissions, while opt-in FAC Chat offers an in-Frappe interface backed by FAC Cloud. The graph preserves the MCP protocol, tool/plugin and audit layers, plus chat, administration, and workflow capabilities documented in the README. Some chat and OAuth wiring is documented rather than shown in sampled source; those links cite the README, and unsampled implementation details are not inferred.

Main entry points: [`frappe_assistant_core/chat/frontend/src/App.vue`](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/chat/frontend/src/App.vue) (Chat interface), [`frappe_assistant_core/core/base_tool.py`](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/core/base_tool.py) (Tool execution), [`frappe_assistant_core/mcp/server.py`](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/mcp/server.py) (MCP server), [`frappe_assistant_core/plugins/core/tools/list_documents.py`](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/plugins/core/tools/list_documents.py) (Document tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mcp["MCP access"]
  node_mcp_server["MCP server<br/>[server.py]"]
  node_handlers["MCP handlers"]
  node_tool_adapter["MCP adapter<br/>[tool_adapter.py]"]
end

subgraph group_tools["Tools and governance"]
  node_plugin_manager["Plugin manager<br/>[plugin_manager.py]"]
  node_plugin_base["Plugin base<br/>[base_plugin.py]"]
  node_tool_base["Tool execution<br/>[base_tool.py]"]
  node_document_tools["Document tools<br/>[list_documents.py]"]
  node_search_tools["Search tools<br/>[search_tools.py]"]
  node_report_tools["Report search<br/>[report_search.py]"]
  node_sql_tool["SQL analysis"]
  node_audit[("Audit log<br/>[audit_trail.py]")]
end

subgraph group_chat["FAC Chat"]
  node_chat_frontend["Chat interface<br/>[App.vue]"]
  node_widget["Desk widget<br/>[main.js]"]
  node_stream_manager["Stream manager<br/>[streamManager.js]"]
  node_chat_api["Chat API"]
  node_chat_data[("Chat records")]
  node_chat_features["Memory, RAG, workflows"]
end

subgraph group_admin["Administration and identity"]
  node_oauth["OAuth endpoints<br/>[oauth_discovery.py]"]
  node_admin_api["Admin APIs<br/>[admin_api.py]"]
  node_admin_settings[("Assistant settings")]
  node_skills_prompts["Skills and prompts<br/>[prompts.py]"]
end

node_client(("MCP client"))
node_chat_user(("Frappe user"))
node_cloud["FAC Cloud"]

node_client -->|"sends MCP requests"| node_mcp_server
node_mcp_server -->|"dispatches prompts/resources"| node_handlers
node_mcp_server -->|"adapts tool calls"| node_tool_adapter
node_tool_adapter -->|"adapts tool"| node_document_tools
node_plugin_manager -->|"discovers plugins"| node_plugin_base
node_plugin_manager -->|"loads tools"| node_tool_base
node_document_tools -->|"extends execution"| node_tool_base
node_document_tools -->|"uses search"| node_search_tools
node_sql_tool -->|"extends execution"| node_tool_base
node_tool_base -->|"records executions"| node_audit
node_client -->|"authenticates"| node_oauth
node_oauth -->|"reads OAuth settings"| node_admin_settings
node_admin_api -->|"updates settings"| node_admin_settings
node_chat_user -->|"uses chat"| node_chat_frontend
node_chat_user -->|"opens widget"| node_widget
node_stream_manager -->|"cancels stream"| node_chat_api
node_chat_frontend -->|"uses managed service"| node_cloud
node_widget -->|"uses managed service"| node_cloud
node_chat_api -.->|"stores conversations"| node_chat_data
node_chat_frontend -->|"offers chat capabilities"| node_chat_features
node_skills_prompts -.->|"provides prompt capability"| node_chat_frontend

click node_mcp_server "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/mcp/server.py"
click node_handlers "https://github.com/buildswithpaul/frappe_assistant_core/tree/main/frappe_assistant_core/api/handlers"
click node_oauth "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/api/oauth_discovery.py"
click node_plugin_manager "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/utils/plugin_manager.py"
click node_plugin_base "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/plugins/base_plugin.py"
click node_tool_base "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/core/base_tool.py"
click node_tool_adapter "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/mcp/tool_adapter.py"
click node_document_tools "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/plugins/core/tools/list_documents.py"
click node_search_tools "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/plugins/core/tools/search_tools.py"
click node_report_tools "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/plugins/core/tools/report_search.py"
click node_sql_tool "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/plugins/data_science/tools/run_database_query.py"
click node_audit "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/utils/audit_trail.py"
click node_admin_api "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/api/admin_api.py"
click node_admin_settings "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/assistant_core/doctype/assistant_core_settings/assistant_core_settings.py"
click node_skills_prompts "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/api/handlers/prompts.py"
click node_chat_frontend "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/chat/frontend/src/App.vue"
click node_widget "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/chat/frontend/src/widget/panel/main.js"
click node_stream_manager "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/chat/frontend/src/stores/chat/streamManager.js"
click node_chat_api "https://github.com/buildswithpaul/frappe_assistant_core/tree/main/frappe_assistant_core/chat/api/chat"
click node_chat_data "https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/chat/doctype/fac_chat_conversation/fac_chat_conversation.py"
click node_chat_features "https://github.com/buildswithpaul/frappe_assistant_core/tree/main/frappe_assistant_core/chat/api"

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_mcp_server,node_handlers,node_tool_adapter,node_client,node_chat_user toneBlue
class node_plugin_manager,node_plugin_base,node_tool_base,node_document_tools,node_search_tools,node_report_tools,node_sql_tool,node_audit toneAmber
class node_chat_frontend,node_widget,node_stream_manager,node_chat_api,node_chat_data,node_chat_features toneMint
class node_oauth,node_admin_api,node_admin_settings,node_skills_prompts toneRose
class node_cloud toneIndigo
```

## Components

### MCP access

- [MCP server](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/mcp/server.py): `frappe_assistant_core/mcp/server.py`
- [MCP handlers](https://github.com/buildswithpaul/frappe_assistant_core/tree/main/frappe_assistant_core/api/handlers): `frappe_assistant_core/api/handlers`
- [MCP adapter](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/mcp/tool_adapter.py): `frappe_assistant_core/mcp/tool_adapter.py`

### Tools and governance

- [Plugin manager](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/utils/plugin_manager.py): `frappe_assistant_core/utils/plugin_manager.py`
- [Plugin base](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/plugins/base_plugin.py): `frappe_assistant_core/plugins/base_plugin.py`
- [Tool execution](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/core/base_tool.py): `frappe_assistant_core/core/base_tool.py`
- [Document tools](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/plugins/core/tools/list_documents.py): `frappe_assistant_core/plugins/core/tools/list_documents.py`
- [Search tools](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/plugins/core/tools/search_tools.py): `frappe_assistant_core/plugins/core/tools/search_tools.py`
- [Report search](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/plugins/core/tools/report_search.py): `frappe_assistant_core/plugins/core/tools/report_search.py`
- [SQL analysis](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/plugins/data_science/tools/run_database_query.py): `frappe_assistant_core/plugins/data_science/tools/run_database_query.py`
- [Audit log](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/utils/audit_trail.py): `frappe_assistant_core/utils/audit_trail.py`

### FAC Chat

- [Chat interface](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/chat/frontend/src/App.vue): `frappe_assistant_core/chat/frontend/src/App.vue`
- [Desk widget](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/chat/frontend/src/widget/panel/main.js): `frappe_assistant_core/chat/frontend/src/widget/panel/main.js`
- [Stream manager](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/chat/frontend/src/stores/chat/streamManager.js): `frappe_assistant_core/chat/frontend/src/stores/chat/streamManager.js`
- [Chat API](https://github.com/buildswithpaul/frappe_assistant_core/tree/main/frappe_assistant_core/chat/api/chat): `frappe_assistant_core/chat/api/chat`
- [Chat records](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/chat/doctype/fac_chat_conversation/fac_chat_conversation.py): `frappe_assistant_core/chat/doctype/fac_chat_conversation/fac_chat_conversation.py`
- [Memory, RAG, workflows](https://github.com/buildswithpaul/frappe_assistant_core/tree/main/frappe_assistant_core/chat/api): `frappe_assistant_core/chat/api`

### Administration and identity

- [OAuth endpoints](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/api/oauth_discovery.py): `frappe_assistant_core/api/oauth_discovery.py`
- [Admin APIs](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/api/admin_api.py): `frappe_assistant_core/api/admin_api.py`
- [Assistant settings](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/assistant_core/doctype/assistant_core_settings/assistant_core_settings.py): `frappe_assistant_core/assistant_core/doctype/assistant_core_settings/assistant_core_settings.py`
- [Skills and prompts](https://github.com/buildswithpaul/frappe_assistant_core/blob/main/frappe_assistant_core/api/handlers/prompts.py): `frappe_assistant_core/api/handlers/prompts.py`

### Other components

- **MCP client**
- **Frappe user**
- **FAC Cloud**

## Connections

- MCP client → MCP server: sends MCP requests
- MCP server → MCP handlers: dispatches prompts/resources (evidence: `frappe_assistant_core/mcp/server.py`)
- MCP server → MCP adapter: adapts tool calls (evidence: `frappe_assistant_core/mcp/server.py`)
- MCP adapter → Document tools: adapts tool (evidence: `frappe_assistant_core/mcp/tool_adapter.py`)
- Plugin manager → Plugin base: discovers plugins (evidence: `frappe_assistant_core/utils/plugin_manager.py`)
- Plugin manager → Tool execution: loads tools (evidence: `frappe_assistant_core/utils/plugin_manager.py`)
- Document tools → Tool execution: extends execution (evidence: `frappe_assistant_core/plugins/core/tools/list_documents.py`)
- Document tools → Search tools: uses search (evidence: `frappe_assistant_core/plugins/core/tools/list_documents.py`)
- SQL analysis → Tool execution: extends execution (evidence: `frappe_assistant_core/plugins/data_science/tools/run_database_query.py`)
- Tool execution → Audit log: records executions (evidence: `frappe_assistant_core/core/base_tool.py`)
- MCP client → OAuth endpoints: authenticates
- OAuth endpoints → Assistant settings: reads OAuth settings (evidence: `frappe_assistant_core/api/oauth_discovery.py`)
- Admin APIs → Assistant settings: updates settings
- Frappe user → Chat interface: uses chat
- Frappe user → Desk widget: opens widget
- Stream manager → Chat API: cancels stream (evidence: `frappe_assistant_core/chat/frontend/src/stores/chat/streamManager.js`)
- Chat interface → FAC Cloud: uses managed service
- Desk widget → FAC Cloud: uses managed service
- Chat API → Chat records: stores conversations
- Chat interface → Memory, RAG, workflows: offers chat capabilities
- Skills and prompts → Chat interface: provides prompt capability
