# white-spade/skala-miniaip architecture

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

- Interactive diagram: https://gitdiagram.com/white-spade/skala-miniaip
- Repository: https://github.com/white-spade/skala-miniaip

## Overview

This is a staged AIOps incident-investigation agent, culminating in a FastAPI/browser application. The main workflow accepts an incident request, checks and clarifies service targets, plans and gates investigation tasks, gathers monitoring and runbook evidence through MCP, analyzes and writes a report, then grounds claims against sources before responding. Multi-turn session persistence and JWT access control wrap the agent. The README documents final composition; sampled excerpts confirm selected internals, but several integration edges rely on README descriptions rather than inspected implementation.

Main entry points: [`step16_react.py`](https://github.com/white-spade/skala-miniaip/blob/main/step16_react.py) (ReAct research), [`step24_integration.py`](https://github.com/white-spade/skala-miniaip/blob/main/step24_integration.py) (Integrated graph), [`step11_write.py`](https://github.com/white-spade/skala-miniaip/blob/main/step11_write.py) (Report writer), [`step21_sqlite_session.py`](https://github.com/white-spade/skala-miniaip/blob/main/step21_sqlite_session.py) (Session orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_browser["Browser UI"]
end

subgraph group_access["API and sessions"]
  node_auth_api["JWT API<br/>[step23_auth_api.py]"]
  node_sessions["Session orchestration"]
  node_session_db[("SQLite sessions")]
end

subgraph group_agent["Agent workflow"]
  node_final_graph["Integrated graph"]
  node_clarification["Target clarification"]
  node_routing["Intent routing"]
  node_planning["Task planning<br/>[step06_planning.py]"]
  node_gate["Task gate<br/>[step14_gate.py]"]
  node_research["ReAct research<br/>[step16_react.py]"]
  node_replan["Replan and validation"]
  node_analysis["Incident analysis<br/>[step15_analysis.py]"]
end

subgraph group_evidence["Evidence services"]
  node_monitoring_mcp["Monitoring MCP"]
  node_runbook_mcp["Runbook MCP"]
  node_monitoring_data["Mock monitoring data<br/>[monitoring.json]"]
  node_runbooks["Runbook documents<br/>[step12_runbook.py]"]
end

subgraph group_quality["Report quality"]
  node_report_writer["Report writer<br/>[step11_write.py]"]
  node_grounding["Evidence grounding"]
end

node_operator(("Operator"))
node_ollama{{"Ollama LLM"}}
node_langsmith{{"LangSmith tracing"}}

node_operator -->|"submits request"| node_browser
node_browser -->|"sends chat"| node_auth_api
node_auth_api -->|"runs chat"| node_sessions
node_sessions -->|"reads and writes"| node_session_db
node_sessions -->|"invokes graph"| node_final_graph
node_final_graph -->|"uses target checks"| node_clarification
node_clarification -->|"classifies request"| node_routing
node_clarification -->|"creates tasks"| node_planning
node_planning -->|"passes tasks"| node_gate
node_gate -->|"authorizes research"| node_research
node_research -->|"calls monitoring tool"| node_monitoring_mcp
node_research -->|"reads runbook"| node_runbook_mcp
node_monitoring_mcp -->|"reads"| node_monitoring_data
node_runbook_mcp -->|"serves resources"| node_runbooks
node_research -->|"returns observations"| node_replan
node_replan -->|"requests more research"| node_research
node_replan -->|"supplies evidence"| node_analysis
node_analysis -->|"provides analysis"| node_report_writer
node_report_writer -->|"submits draft"| node_grounding
node_grounding -->|"requests rewrite"| node_report_writer
node_grounding -->|"returns grounded result"| node_final_graph
node_routing -->|"classifies with"| node_ollama
node_report_writer -->|"generates report"| node_ollama
node_final_graph -.->|"traces runs"| node_langsmith

click node_browser "https://github.com/white-spade/skala-miniaip/blob/main/step24_integration_ui.html"
click node_auth_api "https://github.com/white-spade/skala-miniaip/blob/main/step23_auth_api.py"
click node_sessions "https://github.com/white-spade/skala-miniaip/blob/main/step21_sqlite_session.py"
click node_session_db "https://github.com/white-spade/skala-miniaip/blob/main/step21_sqlite_session.py"
click node_final_graph "https://github.com/white-spade/skala-miniaip/blob/main/step24_integration.py"
click node_clarification "https://github.com/white-spade/skala-miniaip/blob/main/step20_clarification_hybrid.py"
click node_routing "https://github.com/white-spade/skala-miniaip/blob/main/step05_llm_routing.py"
click node_planning "https://github.com/white-spade/skala-miniaip/blob/main/step06_planning.py"
click node_gate "https://github.com/white-spade/skala-miniaip/blob/main/step14_gate.py"
click node_research "https://github.com/white-spade/skala-miniaip/blob/main/step16_react.py"
click node_replan "https://github.com/white-spade/skala-miniaip/blob/main/step18_replan_validate.py"
click node_analysis "https://github.com/white-spade/skala-miniaip/blob/main/step15_analysis.py"
click node_report_writer "https://github.com/white-spade/skala-miniaip/blob/main/step11_write.py"
click node_grounding "https://github.com/white-spade/skala-miniaip/blob/main/step22_grounding.py"
click node_monitoring_mcp "https://github.com/white-spade/skala-miniaip/blob/main/step09_mcp_server.py"
click node_runbook_mcp "https://github.com/white-spade/skala-miniaip/blob/main/step12_mcp_server.py"
click node_monitoring_data "https://github.com/white-spade/skala-miniaip/blob/main/monitoring.json"
click node_runbooks "https://github.com/white-spade/skala-miniaip/blob/main/step12_runbook.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_browser toneBlue
class node_auth_api,node_sessions,node_session_db toneAmber
class node_final_graph,node_clarification,node_routing,node_planning,node_gate,node_research,node_replan,node_analysis toneMint
class node_monitoring_mcp,node_runbook_mcp,node_monitoring_data,node_runbooks toneRose
class node_report_writer,node_grounding,node_operator,node_ollama,node_langsmith toneIndigo
```

## Components

### User experience

- [Browser UI](https://github.com/white-spade/skala-miniaip/blob/main/step24_integration_ui.html): `step24_integration_ui.html`

### API and sessions

- [JWT API](https://github.com/white-spade/skala-miniaip/blob/main/step23_auth_api.py): `step23_auth_api.py`
- [Session orchestration](https://github.com/white-spade/skala-miniaip/blob/main/step21_sqlite_session.py): `step21_sqlite_session.py`
- [SQLite sessions](https://github.com/white-spade/skala-miniaip/blob/main/step21_sqlite_session.py): `step21_sqlite_session.py`

### Agent workflow

- [Integrated graph](https://github.com/white-spade/skala-miniaip/blob/main/step24_integration.py): `step24_integration.py`
- [Target clarification](https://github.com/white-spade/skala-miniaip/blob/main/step20_clarification_hybrid.py): `step20_clarification_hybrid.py`
- [Intent routing](https://github.com/white-spade/skala-miniaip/blob/main/step05_llm_routing.py): `step05_llm_routing.py`
- [Task planning](https://github.com/white-spade/skala-miniaip/blob/main/step06_planning.py): `step06_planning.py`
- [Task gate](https://github.com/white-spade/skala-miniaip/blob/main/step14_gate.py): `step14_gate.py`
- [ReAct research](https://github.com/white-spade/skala-miniaip/blob/main/step16_react.py): `step16_react.py`
- [Replan and validation](https://github.com/white-spade/skala-miniaip/blob/main/step18_replan_validate.py): `step18_replan_validate.py`
- [Incident analysis](https://github.com/white-spade/skala-miniaip/blob/main/step15_analysis.py): `step15_analysis.py`

### Evidence services

- [Monitoring MCP](https://github.com/white-spade/skala-miniaip/blob/main/step09_mcp_server.py): `step09_mcp_server.py`
- [Runbook MCP](https://github.com/white-spade/skala-miniaip/blob/main/step12_mcp_server.py): `step12_mcp_server.py`
- [Mock monitoring data](https://github.com/white-spade/skala-miniaip/blob/main/monitoring.json): `monitoring.json`
- [Runbook documents](https://github.com/white-spade/skala-miniaip/blob/main/step12_runbook.py): `step12_runbook.py`

### Report quality

- [Report writer](https://github.com/white-spade/skala-miniaip/blob/main/step11_write.py): `step11_write.py`
- [Evidence grounding](https://github.com/white-spade/skala-miniaip/blob/main/step22_grounding.py): `step22_grounding.py`

### Other components

- **Operator**
- **Ollama LLM**
- **LangSmith tracing**

## Connections

- Operator → Browser UI: submits request (evidence: `README.md`)
- Browser UI → JWT API: sends chat (evidence: `README.md`)
- JWT API → Session orchestration: runs chat (evidence: `README.md`)
- Session orchestration → SQLite sessions: reads and writes (evidence: `README.md`)
- Session orchestration → Integrated graph: invokes graph (evidence: `README.md`)
- Integrated graph → Target clarification: uses target checks (evidence: `README.md`)
- Target clarification → Intent routing: classifies request (evidence: `step20_clarification_hybrid.py`)
- Target clarification → Task planning: creates tasks (evidence: `step20_clarification_hybrid.py`)
- Task planning → Task gate: passes tasks (evidence: `README.md`)
- Task gate → ReAct research: authorizes research (evidence: `README.md`)
- ReAct research → Monitoring MCP: calls monitoring tool (evidence: `step16_react.py`)
- ReAct research → Runbook MCP: reads runbook (evidence: `step16_react.py`)
- Monitoring MCP → Mock monitoring data: reads (evidence: `step09_mcp_server.py`)
- Runbook MCP → Runbook documents: serves resources (evidence: `README.md`)
- ReAct research → Replan and validation: returns observations (evidence: `README.md`)
- Replan and validation → ReAct research: requests more research (evidence: `README.md`)
- Replan and validation → Incident analysis: supplies evidence (evidence: `README.md`)
- Incident analysis → Report writer: provides analysis (evidence: `step15_analysis.py`)
- Report writer → Evidence grounding: submits draft (evidence: `README.md`)
- Evidence grounding → Report writer: requests rewrite (evidence: `README.md`)
- Evidence grounding → Integrated graph: returns grounded result (evidence: `README.md`)
- Intent routing → Ollama LLM: classifies with (evidence: `step05_llm_routing.py`)
- Report writer → Ollama LLM: generates report (evidence: `step11_write.py`)
- Integrated graph → LangSmith tracing: traces runs (evidence: `README.md`)
