# hoango277/k8s-hub architecture

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

- Interactive diagram: https://gitdiagram.com/hoango277/k8s-hub
- Repository: https://github.com/hoango277/k8s-hub

## Overview

K8s Hub is an AI-assisted Kubernetes operations platform. Engineers use the web app to chat with an agent, inspect proposed cluster changes, and approve them through dry-run, execution, verification, and audit; separate workflows provide RCA and reusable skills. The backend also gathers cluster evidence from observability integrations and traces LLM activity to Langfuse. The graph emphasizes documented product workflows and relationships visible in the supplied excerpts or source index; unsampled implementation details are not expanded into asserted call chains.

Main entry points: [`backend/app/modules/nl_command/agent.py`](https://github.com/hoango277/k8s-hub/blob/main/backend/app/modules/nl_command/agent.py) (Chat agent), [`backend/app/api/router.py`](https://github.com/hoango277/k8s-hub/blob/main/backend/app/api/router.py) (API router), [`frontend/src/app/api/backend/[...path]/route.ts`](https://github.com/hoango277/k8s-hub/blob/main/frontend/src/app/api/backend/%5B...path%5D/route.ts) (Backend proxy), [`backend/app/modules/rca/pipeline.py`](https://github.com/hoango277/k8s-hub/blob/main/backend/app/modules/rca/pipeline.py) (RCA pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_webchat["Chat UI<br/>[page.tsx]"]
  node_webapprovals["Approvals UI<br/>[page.tsx]"]
  node_webrca["RCA UI<br/>[page.tsx]"]
  node_webskills["Skills UI<br/>[page.tsx]"]
  node_proxy["Backend proxy<br/>[route.ts]"]
end

subgraph group_api["API and services"]
  node_app["FastAPI app<br/>[main.py]"]
  node_router["API router<br/>[router.py]"]
  node_chatapi["Chat endpoint<br/>[chat.py]"]
  node_approvalapi["Approval endpoints<br/>[approvals.py]"]
  node_rcaapi["RCA endpoints<br/>[rca.py]"]
  node_skillsapi["Skills endpoints<br/>[skills.py]"]
end

subgraph group_agent["Agent and tools"]
  node_agentcore["Chat agent<br/>[agent.py]"]
  node_safeguards["Input safeguards<br/>[injection.py]"]
  node_toolregistry["Tool registry<br/>[registry.py]"]
  node_tooldefs["Tool definitions<br/>[schema.py]"]
  node_approvalflow["Change approval flow"]
  node_skillruntime["Skill runtime"]
end

subgraph group_diagnosis["RCA"]
  node_rcapipeline["RCA pipeline<br/>[pipeline.py]"]
  node_rcareport["RCA report<br/>[report.py]"]
end

subgraph group_platform["Data and integrations"]
  node_llm["LLM client<br/>[client.py]"]
  node_database[("PostgreSQL data<br/>[session.py]")]
  node_observability["Cluster observability"]
  node_langfuse["Langfuse tracing<br/>[langfuse_client.py]"]
end

node_engineer(("Engineer"))
node_cluster{{"Kubernetes cluster"}}

node_engineer -->|"asks"| node_webchat
node_webchat -.->|"sends requests"| node_proxy
node_webapprovals -.->|"sends requests"| node_proxy
node_webrca -.->|"sends requests"| node_proxy
node_webskills -.->|"sends requests"| node_proxy
node_proxy -.->|"forwards requests"| node_app
node_app -->|"mounts"| node_router
node_router -->|"routes"| node_chatapi
node_router -->|"routes"| node_approvalapi
node_router -->|"routes"| node_rcaapi
node_router -->|"routes"| node_skillsapi
node_chatapi -->|"invokes"| node_agentcore
node_chatapi -->|"loads threads"| node_database
node_agentcore -->|"gets model"| node_llm
node_agentcore -->|"uses"| node_safeguards
node_agentcore -->|"looks up tools"| node_toolregistry
node_toolregistry -->|"builds specs"| node_tooldefs
node_agentcore -.->|"proposes changes"| node_approvalflow
node_approvalflow -->|"stores audit state"| node_database
node_approvalapi -->|"calls service"| node_approvalflow
node_approvalflow -.->|"executes approved change"| node_cluster
node_engineer -->|"reviews changes"| node_webapprovals
node_rcaapi -.->|"starts diagnosis"| node_rcapipeline
node_rcapipeline -.->|"collects evidence"| node_observability
node_rcapipeline -->|"saves analysis"| node_database
node_rcapipeline -->|"optionally reports"| node_rcareport
node_engineer -->|"reviews diagnosis"| node_webrca
node_skillsapi -.->|"uses skills"| node_skillruntime
node_agentcore -.->|"traces activity"| node_langfuse

click node_webchat "https://github.com/hoango277/k8s-hub/blob/main/frontend/src/app/(app)/chat/page.tsx"
click node_webapprovals "https://github.com/hoango277/k8s-hub/blob/main/frontend/src/app/(app)/approvals/page.tsx"
click node_webrca "https://github.com/hoango277/k8s-hub/blob/main/frontend/src/app/(app)/rca/page.tsx"
click node_webskills "https://github.com/hoango277/k8s-hub/blob/main/frontend/src/app/(app)/skills/page.tsx"
click node_proxy "https://github.com/hoango277/k8s-hub/blob/main/frontend/src/app/api/backend/%5B...path%5D/route.ts"
click node_app "https://github.com/hoango277/k8s-hub/blob/main/backend/app/main.py"
click node_router "https://github.com/hoango277/k8s-hub/blob/main/backend/app/api/router.py"
click node_chatapi "https://github.com/hoango277/k8s-hub/blob/main/backend/app/api/v1/chat.py"
click node_approvalapi "https://github.com/hoango277/k8s-hub/blob/main/backend/app/api/v1/approvals.py"
click node_rcaapi "https://github.com/hoango277/k8s-hub/blob/main/backend/app/api/v1/rca.py"
click node_skillsapi "https://github.com/hoango277/k8s-hub/blob/main/backend/app/api/v1/skills.py"
click node_agentcore "https://github.com/hoango277/k8s-hub/blob/main/backend/app/modules/nl_command/agent.py"
click node_safeguards "https://github.com/hoango277/k8s-hub/blob/main/backend/app/modules/nl_command/injection.py"
click node_toolregistry "https://github.com/hoango277/k8s-hub/blob/main/backend/app/modules/tools/registry.py"
click node_tooldefs "https://github.com/hoango277/k8s-hub/blob/main/backend/app/modules/tools/schema.py"
click node_approvalflow "https://github.com/hoango277/k8s-hub/blob/main/backend/app/services/approval_service.py"
click node_rcapipeline "https://github.com/hoango277/k8s-hub/blob/main/backend/app/modules/rca/pipeline.py"
click node_rcareport "https://github.com/hoango277/k8s-hub/blob/main/backend/app/modules/rca/report.py"
click node_skillruntime "https://github.com/hoango277/k8s-hub/tree/main/backend/app/modules/skills"
click node_llm "https://github.com/hoango277/k8s-hub/blob/main/backend/app/integrations/llm/client.py"
click node_database "https://github.com/hoango277/k8s-hub/blob/main/backend/app/db/session.py"
click node_observability "https://github.com/hoango277/k8s-hub/tree/main/backend/app/integrations"
click node_langfuse "https://github.com/hoango277/k8s-hub/blob/main/backend/app/modules/observability/langfuse_client.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_webapprovals,node_webrca,node_webskills,node_proxy toneBlue
class node_app,node_router,node_chatapi,node_approvalapi,node_rcaapi,node_skillsapi toneAmber
class node_agentcore,node_safeguards,node_toolregistry,node_tooldefs,node_approvalflow,node_skillruntime toneMint
class node_rcapipeline,node_rcareport toneRose
class node_llm,node_database,node_observability,node_langfuse,node_engineer,node_cluster toneIndigo
```

## Components

### Web application

- [Chat UI](https://github.com/hoango277/k8s-hub/blob/main/frontend/src/app/(app)/chat/page.tsx): `frontend/src/app/(app)/chat/page.tsx`
- [Approvals UI](https://github.com/hoango277/k8s-hub/blob/main/frontend/src/app/(app)/approvals/page.tsx): `frontend/src/app/(app)/approvals/page.tsx`
- [RCA UI](https://github.com/hoango277/k8s-hub/blob/main/frontend/src/app/(app)/rca/page.tsx): `frontend/src/app/(app)/rca/page.tsx`
- [Skills UI](https://github.com/hoango277/k8s-hub/blob/main/frontend/src/app/(app)/skills/page.tsx): `frontend/src/app/(app)/skills/page.tsx`
- [Backend proxy](https://github.com/hoango277/k8s-hub/blob/main/frontend/src/app/api/backend/%5B...path%5D/route.ts): `frontend/src/app/api/backend/[...path]/route.ts`

### API and services

- [FastAPI app](https://github.com/hoango277/k8s-hub/blob/main/backend/app/main.py): `backend/app/main.py`
- [API router](https://github.com/hoango277/k8s-hub/blob/main/backend/app/api/router.py): `backend/app/api/router.py`
- [Chat endpoint](https://github.com/hoango277/k8s-hub/blob/main/backend/app/api/v1/chat.py): `backend/app/api/v1/chat.py`
- [Approval endpoints](https://github.com/hoango277/k8s-hub/blob/main/backend/app/api/v1/approvals.py): `backend/app/api/v1/approvals.py`
- [RCA endpoints](https://github.com/hoango277/k8s-hub/blob/main/backend/app/api/v1/rca.py): `backend/app/api/v1/rca.py`
- [Skills endpoints](https://github.com/hoango277/k8s-hub/blob/main/backend/app/api/v1/skills.py): `backend/app/api/v1/skills.py`

### Agent and tools

- [Chat agent](https://github.com/hoango277/k8s-hub/blob/main/backend/app/modules/nl_command/agent.py): `backend/app/modules/nl_command/agent.py`
- [Input safeguards](https://github.com/hoango277/k8s-hub/blob/main/backend/app/modules/nl_command/injection.py): `backend/app/modules/nl_command/injection.py`
- [Tool registry](https://github.com/hoango277/k8s-hub/blob/main/backend/app/modules/tools/registry.py): `backend/app/modules/tools/registry.py`
- [Tool definitions](https://github.com/hoango277/k8s-hub/blob/main/backend/app/modules/tools/schema.py): `backend/app/modules/tools/schema.py`
- [Change approval flow](https://github.com/hoango277/k8s-hub/blob/main/backend/app/services/approval_service.py): `backend/app/services/approval_service.py`
- [Skill runtime](https://github.com/hoango277/k8s-hub/tree/main/backend/app/modules/skills): `backend/app/modules/skills`

### RCA

- [RCA pipeline](https://github.com/hoango277/k8s-hub/blob/main/backend/app/modules/rca/pipeline.py): `backend/app/modules/rca/pipeline.py`
- [RCA report](https://github.com/hoango277/k8s-hub/blob/main/backend/app/modules/rca/report.py): `backend/app/modules/rca/report.py`

### Data and integrations

- [LLM client](https://github.com/hoango277/k8s-hub/blob/main/backend/app/integrations/llm/client.py): `backend/app/integrations/llm/client.py`
- [PostgreSQL data](https://github.com/hoango277/k8s-hub/blob/main/backend/app/db/session.py): `backend/app/db/session.py`
- [Cluster observability](https://github.com/hoango277/k8s-hub/tree/main/backend/app/integrations): `backend/app/integrations`
- [Langfuse tracing](https://github.com/hoango277/k8s-hub/blob/main/backend/app/modules/observability/langfuse_client.py): `backend/app/modules/observability/langfuse_client.py`

### Other components

- **Engineer**
- **Kubernetes cluster**

## Connections

- Engineer → Chat UI: asks (evidence: `README.md`)
- Chat UI → Backend proxy: sends requests
- Approvals UI → Backend proxy: sends requests
- RCA UI → Backend proxy: sends requests
- Skills UI → Backend proxy: sends requests
- Backend proxy → FastAPI app: forwards requests
- FastAPI app → API router: mounts (evidence: `backend/app/main.py`)
- API router → Chat endpoint: routes (evidence: `backend/app/api/router.py`)
- API router → Approval endpoints: routes (evidence: `backend/app/api/router.py`)
- API router → RCA endpoints: routes (evidence: `backend/app/api/router.py`)
- API router → Skills endpoints: routes (evidence: `backend/app/api/router.py`)
- Chat endpoint → Chat agent: invokes (evidence: `backend/app/api/v1/chat.py`)
- Chat endpoint → PostgreSQL data: loads threads (evidence: `backend/app/api/v1/chat.py`)
- Chat agent → LLM client: gets model (evidence: `backend/app/modules/nl_command/agent.py`)
- Chat agent → Input safeguards: uses (evidence: `backend/app/modules/nl_command/agent.py`)
- Chat agent → Tool registry: looks up tools (evidence: `backend/app/modules/nl_command/agent.py`)
- Tool registry → Tool definitions: builds specs (evidence: `backend/app/modules/tools/registry.py`)
- Chat agent → Change approval flow: proposes changes
- Change approval flow → PostgreSQL data: stores audit state (evidence: `backend/app/services/approval_service.py`)
- Approval endpoints → Change approval flow: calls service (evidence: `backend/app/api/v1/approvals.py`)
- Change approval flow → Kubernetes cluster: executes approved change
- Engineer → Approvals UI: reviews changes (evidence: `README.md`)
- RCA endpoints → RCA pipeline: starts diagnosis
- RCA pipeline → Cluster observability: collects evidence
- RCA pipeline → PostgreSQL data: saves analysis (evidence: `backend/app/modules/rca/pipeline.py`)
- RCA pipeline → RCA report: optionally reports (evidence: `backend/app/modules/rca/pipeline.py`)
- Engineer → RCA UI: reviews diagnosis (evidence: `README.md`)
- Skills endpoints → Skill runtime: uses skills
- Chat agent → Langfuse tracing: traces activity
