# hj12hj/ai-agent-platform architecture

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

- Interactive diagram: https://gitdiagram.com/hj12hj/ai-agent-platform
- Repository: https://github.com/hj12hj/ai-agent-platform

## Overview

This repository is an enterprise AI-agent platform split into a governance control plane, a LangGraph execution runtime, and a Vue console. A user submits a chat request through the console; the Platform API applies identity, project, policy, and model configuration before forwarding a managed contract to the runtime. The runtime executes agent graphs and streams progress back for the console to render. README-described capabilities include HITL approvals, MCP/tools, persistent state, workspaces, memory, scheduled tasks, and execution diagnostics. Some runtime internals are unsampled, so those branches are documented at directory level.

Main entry points: [`apps/runtime-service`](https://github.com/hj12hj/ai-agent-platform/tree/main/apps/runtime-service) (Runtime Service), [`apps/platform-api/src/platform_api/modules/runtime_gateway/application/service.py`](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-api/src/platform_api/modules/runtime_gateway/application/service.py) (Runtime Gateway), [`apps/platform-web/src/modules/chat/components/ChatSession.vue`](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-web/src/modules/chat/components/ChatSession.vue) (Chat Workspace), [`apps/platform-web/src/services/threads/session.service.ts`](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-web/src/services/threads/session.service.ts) (Session Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_console["User Console"]
  node_webchat["Chat Workspace<br/>[ChatSession.vue]"]
  node_websession["Session Client<br/>[session.service.ts]"]
  node_webtasks["Task Console"]
end

subgraph group_control["Platform Governance"]
  node_api["Platform API<br/>[main.py]"]
  node_gateway["Runtime Gateway<br/>[service.py]"]
  node_projects[("Project Governance<br/>[repository.py]")]
  node_threadacl[("Thread Access<br/>[thread_access.py]")]
  node_catalog["Model Catalog<br/>[service.py]"]
  node_policies["Runtime Policies<br/>[service.py]"]
end

subgraph group_execution["Agent Execution"]
  node_runtime["Runtime Service"]
  node_sandbox["Workspace Sandbox<br/>[engine.py]"]
  node_workspacefiles[("Workspace Storage<br/>[storage.py]")]
  node_runcontrol["Run Control<br/>[service.py]"]
  node_background["Background Tasks<br/>[service.py]"]
end

subgraph group_capabilities["Agent Capabilities"]
  node_agentgraphs["Agent Graphs"]
  node_tools["Tools and MCP"]
  node_memory["Memory Pipeline"]
  node_approvals["HITL Approvals"]
  node_observability["Run Diagnostics<br/>[query.py]"]
end

node_user(("Platform User"))
node_model{{"LLM Provider"}}
node_mcp{{"MCP Services"}}

node_user -->|"submits prompt"| node_webchat
node_webchat -->|"sends session requests"| node_websession
node_websession -->|"calls platform APIs"| node_api
node_api -->|"routes requests"| node_gateway
node_gateway -->|"checks project scope"| node_projects
node_gateway -->|"enforces thread access"| node_threadacl
node_gateway -->|"loads model settings"| node_catalog
node_gateway -->|"applies runtime policy"| node_policies
node_gateway -->|"forwards managed contract"| node_runtime
node_runtime -->|"executes graphs"| node_agentgraphs
node_agentgraphs -->|"requests inference"| node_model
node_agentgraphs -->|"dispatches tool calls"| node_tools
node_tools -.->|"invokes MCP tools"| node_mcp
node_agentgraphs -->|"pauses for approval"| node_approvals
node_runtime -.->|"manages run state"| node_runcontrol
node_runtime -.->|"schedules background work"| node_background
node_runtime -.->|"provides workspace execution"| node_sandbox
node_sandbox -->|"reads and writes files"| node_workspacefiles
node_agentgraphs -.->|"uses long-term memory"| node_memory
node_runtime -.->|"reports execution diagnostics"| node_observability
node_runtime -->|"streams run events"| node_websession
node_webchat -.->|"shows task updates"| node_webtasks

click node_webchat "https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-web/src/modules/chat/components/ChatSession.vue"
click node_websession "https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-web/src/services/threads/session.service.ts"
click node_webtasks "https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-web/src/modules/chat/composables/useBackgroundTasks.ts"
click node_api "https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-api/src/platform_api/main.py"
click node_gateway "https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-api/src/platform_api/modules/runtime_gateway/application/service.py"
click node_projects "https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-api/src/platform_api/modules/projects/repository.py"
click node_threadacl "https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-api/src/platform_api/modules/runtime_gateway/application/thread_access.py"
click node_catalog "https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-api/src/platform_api/modules/runtime_catalog/application/service.py"
click node_policies "https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-api/src/platform_api/modules/runtime_policies/application/service.py"
click node_runtime "https://github.com/hj12hj/ai-agent-platform/tree/main/apps/runtime-service"
click node_sandbox "https://github.com/hj12hj/ai-agent-platform/blob/main/apps/runtime-service/src/runtime_service/sandbox_node/engine.py"
click node_workspacefiles "https://github.com/hj12hj/ai-agent-platform/blob/main/apps/runtime-service/src/runtime_service/sandbox_node/storage.py"
click node_runcontrol "https://github.com/hj12hj/ai-agent-platform/blob/main/apps/runtime-service/src/runtime_service/run_control/service.py"
click node_background "https://github.com/hj12hj/ai-agent-platform/blob/main/apps/runtime-service/src/runtime_service/background_tasks/service.py"
click node_agentgraphs "https://github.com/hj12hj/ai-agent-platform/tree/main/apps/runtime-service"
click node_tools "https://github.com/hj12hj/ai-agent-platform/tree/main/apps/runtime-service"
click node_memory "https://github.com/hj12hj/ai-agent-platform/tree/main/apps/runtime-service/src/runtime_service/services/dearflow_agent"
click node_approvals "https://github.com/hj12hj/ai-agent-platform/tree/main/apps/runtime-service"
click node_observability "https://github.com/hj12hj/ai-agent-platform/blob/main/apps/runtime-service/src/runtime_service/observability/query.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_webchat,node_websession,node_webtasks,node_user toneBlue
class node_api,node_gateway,node_projects,node_threadacl,node_catalog,node_policies toneAmber
class node_runtime,node_sandbox,node_workspacefiles,node_runcontrol,node_background toneMint
class node_agentgraphs,node_tools,node_memory,node_approvals,node_observability toneRose
class node_model,node_mcp toneIndigo
```

## Components

### User Console

- [Chat Workspace](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-web/src/modules/chat/components/ChatSession.vue): `apps/platform-web/src/modules/chat/components/ChatSession.vue`
- [Session Client](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-web/src/services/threads/session.service.ts): `apps/platform-web/src/services/threads/session.service.ts`
- [Task Console](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-web/src/modules/chat/composables/useBackgroundTasks.ts): `apps/platform-web/src/modules/chat/composables/useBackgroundTasks.ts`

### Platform Governance

- [Platform API](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-api/src/platform_api/main.py): `apps/platform-api/src/platform_api/main.py`
- [Runtime Gateway](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-api/src/platform_api/modules/runtime_gateway/application/service.py): `apps/platform-api/src/platform_api/modules/runtime_gateway/application/service.py`
- [Project Governance](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-api/src/platform_api/modules/projects/repository.py): `apps/platform-api/src/platform_api/modules/projects/repository.py`
- [Thread Access](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-api/src/platform_api/modules/runtime_gateway/application/thread_access.py): `apps/platform-api/src/platform_api/modules/runtime_gateway/application/thread_access.py`
- [Model Catalog](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-api/src/platform_api/modules/runtime_catalog/application/service.py): `apps/platform-api/src/platform_api/modules/runtime_catalog/application/service.py`
- [Runtime Policies](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/platform-api/src/platform_api/modules/runtime_policies/application/service.py): `apps/platform-api/src/platform_api/modules/runtime_policies/application/service.py`

### Agent Execution

- [Runtime Service](https://github.com/hj12hj/ai-agent-platform/tree/main/apps/runtime-service): `apps/runtime-service`
- [Workspace Sandbox](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/runtime-service/src/runtime_service/sandbox_node/engine.py): `apps/runtime-service/src/runtime_service/sandbox_node/engine.py`
- [Workspace Storage](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/runtime-service/src/runtime_service/sandbox_node/storage.py): `apps/runtime-service/src/runtime_service/sandbox_node/storage.py`
- [Run Control](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/runtime-service/src/runtime_service/run_control/service.py): `apps/runtime-service/src/runtime_service/run_control/service.py`
- [Background Tasks](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/runtime-service/src/runtime_service/background_tasks/service.py): `apps/runtime-service/src/runtime_service/background_tasks/service.py`

### Agent Capabilities

- [Agent Graphs](https://github.com/hj12hj/ai-agent-platform/tree/main/apps/runtime-service): `apps/runtime-service`
- [Tools and MCP](https://github.com/hj12hj/ai-agent-platform/tree/main/apps/runtime-service): `apps/runtime-service`
- [Memory Pipeline](https://github.com/hj12hj/ai-agent-platform/tree/main/apps/runtime-service/src/runtime_service/services/dearflow_agent): `apps/runtime-service/src/runtime_service/services/dearflow_agent`
- [HITL Approvals](https://github.com/hj12hj/ai-agent-platform/tree/main/apps/runtime-service): `apps/runtime-service`
- [Run Diagnostics](https://github.com/hj12hj/ai-agent-platform/blob/main/apps/runtime-service/src/runtime_service/observability/query.py): `apps/runtime-service/src/runtime_service/observability/query.py`

### Other components

- **Platform User**
- **LLM Provider**
- **MCP Services**

## Connections

- Platform User → Chat Workspace: submits prompt (evidence: `README.md`)
- Chat Workspace → Session Client: sends session requests (evidence: `README.md`)
- Session Client → Platform API: calls platform APIs (evidence: `README.md`)
- Platform API → Runtime Gateway: routes requests (evidence: `apps/platform-api/src/platform_api/main.py`)
- Runtime Gateway → Project Governance: checks project scope (evidence: `apps/platform-api/src/platform_api/modules/runtime_gateway/application/service.py`)
- Runtime Gateway → Thread Access: enforces thread access (evidence: `apps/platform-api/src/platform_api/modules/runtime_gateway/application/service.py`)
- Runtime Gateway → Model Catalog: loads model settings (evidence: `README.md`)
- Runtime Gateway → Runtime Policies: applies runtime policy (evidence: `apps/platform-api/src/platform_api/modules/runtime_gateway/application/service.py`)
- Runtime Gateway → Runtime Service: forwards managed contract (evidence: `README.md`)
- Runtime Service → Agent Graphs: executes graphs (evidence: `README.md`)
- Agent Graphs → LLM Provider: requests inference (evidence: `README.md`)
- Agent Graphs → Tools and MCP: dispatches tool calls (evidence: `README.md`)
- Tools and MCP → MCP Services: invokes MCP tools (evidence: `README.md`)
- Agent Graphs → HITL Approvals: pauses for approval (evidence: `README.md`)
- Runtime Service → Run Control: manages run state
- Runtime Service → Background Tasks: schedules background work
- Runtime Service → Workspace Sandbox: provides workspace execution (evidence: `apps/runtime-service/src/runtime_service/sandbox_node/engine.py`)
- Workspace Sandbox → Workspace Storage: reads and writes files (evidence: `apps/runtime-service/src/runtime_service/sandbox_node/storage.py`)
- Agent Graphs → Memory Pipeline: uses long-term memory (evidence: `README.md`)
- Runtime Service → Run Diagnostics: reports execution diagnostics (evidence: `apps/runtime-service/src/runtime_service/observability/query.py`)
- Runtime Service → Session Client: streams run events (evidence: `README.md`)
- Chat Workspace → Task Console: shows task updates
