# pkritjha-quantum/ai-agent-for-cybersecurity-incident-response architecture

> Architecture diagram of the GitHub repository pkritjha-quantum/ai-agent-for-cybersecurity-incident-response, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response
- Repository: https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response

## Overview

This repository combines a CyberGuard incident-response chat application with a separate simulated security-log pipeline. The main user flow is browser prompt → Flask chat route → response generation, with optional threat analysis and persisted history, then JSON response rendered in the UI. The pipeline separately generates noisy logs, cleans them into CSV, and evaluates login anomalies for remediation. The graph reflects documented and excerpted calls; no real external AI provider is shown, and the incident echo API remains a separate placeholder.

Main entry points: [`src/api.py`](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/api.py) (Flask API), [`frontend/script.js`](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/frontend/script.js) (Chat interface), [`src/log_parser.py`](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/log_parser.py) (Log cleaner), [`src/remediation_control.py`](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/remediation_control.py) (Anomaly evaluator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_frontend["Chat interface<br/>[script.js]"]
end

subgraph group_service["Chat service"]
  node_api["Flask API<br/>[api.py]"]
  node_response_engine["Response generation<br/>[api.py]"]
  node_incident_api["Incident endpoint<br/>[app.py]"]
end

subgraph group_history["Chat history"]
  node_history_routes["History routes<br/>[history_routes.py]"]
  node_history_logic["History operations<br/>[chat_history.py]"]
  node_history_db[("SQLite history<br/>[db.py]")]
end

subgraph group_pipeline["Threat pipeline"]
  node_simulator["Log simulator"]
  node_raw_logs["Raw log file<br/>[raw_logs.txt]"]
  node_parser["Log cleaner<br/>[log_parser.py]"]
  node_clean_logs["Clean CSV<br/>[cleaned_logs.csv]"]
  node_orchestrator["Pipeline runner<br/>[main.py]"]
end

subgraph group_response["Security response"]
  node_controls["Anomaly evaluator"]
  node_settings["Security settings"]
  node_blacklist["Firewall blacklist"]
end

node_user(("Responder"))

node_user -->|"enters prompt"| node_frontend
node_frontend -->|"posts chat"| node_api
node_api -->|"generates reply"| node_response_engine
node_api -->|"runs on threat prompts"| node_simulator
node_api -->|"cleans generated logs"| node_parser
node_api -->|"evaluates anomalies"| node_controls
node_api -->|"saves exchange"| node_history_logic
node_api -->|"reads history"| node_history_logic
node_history_routes -->|"delegates history"| node_history_logic
node_history_logic -->|"queries SQLite"| node_history_db
node_frontend -.->|"requests history"| node_history_routes
node_simulator -->|"writes logs"| node_raw_logs
node_parser -->|"reads logs"| node_raw_logs
node_parser -->|"writes CSV"| node_clean_logs
node_orchestrator -->|"runs generator"| node_simulator
node_orchestrator -->|"runs cleaner"| node_parser
node_orchestrator -->|"evaluates IP"| node_controls
node_controls -->|"loads thresholds"| node_settings
node_controls -->|"records blocked IP"| node_blacklist
node_api -->|"returns JSON"| node_frontend

click node_frontend "https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/frontend/script.js"
click node_api "https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/api.py"
click node_response_engine "https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/api.py"
click node_incident_api "https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/app.py"
click node_history_routes "https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/history/history_routes.py"
click node_history_logic "https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/history/chat_history.py"
click node_history_db "https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/history/db.py"
click node_simulator "https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/threat_simulator.py"
click node_raw_logs "https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/data/raw_logs.txt"
click node_parser "https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/log_parser.py"
click node_clean_logs "https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/data/cleaned_logs.csv"
click node_orchestrator "https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/main.py"
click node_controls "https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/remediation_control.py"
click node_settings "https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/security_config.json"
click node_blacklist "https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/tree/main/data"

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_frontend toneBlue
class node_api,node_response_engine,node_incident_api toneAmber
class node_history_routes,node_history_logic,node_history_db toneMint
class node_simulator,node_raw_logs,node_parser,node_clean_logs,node_orchestrator toneRose
class node_controls,node_settings,node_blacklist,node_user toneIndigo
```

## Components

### Web client

- [Chat interface](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/frontend/script.js): `frontend/script.js`

### Chat service

- [Flask API](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/api.py): `src/api.py`
- [Response generation](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/api.py): `src/api.py`
- [Incident endpoint](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/app.py): `src/app.py`

### Chat history

- [History routes](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/history/history_routes.py): `src/history/history_routes.py`
- [History operations](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/history/chat_history.py): `src/history/chat_history.py`
- [SQLite history](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/history/db.py): `src/history/db.py`

### Threat pipeline

- [Log simulator](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/threat_simulator.py): `src/threat_simulator.py`
- [Raw log file](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/data/raw_logs.txt): `data/raw_logs.txt`
- [Log cleaner](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/log_parser.py): `src/log_parser.py`
- [Clean CSV](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/data/cleaned_logs.csv): `data/cleaned_logs.csv`
- [Pipeline runner](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/main.py): `src/main.py`

### Security response

- [Anomaly evaluator](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/remediation_control.py): `src/remediation_control.py`
- [Security settings](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/blob/main/src/security_config.json): `src/security_config.json`
- [Firewall blacklist](https://github.com/pkritjha-quantum/ai-agent-for-cybersecurity-incident-response/tree/main/data): `data`

### Other components

- **Responder**

## Connections

- Responder → Chat interface: enters prompt (evidence: `README.md`)
- Chat interface → Flask API: posts chat (evidence: `frontend/script.js`)
- Flask API → Response generation: generates reply (evidence: `src/api.py`)
- Flask API → Log simulator: runs on threat prompts (evidence: `src/api.py`)
- Flask API → Log cleaner: cleans generated logs (evidence: `src/api.py`)
- Flask API → Anomaly evaluator: evaluates anomalies (evidence: `src/api.py`)
- Flask API → History operations: saves exchange (evidence: `src/api.py`)
- Flask API → History operations: reads history (evidence: `src/api.py`)
- History routes → History operations: delegates history (evidence: `src/history/history_routes.py`)
- History operations → SQLite history: queries SQLite (evidence: `src/history/chat_history.py`)
- Chat interface → History routes: requests history
- Log simulator → Raw log file: writes logs (evidence: `src/threat_simulator.py`)
- Log cleaner → Raw log file: reads logs (evidence: `src/log_parser.py`)
- Log cleaner → Clean CSV: writes CSV (evidence: `src/log_parser.py`)
- Pipeline runner → Log simulator: runs generator (evidence: `src/main.py`)
- Pipeline runner → Log cleaner: runs cleaner (evidence: `src/main.py`)
- Pipeline runner → Anomaly evaluator: evaluates IP (evidence: `src/main.py`)
- Anomaly evaluator → Security settings: loads thresholds (evidence: `src/remediation_control.py`)
- Anomaly evaluator → Firewall blacklist: records blocked IP (evidence: `src/remediation_control.py`)
- Flask API → Chat interface: returns JSON (evidence: `src/api.py`)
