# yuyan3616/aiops architecture

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

- Interactive diagram: https://gitdiagram.com/yuyan3616/aiops
- Repository: https://github.com/yuyan3616/aiops

## Overview

Pi Chat is an AIOps root-cause-analysis workspace: users investigate incidents through a chat UI, while a Main Agent coordinates hypotheses and specialist evidence gathering, then produces a validated conclusion and report. The graph also includes session lifecycle, persisted evidence, visualization, and independent evaluation. Source excerpts show key orchestration and persistence relationships; other links rely on README documentation, and unsampled implementation details are not inferred.

Main entry points: [`apps/pi-chat/server/rca/service.ts`](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/service.ts) (Investigation coordinator), [`apps/pi-chat/server/conversation/service.ts`](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/conversation/service.ts) (Conversation service), [`apps/pi-chat/src/App.tsx`](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/src/App.tsx) (Chat workspace), [`apps/pi-chat/server/rca/pi-expert.ts`](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/pi-expert.ts) (Expert sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Chat workspace"]
  node_app["Chat workspace<br/>[App.tsx]"]
  node_stream["Conversation stream"]
  node_rca_ui["Investigation details"]
  node_flow_viewer["Flow viewer"]
end

subgraph group_conversation["Conversation runtime"]
  node_conversation_routes["Conversation routes<br/>[conversation.ts]"]
  node_conversation_service["Conversation service<br/>[service.ts]"]
  node_conversation_runtime["Pi session runtime<br/>[runtime.ts]"]
  node_conversation_channel["Stream channel<br/>[channel.ts]"]
  node_conversation_store[("Conversation records<br/>[repository.ts]")]
end

subgraph group_investigation["RCA investigation"]
  node_main_agent["Main Agent"]
  node_rca_service["Investigation coordinator<br/>[service.ts]"]
  node_expert_runner["Expert sessions<br/>[pi-expert.ts]"]
  node_profiles["Expert profiles<br/>[registry.ts]"]
  node_budget["Budget controls<br/>[budget.ts]"]
end

subgraph group_evidence["Evidence and data"]
  node_tool_runtime["Observability tools<br/>[tools.ts]"]
  node_adapter["RCA100 adapter<br/>[adapter.ts]"]
  node_parquet["Parquet queries<br/>[parquet.ts]"]
  node_investigation_store[("Investigation records<br/>[repository.ts]")]
end

subgraph group_outputs["Investigation outputs"]
  node_visualization_service["Visualization service<br/>[service.ts]"]
  node_flow_builder["Flow builder<br/>[builder.ts]"]
  node_report["Final report<br/>[service.ts]"]
  node_evaluator["Independent evaluator<br/>[scorer.ts]"]
end

node_user(("User"))

node_user -->|"starts investigation"| node_app
node_app -->|"streams conversation"| node_stream
node_app -->|"opens details"| node_rca_ui
node_rca_ui -->|"renders flow"| node_flow_viewer
node_stream -->|"uses API"| node_conversation_routes
node_conversation_routes -->|"handles requests"| node_conversation_service
node_conversation_service -->|"creates runtime"| node_conversation_runtime
node_conversation_service -->|"persists records"| node_conversation_store
node_conversation_service -->|"loads investigation context"| node_rca_service
node_conversation_runtime -.->|"streams events"| node_conversation_channel
node_main_agent -->|"requests investigation actions"| node_rca_service
node_rca_service -->|"dispatches tasks"| node_expert_runner
node_expert_runner -->|"selects expertise"| node_profiles
node_expert_runner -->|"calls tools"| node_tool_runtime
node_tool_runtime -->|"queries case data"| node_adapter
node_adapter -.->|"reads telemetry"| node_parquet
node_rca_service -->|"enforces budgets"| node_budget
node_rca_service -->|"persists evidence"| node_investigation_store
node_rca_service -->|"validates conclusion"| node_report
node_rca_service -->|"requests visualization"| node_visualization_service
node_visualization_service -->|"loads and saves artifact"| node_investigation_store
node_visualization_service -->|"builds flow"| node_flow_builder
node_evaluator -->|"reads completed investigation"| node_investigation_store
node_evaluator -->|"scores after completion"| node_report

click node_app "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/src/App.tsx"
click node_stream "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/src/hooks/useConversationStream.ts"
click node_rca_ui "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/src/components/rca/InvestigationDetailDrawer.tsx"
click node_flow_viewer "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/src/components/rca/MermaidFlowViewer.tsx"
click node_conversation_routes "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/routes/conversation.ts"
click node_conversation_service "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/conversation/service.ts"
click node_conversation_runtime "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/conversation/runtime.ts"
click node_conversation_channel "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/conversation/channel.ts"
click node_conversation_store "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/conversation/repository.ts"
click node_main_agent "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/main-agent-tools.ts"
click node_rca_service "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/service.ts"
click node_expert_runner "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/pi-expert.ts"
click node_profiles "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/profiles/registry.ts"
click node_budget "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/budget.ts"
click node_tool_runtime "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/tools.ts"
click node_adapter "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/adapter.ts"
click node_parquet "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/parquet.ts"
click node_investigation_store "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/repository.ts"
click node_visualization_service "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/visualization/service.ts"
click node_flow_builder "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/visualization/builder.ts"
click node_report "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/service.ts"
click node_evaluator "https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/evaluation/scorer.ts"

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_app,node_stream,node_rca_ui,node_flow_viewer,node_user toneBlue
class node_conversation_routes,node_conversation_service,node_conversation_runtime,node_conversation_channel,node_conversation_store toneAmber
class node_main_agent,node_rca_service,node_expert_runner,node_profiles,node_budget toneMint
class node_tool_runtime,node_adapter,node_parquet,node_investigation_store toneRose
class node_visualization_service,node_flow_builder,node_report,node_evaluator toneIndigo
```

## Components

### Chat workspace

- [Chat workspace](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/src/App.tsx): `apps/pi-chat/src/App.tsx`
- [Conversation stream](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/src/hooks/useConversationStream.ts): `apps/pi-chat/src/hooks/useConversationStream.ts`
- [Investigation details](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/src/components/rca/InvestigationDetailDrawer.tsx): `apps/pi-chat/src/components/rca/InvestigationDetailDrawer.tsx`
- [Flow viewer](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/src/components/rca/MermaidFlowViewer.tsx): `apps/pi-chat/src/components/rca/MermaidFlowViewer.tsx`

### Conversation runtime

- [Conversation routes](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/routes/conversation.ts): `apps/pi-chat/server/routes/conversation.ts`
- [Conversation service](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/conversation/service.ts): `apps/pi-chat/server/conversation/service.ts`
- [Pi session runtime](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/conversation/runtime.ts): `apps/pi-chat/server/conversation/runtime.ts`
- [Stream channel](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/conversation/channel.ts): `apps/pi-chat/server/conversation/channel.ts`
- [Conversation records](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/conversation/repository.ts): `apps/pi-chat/server/conversation/repository.ts`

### RCA investigation

- [Main Agent](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/main-agent-tools.ts): `apps/pi-chat/server/rca/main-agent-tools.ts`
- [Investigation coordinator](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/service.ts): `apps/pi-chat/server/rca/service.ts`
- [Expert sessions](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/pi-expert.ts): `apps/pi-chat/server/rca/pi-expert.ts`
- [Expert profiles](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/profiles/registry.ts): `apps/pi-chat/server/rca/profiles/registry.ts`
- [Budget controls](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/budget.ts): `apps/pi-chat/server/rca/budget.ts`

### Evidence and data

- [Observability tools](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/tools.ts): `apps/pi-chat/server/rca/tools.ts`
- [RCA100 adapter](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/adapter.ts): `apps/pi-chat/server/rca/adapter.ts`
- [Parquet queries](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/parquet.ts): `apps/pi-chat/server/rca/parquet.ts`
- [Investigation records](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/repository.ts): `apps/pi-chat/server/rca/repository.ts`

### Investigation outputs

- [Visualization service](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/visualization/service.ts): `apps/pi-chat/server/rca/visualization/service.ts`
- [Flow builder](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/visualization/builder.ts): `apps/pi-chat/server/rca/visualization/builder.ts`
- [Final report](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/service.ts): `apps/pi-chat/server/rca/service.ts`
- [Independent evaluator](https://github.com/yuyan3616/aiops/blob/main/apps/pi-chat/server/rca/evaluation/scorer.ts): `apps/pi-chat/server/rca/evaluation/scorer.ts`

### Other components

- **User**

## Connections

- User → Chat workspace: starts investigation (evidence: `README.md`)
- Chat workspace → Conversation stream: streams conversation (evidence: `README.md`)
- Chat workspace → Investigation details: opens details (evidence: `apps/pi-chat/src/App.tsx`)
- Investigation details → Flow viewer: renders flow (evidence: `apps/pi-chat/src/components/rca/InvestigationDetailDrawer.tsx`)
- Conversation stream → Conversation routes: uses API (evidence: `README.md`)
- Conversation routes → Conversation service: handles requests (evidence: `README.md`)
- Conversation service → Pi session runtime: creates runtime (evidence: `apps/pi-chat/server/conversation/service.ts`)
- Conversation service → Conversation records: persists records (evidence: `apps/pi-chat/server/conversation/service.ts`)
- Conversation service → Investigation coordinator: loads investigation context (evidence: `apps/pi-chat/server/conversation/service.ts`)
- Pi session runtime → Stream channel: streams events
- Main Agent → Investigation coordinator: requests investigation actions (evidence: `README.md`)
- Investigation coordinator → Expert sessions: dispatches tasks (evidence: `apps/pi-chat/server/rca/service.ts`)
- Expert sessions → Expert profiles: selects expertise (evidence: `apps/pi-chat/server/rca/profiles/registry.ts`)
- Expert sessions → Observability tools: calls tools (evidence: `README.md`)
- Observability tools → RCA100 adapter: queries case data (evidence: `README.md`)
- RCA100 adapter → Parquet queries: reads telemetry
- Investigation coordinator → Budget controls: enforces budgets (evidence: `apps/pi-chat/server/rca/service.ts`)
- Investigation coordinator → Investigation records: persists evidence (evidence: `README.md`)
- Investigation coordinator → Final report: validates conclusion (evidence: `README.md`)
- Investigation coordinator → Visualization service: requests visualization (evidence: `apps/pi-chat/server/rca/service.ts`)
- Visualization service → Investigation records: loads and saves artifact (evidence: `apps/pi-chat/server/rca/visualization/service.ts`)
- Visualization service → Flow builder: builds flow (evidence: `apps/pi-chat/server/rca/visualization/service.ts`)
- Independent evaluator → Investigation records: reads completed investigation (evidence: `apps/pi-chat/server/rca/evaluation/scorer.ts`)
- Independent evaluator → Final report: scores after completion (evidence: `README.md`)
