# iiooiioo888/linkin architecture

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

- Interactive diagram: https://gitdiagram.com/iiooiioo888/linkin
- Repository: https://github.com/iiooiioo888/linkin

## Overview

Linkin is an AI runtime and monitoring console. A user enters a query in the chat UI, can request a routing preview, then sends it through the chat API and shared execution-path decision: simple requests use the reflective generation loop, while company requests are analyzed into milestones and delegated to seats. The repository also documents integrations and memory recall, OPC sensing with guarded writes, AI Hub routing, and virtual-credit billing. The workflow edges follow the README and shown excerpts; unsampled subsystem internals are represented at their existing directory paths.

Main entry points: [`backend/core/graph.py`](https://github.com/iiooiioo888/linkin/blob/master/backend/core/graph.py) (Execution graph), [`backend/api/routers/chat/routes.py`](https://github.com/iiooiioo888/linkin/blob/master/backend/api/routers/chat/routes.py) (Chat endpoints), [`backend/company/tools.py`](https://github.com/iiooiioo888/linkin/blob/master/backend/company/tools.py) (Agent tools), [`frontend/src/components/ChatView.tsx`](https://github.com/iiooiioo888/linkin/blob/master/frontend/src/components/ChatView.tsx) (Chat UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Chat interaction"]
  node_chat_ui["Chat UI<br/>[ChatView.tsx]"]
  node_preview_ui["Route preview"]
  node_api_client["API client<br/>[index.ts]"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_chat_routes["Chat endpoints<br/>[routes.py]"]
end

subgraph group_runtime["Unified runtime"]
  node_route_preview["Route decision<br/>[execution_path.py]"]
  node_graph["Execution graph<br/>[graph.py]"]
  node_simple_loop["Reflective loop<br/>[reflection.py]"]
  node_memory[("Memory retrieval<br/>[vector_store.py]")]
  node_recall["Integration recall<br/>[recall_bridge.py]"]
end

subgraph group_company["Company execution"]
  node_company_runtime["Task manager<br/>[runtime.py]"]
  node_company_orchestrator["Seat orchestration<br/>[run.py]"]
  node_company_tools["Agent tools<br/>[tools.py]"]
end

subgraph group_platform["Platform services"]
  node_opc_context["OPC sensing<br/>[opc_degrade.py]"]
  node_opc_service["OPC UA service<br/>[app.py]"]
  node_guardrail["Write guardrail<br/>[app.py]"]
  node_hub["AI Hub<br/>[router.py]"]
  node_billing["Credits and billing<br/>[pricing_engine.py]"]
end

subgraph group_console["Monitoring console"]
  node_console_ui["Monitoring console<br/>[AppShell.tsx]"]
  node_monitor_api["Monitoring services<br/>[aggregate.py]"]
end

node_user(("User"))

node_user -->|"submits query"| node_chat_ui
node_chat_ui -->|"requests preview"| node_preview_ui
node_preview_ui -->|"calls preview API"| node_api_client
node_api_client -->|"sends chat request"| node_chat_routes
node_api_app -->|"mounts routes"| node_chat_routes
node_chat_routes -->|"builds preview"| node_route_preview
node_chat_routes -->|"invokes graph"| node_graph
node_route_preview -->|"selects execution path"| node_graph
node_graph -->|"runs simple path"| node_simple_loop
node_graph -->|"runs company path"| node_company_runtime
node_graph -->|"retrieves and saves"| node_memory
node_graph -->|"adds sensor context"| node_opc_context
node_graph -->|"adds recall context"| node_recall
node_company_runtime -->|"delegates seat work"| node_company_orchestrator
node_company_orchestrator -.->|"uses agent tools"| node_company_tools
node_opc_context -.->|"reads sensor data"| node_opc_service
node_company_tools -->|"guards writes"| node_guardrail
node_chat_routes -.->|"routes model requests"| node_hub
node_company_tools -->|"meters tool use"| node_billing
node_user -->|"views status"| node_console_ui
node_console_ui -.->|"requests monitoring"| node_monitor_api

click node_chat_ui "https://github.com/iiooiioo888/linkin/blob/master/frontend/src/components/ChatView.tsx"
click node_preview_ui "https://github.com/iiooiioo888/linkin/blob/master/frontend/src/hooks/useRoutingPreview.ts"
click node_api_client "https://github.com/iiooiioo888/linkin/blob/master/frontend/src/api/client/index.ts"
click node_api_app "https://github.com/iiooiioo888/linkin/blob/master/backend/main.py"
click node_chat_routes "https://github.com/iiooiioo888/linkin/blob/master/backend/api/routers/chat/routes.py"
click node_route_preview "https://github.com/iiooiioo888/linkin/blob/master/backend/core/execution_path.py"
click node_graph "https://github.com/iiooiioo888/linkin/blob/master/backend/core/graph.py"
click node_simple_loop "https://github.com/iiooiioo888/linkin/blob/master/backend/core/nodes/reflection.py"
click node_memory "https://github.com/iiooiioo888/linkin/blob/master/backend/memory/vector_store.py"
click node_recall "https://github.com/iiooiioo888/linkin/blob/master/backend/integrations/recall_bridge.py"
click node_company_runtime "https://github.com/iiooiioo888/linkin/blob/master/backend/services/task_manager/runtime.py"
click node_company_orchestrator "https://github.com/iiooiioo888/linkin/blob/master/backend/company/orchestrator/execution/run.py"
click node_company_tools "https://github.com/iiooiioo888/linkin/blob/master/backend/company/tools.py"
click node_opc_context "https://github.com/iiooiioo888/linkin/blob/master/backend/core/opc_degrade.py"
click node_opc_service "https://github.com/iiooiioo888/linkin/blob/master/opc_service/app.py"
click node_guardrail "https://github.com/iiooiioo888/linkin/blob/master/services/guardrail-service/app.py"
click node_hub "https://github.com/iiooiioo888/linkin/blob/master/backend/hub/router.py"
click node_billing "https://github.com/iiooiioo888/linkin/blob/master/backend/billing/pricing_engine.py"
click node_console_ui "https://github.com/iiooiioo888/linkin/blob/master/frontend/src/components/AppShell.tsx"
click node_monitor_api "https://github.com/iiooiioo888/linkin/blob/master/backend/services/agent_monitor/aggregate.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_chat_ui,node_preview_ui,node_api_client,node_api_app,node_chat_routes,node_user toneBlue
class node_route_preview,node_graph,node_simple_loop,node_memory,node_recall toneAmber
class node_company_runtime,node_company_orchestrator,node_company_tools toneMint
class node_opc_context,node_opc_service,node_guardrail,node_hub,node_billing toneRose
class node_console_ui,node_monitor_api toneIndigo
```

## Components

### Chat interaction

- [Chat UI](https://github.com/iiooiioo888/linkin/blob/master/frontend/src/components/ChatView.tsx): `frontend/src/components/ChatView.tsx`
- [Route preview](https://github.com/iiooiioo888/linkin/blob/master/frontend/src/hooks/useRoutingPreview.ts): `frontend/src/hooks/useRoutingPreview.ts`
- [API client](https://github.com/iiooiioo888/linkin/blob/master/frontend/src/api/client/index.ts): `frontend/src/api/client/index.ts`
- [FastAPI app](https://github.com/iiooiioo888/linkin/blob/master/backend/main.py): `backend/main.py`
- [Chat endpoints](https://github.com/iiooiioo888/linkin/blob/master/backend/api/routers/chat/routes.py): `backend/api/routers/chat/routes.py`

### Unified runtime

- [Route decision](https://github.com/iiooiioo888/linkin/blob/master/backend/core/execution_path.py): `backend/core/execution_path.py`
- [Execution graph](https://github.com/iiooiioo888/linkin/blob/master/backend/core/graph.py): `backend/core/graph.py`
- [Reflective loop](https://github.com/iiooiioo888/linkin/blob/master/backend/core/nodes/reflection.py): `backend/core/nodes/reflection.py`
- [Memory retrieval](https://github.com/iiooiioo888/linkin/blob/master/backend/memory/vector_store.py): `backend/memory/vector_store.py`
- [Integration recall](https://github.com/iiooiioo888/linkin/blob/master/backend/integrations/recall_bridge.py): `backend/integrations/recall_bridge.py`

### Company execution

- [Task manager](https://github.com/iiooiioo888/linkin/blob/master/backend/services/task_manager/runtime.py): `backend/services/task_manager/runtime.py`
- [Seat orchestration](https://github.com/iiooiioo888/linkin/blob/master/backend/company/orchestrator/execution/run.py): `backend/company/orchestrator/execution/run.py`
- [Agent tools](https://github.com/iiooiioo888/linkin/blob/master/backend/company/tools.py): `backend/company/tools.py`

### Platform services

- [OPC sensing](https://github.com/iiooiioo888/linkin/blob/master/backend/core/opc_degrade.py): `backend/core/opc_degrade.py`
- [OPC UA service](https://github.com/iiooiioo888/linkin/blob/master/opc_service/app.py): `opc_service/app.py`
- [Write guardrail](https://github.com/iiooiioo888/linkin/blob/master/services/guardrail-service/app.py): `services/guardrail-service/app.py`
- [AI Hub](https://github.com/iiooiioo888/linkin/blob/master/backend/hub/router.py): `backend/hub/router.py`
- [Credits and billing](https://github.com/iiooiioo888/linkin/blob/master/backend/billing/pricing_engine.py): `backend/billing/pricing_engine.py`

### Monitoring console

- [Monitoring console](https://github.com/iiooiioo888/linkin/blob/master/frontend/src/components/AppShell.tsx): `frontend/src/components/AppShell.tsx`
- [Monitoring services](https://github.com/iiooiioo888/linkin/blob/master/backend/services/agent_monitor/aggregate.py): `backend/services/agent_monitor/aggregate.py`

### Other components

- **User**

## Connections

- User → Chat UI: submits query (evidence: `README.md`)
- Chat UI → Route preview: requests preview (evidence: `README.md`)
- Route preview → API client: calls preview API (evidence: `frontend/src/hooks/useRoutingPreview.ts`)
- API client → Chat endpoints: sends chat request (evidence: `README.md`)
- FastAPI app → Chat endpoints: mounts routes (evidence: `backend/main.py`)
- Chat endpoints → Route decision: builds preview (evidence: `backend/api/routers/chat/routes.py`)
- Chat endpoints → Execution graph: invokes graph (evidence: `backend/api/routers/chat/routes.py`)
- Route decision → Execution graph: selects execution path (evidence: `README.md`)
- Execution graph → Reflective loop: runs simple path (evidence: `README.md`)
- Execution graph → Task manager: runs company path (evidence: `README.md`)
- Execution graph → Memory retrieval: retrieves and saves (evidence: `README.md`)
- Execution graph → OPC sensing: adds sensor context (evidence: `README.md`)
- Execution graph → Integration recall: adds recall context (evidence: `README.md`)
- Task manager → Seat orchestration: delegates seat work (evidence: `README.md`)
- Seat orchestration → Agent tools: uses agent tools
- OPC sensing → OPC UA service: reads sensor data
- Agent tools → Write guardrail: guards writes (evidence: `README.md`)
- Chat endpoints → AI Hub: routes model requests
- Agent tools → Credits and billing: meters tool use (evidence: `backend/company/tools.py`)
- User → Monitoring console: views status (evidence: `README.md`)
- Monitoring console → Monitoring services: requests monitoring
