# suwtyunwei/weftrix architecture

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

- Interactive diagram: https://gitdiagram.com/suwtyunwei/weftrix
- Repository: https://github.com/suwtyunwei/weftrix

## Overview

Weftrix is a self-hosted agent platform: users work in a Vue workspace, send chat or agent requests through the FastAPI backend, and receive streamed answers, tool activity, and deliverable files. The backend adapts requests to the DSH SDK runtime or its local fallback, with optional knowledge retrieval and team coordination. Separate product branches provide identity and permissions, scheduling, skills/plugins/MCP, model and preset administration, and audit/traceability. Edges use README statements or the shown source references; several subsystem internals were not sampled, so their detailed call paths are omitted.

Main entry points: [`backend/app/core/run_manager.py`](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/run_manager.py) (Run Manager), [`backend/app/core/dsh_runtime.py`](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/dsh_runtime.py) (DSH Runtime Adapter), [`backend/app/database.py`](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/database.py) (Application Database), [`backend/app/core/scheduled_tasks.py`](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/scheduled_tasks.py) (Task Scheduler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["User Workspace"]
  node_workspace_ui["Vue Workspace<br/>[ChatView.vue]"]
  node_chat_api["Chat API<br/>[chat.py]"]
  node_session_api["Session API<br/>[sessions.py]"]
  node_workspace_tools["Workspace Files<br/>[workspace_tools.py]"]
end

subgraph group_execution["Agent Execution"]
  node_run_manager["Run Manager<br/>[run_manager.py]"]
  node_dsh_runtime["DSH Runtime Adapter<br/>[dsh_runtime.py]"]
  node_local_runtime["Local Runtime<br/>[local_runtime.py]"]
  node_agent_teams["Team Orchestrator<br/>[agent_team.py]"]
  node_model_router["Model Routing<br/>[model_router.py]"]
end

subgraph group_capabilities["Platform Capabilities"]
  node_kb_api["Knowledge APIs<br/>[kb.py]"]
  node_knowledge["Knowledge Retrieval<br/>[knowledge_base.py]"]
  node_vector_store[("Weaviate Store<br/>[weaviate_store.py]")]
  node_skills_plugins["Skills And Plugins<br/>[plugins.py]"]
  node_mcp["MCP Integration<br/>[mcp_bridge.py]"]
  node_mcp_server["Platform MCP Server<br/>[platform_server.py]"]
  node_scheduler["Task Scheduler<br/>[scheduled_tasks.py]"]
  node_schedule_api["Schedule API<br/>[scheduled_tasks.py]"]
end

subgraph group_governance["Identity And Governance"]
  node_auth_api["Authentication API<br/>[auth.py]"]
  node_security["Token Security<br/>[security.py]"]
  node_rbac["RBAC Enforcement<br/>[rbac.py]"]
  node_audit["Audit Logging<br/>[audit.py]"]
  node_traces["Run Traces<br/>[trajectory.py]"]
  node_memory["Long-Term Memory<br/>[memory_service.py]"]
end

subgraph group_persistence["Platform State"]
  node_database[("Application Database<br/>[database.py]")]
  node_models["Domain Models<br/>[models.py]"]
end

node_user(("Platform User"))

node_user -->|"uses"| node_workspace_ui
node_workspace_ui -->|"sends requests"| node_chat_api
node_chat_api -->|"starts runs"| node_run_manager
node_run_manager -->|"dispatches runs"| node_dsh_runtime
node_run_manager -->|"fallback runs"| node_local_runtime
node_run_manager -->|"coordinates teams"| node_agent_teams
node_run_manager -->|"prefetches retrieval"| node_knowledge
node_run_manager -->|"records events"| node_traces
node_run_manager -->|"delivers files"| node_workspace_tools
node_dsh_runtime -->|"bridges tools"| node_mcp
node_dsh_runtime -->|"falls back"| node_local_runtime
node_model_router -->|"supplies model"| node_dsh_runtime
node_kb_api -->|"manages knowledge"| node_knowledge
node_knowledge -->|"stores vectors"| node_vector_store
node_dsh_runtime -->|"loads capabilities"| node_skills_plugins
node_dsh_runtime -.->|"exposes platform tools"| node_mcp_server
node_schedule_api -->|"manages schedules"| node_scheduler
node_scheduler -->|"executes tasks"| node_run_manager
node_auth_api -->|"issues identity"| node_security
node_security -->|"resolves permissions"| node_rbac
node_rbac -->|"loads roles"| node_database
node_audit -->|"persists records"| node_database
node_memory -->|"persists memory"| node_database
node_database -->|"uses mappings"| node_models
node_scheduler -->|"reads and writes"| node_database
node_session_api -.->|"manages sessions"| node_database

click node_workspace_ui "https://github.com/suwtyunwei/weftrix/blob/main/frontend/src/views/chat/ChatView.vue"
click node_chat_api "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/api/chat.py"
click node_session_api "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/api/sessions.py"
click node_workspace_tools "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/workspace_tools.py"
click node_run_manager "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/run_manager.py"
click node_dsh_runtime "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/dsh_runtime.py"
click node_local_runtime "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/local_runtime.py"
click node_agent_teams "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/agent_team.py"
click node_model_router "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/model_router.py"
click node_kb_api "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/api/kb.py"
click node_knowledge "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/knowledge_base.py"
click node_vector_store "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/weaviate_store.py"
click node_skills_plugins "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/plugins.py"
click node_mcp "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/mcp_bridge.py"
click node_mcp_server "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/mcp_server/platform_server.py"
click node_scheduler "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/scheduled_tasks.py"
click node_schedule_api "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/api/scheduled_tasks.py"
click node_auth_api "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/api/auth.py"
click node_security "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/security.py"
click node_rbac "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/rbac.py"
click node_audit "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/audit.py"
click node_traces "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/trajectory.py"
click node_memory "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/memory_service.py"
click node_database "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/database.py"
click node_models "https://github.com/suwtyunwei/weftrix/blob/main/backend/app/models.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_workspace_ui,node_chat_api,node_session_api,node_workspace_tools,node_user toneBlue
class node_run_manager,node_dsh_runtime,node_local_runtime,node_agent_teams,node_model_router toneAmber
class node_kb_api,node_knowledge,node_vector_store,node_skills_plugins,node_mcp,node_mcp_server,node_scheduler,node_schedule_api toneMint
class node_auth_api,node_security,node_rbac,node_audit,node_traces,node_memory toneRose
class node_database,node_models toneIndigo
```

## Components

### User Workspace

- [Vue Workspace](https://github.com/suwtyunwei/weftrix/blob/main/frontend/src/views/chat/ChatView.vue): `frontend/src/views/chat/ChatView.vue`
- [Chat API](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/api/chat.py): `backend/app/api/chat.py`
- [Session API](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/api/sessions.py): `backend/app/api/sessions.py`
- [Workspace Files](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/workspace_tools.py): `backend/app/core/workspace_tools.py`

### Agent Execution

- [Run Manager](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/run_manager.py): `backend/app/core/run_manager.py`
- [DSH Runtime Adapter](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/dsh_runtime.py): `backend/app/core/dsh_runtime.py`
- [Local Runtime](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/local_runtime.py): `backend/app/core/local_runtime.py`
- [Team Orchestrator](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/agent_team.py): `backend/app/core/agent_team.py`
- [Model Routing](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/model_router.py): `backend/app/core/model_router.py`

### Platform Capabilities

- [Knowledge APIs](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/api/kb.py): `backend/app/api/kb.py`
- [Knowledge Retrieval](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/knowledge_base.py): `backend/app/core/knowledge_base.py`
- [Weaviate Store](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/weaviate_store.py): `backend/app/core/weaviate_store.py`
- [Skills And Plugins](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/plugins.py): `backend/app/core/plugins.py`
- [MCP Integration](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/mcp_bridge.py): `backend/app/core/mcp_bridge.py`
- [Platform MCP Server](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/mcp_server/platform_server.py): `backend/app/mcp_server/platform_server.py`
- [Task Scheduler](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/scheduled_tasks.py): `backend/app/core/scheduled_tasks.py`
- [Schedule API](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/api/scheduled_tasks.py): `backend/app/api/scheduled_tasks.py`

### Identity And Governance

- [Authentication API](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`
- [Token Security](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/security.py): `backend/app/core/security.py`
- [RBAC Enforcement](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/rbac.py): `backend/app/core/rbac.py`
- [Audit Logging](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/audit.py): `backend/app/core/audit.py`
- [Run Traces](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/trajectory.py): `backend/app/core/trajectory.py`
- [Long-Term Memory](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/core/memory_service.py): `backend/app/core/memory_service.py`

### Platform State

- [Application Database](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/database.py): `backend/app/database.py`
- [Domain Models](https://github.com/suwtyunwei/weftrix/blob/main/backend/app/models.py): `backend/app/models.py`

### Other components

- **Platform User**

## Connections

- Platform User → Vue Workspace: uses
- Vue Workspace → Chat API: sends requests
- Chat API → Run Manager: starts runs
- Run Manager → DSH Runtime Adapter: dispatches runs (evidence: `backend/app/core/run_manager.py`)
- Run Manager → Local Runtime: fallback runs (evidence: `backend/app/core/run_manager.py`)
- Run Manager → Team Orchestrator: coordinates teams (evidence: `backend/app/core/run_manager.py`)
- Run Manager → Knowledge Retrieval: prefetches retrieval (evidence: `backend/app/core/run_manager.py`)
- Run Manager → Run Traces: records events (evidence: `backend/app/core/run_manager.py`)
- Run Manager → Workspace Files: delivers files
- DSH Runtime Adapter → MCP Integration: bridges tools (evidence: `backend/app/core/dsh_runtime.py`)
- DSH Runtime Adapter → Local Runtime: falls back (evidence: `backend/app/core/dsh_runtime.py`)
- Model Routing → DSH Runtime Adapter: supplies model
- Knowledge APIs → Knowledge Retrieval: manages knowledge
- Knowledge Retrieval → Weaviate Store: stores vectors
- DSH Runtime Adapter → Skills And Plugins: loads capabilities (evidence: `backend/app/core/dsh_runtime.py`)
- DSH Runtime Adapter → Platform MCP Server: exposes platform tools
- Schedule API → Task Scheduler: manages schedules (evidence: `backend/app/api/scheduled_tasks.py`)
- Task Scheduler → Run Manager: executes tasks (evidence: `backend/app/core/scheduled_tasks.py`)
- Authentication API → Token Security: issues identity (evidence: `backend/app/api/auth.py`)
- Token Security → RBAC Enforcement: resolves permissions (evidence: `backend/app/core/security.py`)
- RBAC Enforcement → Application Database: loads roles (evidence: `backend/app/core/rbac.py`)
- Audit Logging → Application Database: persists records (evidence: `backend/app/core/audit.py`)
- Long-Term Memory → Application Database: persists memory (evidence: `backend/app/core/memory_service.py`)
- Application Database → Domain Models: uses mappings (evidence: `backend/app/database.py`)
- Task Scheduler → Application Database: reads and writes (evidence: `backend/app/core/scheduled_tasks.py`)
- Session API → Application Database: manages sessions
