# user-waron/hackathon architecture

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

- Interactive diagram: https://gitdiagram.com/user-waron/hackathon
- Repository: https://github.com/user-waron/hackathon

## Overview

ShadowGuard is an AI security gateway for tool actions, with a security-operations UI. The main flow is a user chat request through the API and agent to a guarded tool invocation; the interceptor evaluates intent, trust, policy, and taint, then simulates risky SQL and may stage it for human approval. Approved actions and audit events are persisted, while the UI exposes approvals, integrations, and live security events. The README content was unavailable, so capability coverage relies on the provided tree and source excerpts; unsampled subsystem links are omitted where invocation evidence is missing.

Main entry points: [`backend/app/security/interceptor.py`](https://github.com/user-waron/hackathon/blob/main/backend/app/security/interceptor.py) (Action interceptor), [`frontend/src/App.jsx`](https://github.com/user-waron/hackathon/blob/main/frontend/src/App.jsx) (Security console), [`backend/app/main.py`](https://github.com/user-waron/hackathon/blob/main/backend/app/main.py) (HTTP and event API), [`backend/app/database.py`](https://github.com/user-waron/hackathon/blob/main/backend/app/database.py) (Application database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Operations UI"]
  node_ui["Security console<br/>[App.jsx]"]
end

subgraph group_api["API and agent"]
  node_api_server["HTTP and event API<br/>[main.py]"]
  node_chat_api["Chat endpoint<br/>[chat.py]"]
  node_approval_api["Approval endpoint<br/>[approvals.py]"]
  node_integration_api["Integration settings<br/>[integrations.py]"]
  node_event_api["Event endpoint<br/>[events.py]"]
  node_agent["AI agent<br/>[agent.py]"]
  node_mcp["MCP server<br/>[mcp_server.py]"]
end

subgraph group_security["Guarded execution"]
  node_interceptor["Action interceptor<br/>[interceptor.py]"]
  node_intent["Intent guard<br/>[intent_guard.py]"]
  node_action_classifier["Action classifier"]
  node_risk["SQL risk analysis<br/>[risk_engine.py]"]
  node_response_guard["Response guard<br/>[response_guard.py]"]
  node_synthesizer["Safe response synthesis"]
  node_trust_registry["Tool trust registry<br/>[registry.py]"]
  node_ml_models["ML security models<br/>[ml_models.py]"]
  node_approval_manager["Approval manager<br/>[approvals.py]"]
  node_shadow_state["SQL shadow simulation<br/>[shadow_state.py]"]
end

subgraph group_state["Security state"]
  node_taint["Session taint<br/>[taint.py]"]
  node_audit["Audit logging<br/>[audit.py]"]
  node_database[("Application database<br/>[database.py]")]
end

node_user(("Operator"))
node_model_service["LLM provider"]
node_approver(("Human approver"))
node_tool_service["External tools"]

node_user -->|"uses"| node_ui
node_ui -->|"submits chat"| node_chat_api
node_api_server -->|"registers route"| node_chat_api
node_api_server -->|"registers route"| node_approval_api
node_api_server -->|"registers route"| node_integration_api
node_api_server -->|"serves events"| node_event_api
node_chat_api -->|"runs agent"| node_agent
node_agent -.->|"requests completion"| node_model_service
node_agent -->|"executes tool"| node_interceptor
node_interceptor -->|"checks intent"| node_intent
node_interceptor -->|"classifies action"| node_action_classifier
node_interceptor -->|"evaluates trust"| node_trust_registry
node_interceptor -->|"classifies with"| node_ml_models
node_interceptor -->|"checks SQL"| node_risk
node_interceptor -->|"simulates action"| node_shadow_state
node_interceptor -->|"stages approval"| node_approval_manager
node_interceptor -->|"checks session"| node_taint
node_interceptor -->|"records events"| node_audit
node_interceptor -.->|"dispatches tool"| node_tool_service
node_interceptor -->|"checks output"| node_response_guard
node_interceptor -->|"builds response"| node_synthesizer
node_approval_api -->|"decides approval"| node_approval_manager
node_approver -->|"reviews action"| node_ui
node_ui -->|"sends decision"| node_approval_api
node_ui -->|"configures integrations"| node_integration_api
node_ui -->|"views events"| node_event_api
node_api_server -->|"initializes store"| node_database
node_approval_manager -->|"persists approvals"| node_database
node_audit -->|"writes audit trail"| node_database
node_trust_registry -->|"reads tool records"| node_database
node_shadow_state -->|"analyzes SQL"| node_risk
node_trust_registry -->|"scores trust"| node_ml_models
node_taint -->|"stores taint state"| node_database

click node_ui "https://github.com/user-waron/hackathon/blob/main/frontend/src/App.jsx"
click node_api_server "https://github.com/user-waron/hackathon/blob/main/backend/app/main.py"
click node_chat_api "https://github.com/user-waron/hackathon/blob/main/backend/app/api/chat.py"
click node_approval_api "https://github.com/user-waron/hackathon/blob/main/backend/app/api/approvals.py"
click node_integration_api "https://github.com/user-waron/hackathon/blob/main/backend/app/api/integrations.py"
click node_event_api "https://github.com/user-waron/hackathon/blob/main/backend/app/api/events.py"
click node_agent "https://github.com/user-waron/hackathon/blob/main/backend/app/agent.py"
click node_mcp "https://github.com/user-waron/hackathon/blob/main/backend/app/mcp_server.py"
click node_interceptor "https://github.com/user-waron/hackathon/blob/main/backend/app/security/interceptor.py"
click node_intent "https://github.com/user-waron/hackathon/blob/main/backend/app/security/intent_guard.py"
click node_action_classifier "https://github.com/user-waron/hackathon/blob/main/backend/app/security/action_classifier.py"
click node_risk "https://github.com/user-waron/hackathon/blob/main/backend/app/security/risk_engine.py"
click node_response_guard "https://github.com/user-waron/hackathon/blob/main/backend/app/security/response_guard.py"
click node_synthesizer "https://github.com/user-waron/hackathon/blob/main/backend/app/security/response_synthesizer.py"
click node_trust_registry "https://github.com/user-waron/hackathon/blob/main/backend/app/security/registry.py"
click node_ml_models "https://github.com/user-waron/hackathon/blob/main/backend/app/security/ml_models.py"
click node_approval_manager "https://github.com/user-waron/hackathon/blob/main/backend/app/security/approvals.py"
click node_shadow_state "https://github.com/user-waron/hackathon/blob/main/backend/app/security/shadow_state.py"
click node_taint "https://github.com/user-waron/hackathon/blob/main/backend/app/security/taint.py"
click node_audit "https://github.com/user-waron/hackathon/blob/main/backend/app/security/audit.py"
click node_database "https://github.com/user-waron/hackathon/blob/main/backend/app/database.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_ui toneBlue
class node_api_server,node_chat_api,node_approval_api,node_integration_api,node_event_api,node_agent,node_mcp toneAmber
class node_interceptor,node_intent,node_action_classifier,node_risk,node_response_guard,node_synthesizer,node_trust_registry,node_ml_models,node_approval_manager,node_shadow_state toneMint
class node_taint,node_audit,node_database toneRose
class node_user,node_model_service,node_approver,node_tool_service toneIndigo
```

## Components

### Operations UI

- [Security console](https://github.com/user-waron/hackathon/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`

### API and agent

- [HTTP and event API](https://github.com/user-waron/hackathon/blob/main/backend/app/main.py): `backend/app/main.py`
- [Chat endpoint](https://github.com/user-waron/hackathon/blob/main/backend/app/api/chat.py): `backend/app/api/chat.py`
- [Approval endpoint](https://github.com/user-waron/hackathon/blob/main/backend/app/api/approvals.py): `backend/app/api/approvals.py`
- [Integration settings](https://github.com/user-waron/hackathon/blob/main/backend/app/api/integrations.py): `backend/app/api/integrations.py`
- [Event endpoint](https://github.com/user-waron/hackathon/blob/main/backend/app/api/events.py): `backend/app/api/events.py`
- [AI agent](https://github.com/user-waron/hackathon/blob/main/backend/app/agent.py): `backend/app/agent.py`
- [MCP server](https://github.com/user-waron/hackathon/blob/main/backend/app/mcp_server.py): `backend/app/mcp_server.py`

### Guarded execution

- [Action interceptor](https://github.com/user-waron/hackathon/blob/main/backend/app/security/interceptor.py): `backend/app/security/interceptor.py`
- [Intent guard](https://github.com/user-waron/hackathon/blob/main/backend/app/security/intent_guard.py): `backend/app/security/intent_guard.py`
- [Action classifier](https://github.com/user-waron/hackathon/blob/main/backend/app/security/action_classifier.py): `backend/app/security/action_classifier.py`
- [SQL risk analysis](https://github.com/user-waron/hackathon/blob/main/backend/app/security/risk_engine.py): `backend/app/security/risk_engine.py`
- [Response guard](https://github.com/user-waron/hackathon/blob/main/backend/app/security/response_guard.py): `backend/app/security/response_guard.py`
- [Safe response synthesis](https://github.com/user-waron/hackathon/blob/main/backend/app/security/response_synthesizer.py): `backend/app/security/response_synthesizer.py`
- [Tool trust registry](https://github.com/user-waron/hackathon/blob/main/backend/app/security/registry.py): `backend/app/security/registry.py`
- [ML security models](https://github.com/user-waron/hackathon/blob/main/backend/app/security/ml_models.py): `backend/app/security/ml_models.py`
- [Approval manager](https://github.com/user-waron/hackathon/blob/main/backend/app/security/approvals.py): `backend/app/security/approvals.py`
- [SQL shadow simulation](https://github.com/user-waron/hackathon/blob/main/backend/app/security/shadow_state.py): `backend/app/security/shadow_state.py`

### Security state

- [Session taint](https://github.com/user-waron/hackathon/blob/main/backend/app/security/taint.py): `backend/app/security/taint.py`
- [Audit logging](https://github.com/user-waron/hackathon/blob/main/backend/app/security/audit.py): `backend/app/security/audit.py`
- [Application database](https://github.com/user-waron/hackathon/blob/main/backend/app/database.py): `backend/app/database.py`

### Other components

- **Operator**
- **LLM provider**
- **Human approver**
- **External tools**

## Connections

- Operator → Security console: uses (evidence: `frontend/src/App.jsx`)
- Security console → Chat endpoint: submits chat (evidence: `backend/app/api/chat.py`)
- HTTP and event API → Chat endpoint: registers route (evidence: `backend/app/main.py`)
- HTTP and event API → Approval endpoint: registers route (evidence: `backend/app/main.py`)
- HTTP and event API → Integration settings: registers route (evidence: `backend/app/main.py`)
- HTTP and event API → Event endpoint: serves events (evidence: `backend/app/main.py`)
- Chat endpoint → AI agent: runs agent (evidence: `backend/app/api/chat.py`)
- AI agent → LLM provider: requests completion (evidence: `backend/app/agent.py`)
- AI agent → Action interceptor: executes tool (evidence: `backend/app/agent.py`)
- Action interceptor → Intent guard: checks intent (evidence: `backend/app/security/interceptor.py`)
- Action interceptor → Action classifier: classifies action (evidence: `backend/app/security/interceptor.py`)
- Action interceptor → Tool trust registry: evaluates trust (evidence: `backend/app/security/interceptor.py`)
- Action interceptor → ML security models: classifies with (evidence: `backend/app/security/interceptor.py`)
- Action interceptor → SQL risk analysis: checks SQL (evidence: `backend/app/security/interceptor.py`)
- Action interceptor → SQL shadow simulation: simulates action (evidence: `backend/app/security/interceptor.py`)
- Action interceptor → Approval manager: stages approval (evidence: `backend/app/security/interceptor.py`)
- Action interceptor → Session taint: checks session (evidence: `backend/app/main.py`)
- Action interceptor → Audit logging: records events (evidence: `backend/app/main.py`)
- Action interceptor → External tools: dispatches tool
- Action interceptor → Response guard: checks output (evidence: `backend/app/security/interceptor.py`)
- Action interceptor → Safe response synthesis: builds response (evidence: `backend/app/security/interceptor.py`)
- Approval endpoint → Approval manager: decides approval (evidence: `backend/app/api/approvals.py`)
- Human approver → Security console: reviews action (evidence: `frontend/src/App.jsx`)
- Security console → Approval endpoint: sends decision (evidence: `backend/app/api/approvals.py`)
- Security console → Integration settings: configures integrations (evidence: `backend/app/api/integrations.py`)
- Security console → Event endpoint: views events (evidence: `frontend/src/App.jsx`)
- HTTP and event API → Application database: initializes store (evidence: `backend/app/main.py`)
- Approval manager → Application database: persists approvals (evidence: `backend/app/security/approvals.py`)
- Audit logging → Application database: writes audit trail (evidence: `backend/app/security/audit.py`)
- Tool trust registry → Application database: reads tool records (evidence: `backend/app/security/registry.py`)
- SQL shadow simulation → SQL risk analysis: analyzes SQL (evidence: `backend/app/security/shadow_state.py`)
- Tool trust registry → ML security models: scores trust (evidence: `backend/app/security/registry.py`)
- Session taint → Application database: stores taint state (evidence: `backend/app/security/taint.py`)
