# albinjacob/cybersec-agent architecture

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

- Interactive diagram: https://gitdiagram.com/albinjacob/cybersec-agent
- Repository: https://github.com/albinjacob/cybersec-agent

## Overview

#### Purpose and Entry Points
This repository is a multi-agent cybersecurity analysis pipeline. It ingests authentication logs, container/dependency artifacts, and policy data; detects threats and vulnerabilities; correlates intelligence and controls; produces remediation guidance; optionally dispatches alerts; and generates a traceable Markdown report.

Primary entry points:
- Gradio demo/UI: `app.py`
- CLI execution and report/state persistence: `main.py`
- Pipeline assembly: `orchestrator.py`

#### Orchestration and Shared State
`orchestrator.py` builds the LangGraph `StateGraph` that carries one shared investigation state through agent stages. The graph is the central control boundary: agents contribute structured findings rather than directly invoking one another.

Independent initial branches analyze logs and build artifacts, then converge for correlation. Subsequent response and policy stages consume combined findings; notification is terminal. Shared model access and offline reasoning behavior are centralized in `agents/llm.py`.

Paths: `orchestrator.py`, `agents/llm.py`, `main.py`

#### Detection Inputs and Parallel Analysis
The log-monitor branch parses authentication/security events to identify brute-force, reconnaissance, and port-scan signals. The vulnerability branch evaluates Docker and dependency posture, preferring Trivy when installed and otherwise applying static checks against bundled CVE data.

These branches operate on distinct evidence sources before their results join downstream.

Paths: `agents/log_monitor.py`, `agents/vuln_scanner.py`, `data/sample_auth.log`, `data/Dockerfile`, `data/requirements.txt`

#### Threat Correlation and Intelligence Boundary
Threat intelligence consumes findings from both initial branches and enriches surfaced CVEs or attack patterns. It calls the public NVD REST API when reachable, with `data/cve_dataset.json` as an offline fallback. This keeps external threat-feed availability from blocking an investigation.

Paths: `agents/threat_intel.py`, `data/cve_dataset.json`, `agents/embeddings.py`

#### Response and Policy Analysis
Incident response converts correlated findings into a prioritized remediation/action plan. Policy checking maps gaps to security controls using semantic retrieval over the full cached NIST 800-53 catalog, with a TF-IDF-style fallback over a smaller policy excerpt when semantic resources are unavailable.

This separates operational remediation from compliance/control evidence while allowing both to use the same combined findings.

Paths: `agents/incident_response.py`, `agents/policy_checker.py`, `data/nist_800_53_catalog.json`, `data/policy_index_vectors.npy`, `data/policy_excerpt.md`

#### Notification Action Stage
Notification is a terminal side-effect stage rather than a reasoning agent. It evaluates configured severity thresholds and dispatches qualifying findings to Slack webhooks and/or Gmail SMTP. Missing credentials or channels produce a labeled skipped result, preserving pipeline completion.

Configuration can arrive from the UI session or environment variables; secrets are not repository-owned.

Paths: `agents/notify.py`, `app.py`, `.env.example`

#### Presentation, Reporting, and Deployment
`app.py` is a thin Gradio layer over pipeline execution, while `ui_render.py` holds UI presentation formatting without Gradio coupling. CLI runs write the aggregate report and state under `output/`; `report_builder.py` assembles stage outputs into Markdown.

Runtime dependencies include Python, LangGraph, optional Trivy, optional LLM providers (Anthropic/OpenAI/OpenRouter), NVD, Slack, and Gmail SMTP. Render deployment support installs Trivy during builds.

Paths: `report_builder.py`, `ui_render.py`, `output/report.md`, `render.yaml`, `scripts/render_build.sh`

Main entry points: [`agents/threat_intel.py`](https://github.com/albinjacob/cybersec-agent/blob/master/agents/threat_intel.py) (Threat intelligence), [`orchestrator.py`](https://github.com/albinjacob/cybersec-agent/blob/master/orchestrator.py) (LangGraph pipeline), [`agents/log_monitor.py`](https://github.com/albinjacob/cybersec-agent/blob/master/agents/log_monitor.py) (Log monitor), [`agents/policy_checker.py`](https://github.com/albinjacob/cybersec-agent/blob/master/agents/policy_checker.py) (Policy checker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry &amp; Presentation"]
  node_ui["Gradio UI<br/>entrypoint<br/>[app.py]"]
  node_cli["CLI runner<br/>entrypoint<br/>[main.py]"]
  node_ui_render["UI formatter<br/>presentation<br/>[ui_render.py]"]
end

subgraph group_analysis["Analysis Pipeline"]
  node_orchestrator{{"LangGraph pipeline<br/>orchestrator<br/>[orchestrator.py]"}}
  node_llm["Model access<br/>shared runtime<br/>[llm.py]"]
  node_log_monitor["Log monitor<br/>analysis agent<br/>[log_monitor.py]"]
  node_vuln_scanner["Vulnerability scanner<br/>analysis agent<br/>[vuln_scanner.py]"]
  node_threat_intel["Threat intelligence<br/>correlation agent<br/>[threat_intel.py]"]
  node_incident_response["Incident response<br/>response agent"]
  node_policy_checker["Policy checker<br/>compliance agent<br/>[policy_checker.py]"]
end

subgraph group_knowledge["Knowledge &amp; External Services"]
  node_auth_log["Authentication log<br/>evidence<br/>[sample_auth.log]"]
  node_build_artifacts["Container dependencies<br/>evidence"]
  node_nvd[("NVD API<br/>external feed")]
  node_cve_dataset[("Bundled CVE dataset<br/>offline fallback<br/>[cve_dataset.json]")]
  node_policy_catalog[("NIST control catalog<br/>policy knowledge")]
  node_policy_excerpt["Policy excerpt<br/>retrieval fallback<br/>[policy_excerpt.md]"]
end

subgraph group_output["Output &amp; Actions"]
  node_notify["Notification dispatcher<br/>terminal action<br/>[notify.py]"]
  node_report_builder["Markdown report builder<br/>reporting<br/>[report_builder.py]"]
  node_report["Investigation report<br/>artifact<br/>[report.md]"]
  node_alert_channels["Slack / Gmail<br/>external action"]
end

node_ui -->|"starts run"| node_orchestrator
node_cli -->|"starts run"| node_orchestrator
node_ui -->|"renders results"| node_ui_render
node_orchestrator -->|"parallel branch"| node_log_monitor
node_orchestrator -->|"parallel branch"| node_vuln_scanner
node_auth_log -->|"events"| node_log_monitor
node_build_artifacts -->|"artifacts"| node_vuln_scanner
node_log_monitor -->|"attack findings"| node_threat_intel
node_vuln_scanner -->|"vulnerability findings"| node_threat_intel
node_nvd -->|"online enrichment"| node_threat_intel
node_cve_dataset -.->|"offline fallback"| node_threat_intel
node_threat_intel -->|"correlated findings"| node_incident_response
node_threat_intel -->|"combined findings"| node_policy_checker
node_policy_catalog -->|"semantic retrieval"| node_policy_checker
node_policy_excerpt -.->|"TF-IDF fallback"| node_policy_checker
node_llm -->|"shared reasoning"| node_log_monitor
node_llm -->|"shared reasoning"| node_threat_intel
node_llm -->|"shared reasoning"| node_incident_response
node_incident_response -->|"action plan"| node_notify
node_policy_checker -->|"control gaps"| node_notify
node_notify -->|"qualifying alerts"| node_alert_channels
node_orchestrator -->|"aggregate state"| node_report_builder
node_report_builder -->|"writes Markdown"| node_report

click node_ui "https://github.com/albinjacob/cybersec-agent/blob/master/app.py"
click node_cli "https://github.com/albinjacob/cybersec-agent/blob/master/main.py"
click node_ui_render "https://github.com/albinjacob/cybersec-agent/blob/master/ui_render.py"
click node_orchestrator "https://github.com/albinjacob/cybersec-agent/blob/master/orchestrator.py"
click node_llm "https://github.com/albinjacob/cybersec-agent/blob/master/agents/llm.py"
click node_log_monitor "https://github.com/albinjacob/cybersec-agent/blob/master/agents/log_monitor.py"
click node_vuln_scanner "https://github.com/albinjacob/cybersec-agent/blob/master/agents/vuln_scanner.py"
click node_threat_intel "https://github.com/albinjacob/cybersec-agent/blob/master/agents/threat_intel.py"
click node_incident_response "https://github.com/albinjacob/cybersec-agent/blob/master/agents/incident_response.py"
click node_policy_checker "https://github.com/albinjacob/cybersec-agent/blob/master/agents/policy_checker.py"
click node_notify "https://github.com/albinjacob/cybersec-agent/blob/master/agents/notify.py"
click node_report_builder "https://github.com/albinjacob/cybersec-agent/blob/master/report_builder.py"
click node_report "https://github.com/albinjacob/cybersec-agent/blob/master/output/report.md"
click node_auth_log "https://github.com/albinjacob/cybersec-agent/blob/master/data/sample_auth.log"
click node_build_artifacts "https://github.com/albinjacob/cybersec-agent/blob/master/data/Dockerfile"
click node_cve_dataset "https://github.com/albinjacob/cybersec-agent/blob/master/data/cve_dataset.json"
click node_policy_catalog "https://github.com/albinjacob/cybersec-agent/blob/master/data/nist_800_53_catalog.json"
click node_policy_excerpt "https://github.com/albinjacob/cybersec-agent/blob/master/data/policy_excerpt.md"

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,node_cli,node_ui_render toneBlue
class node_orchestrator,node_llm,node_log_monitor,node_vuln_scanner,node_threat_intel,node_incident_response,node_policy_checker toneAmber
class node_auth_log,node_build_artifacts,node_nvd,node_cve_dataset,node_policy_catalog,node_policy_excerpt toneMint
class node_notify,node_report_builder,node_report,node_alert_channels toneRose
```

## Components

### Entry & Presentation

- [Gradio UI](https://github.com/albinjacob/cybersec-agent/blob/master/app.py): entrypoint · Starts investigations from an interactive session. · `app.py`
- [CLI runner](https://github.com/albinjacob/cybersec-agent/blob/master/main.py): entrypoint · Executes runs and persists report and state. · `main.py`
- [UI formatter](https://github.com/albinjacob/cybersec-agent/blob/master/ui_render.py): presentation · `ui_render.py`

### Analysis Pipeline

- [LangGraph pipeline](https://github.com/albinjacob/cybersec-agent/blob/master/orchestrator.py): orchestrator · Shared investigation state joins parallel findings before downstream stages. · `orchestrator.py`
- [Model access](https://github.com/albinjacob/cybersec-agent/blob/master/agents/llm.py): shared runtime · Centralizes provider access and offline reasoning behavior. · `agents/llm.py`
- [Log monitor](https://github.com/albinjacob/cybersec-agent/blob/master/agents/log_monitor.py): analysis agent · Detects authentication attacks and reconnaissance signals. · `agents/log_monitor.py`
- [Vulnerability scanner](https://github.com/albinjacob/cybersec-agent/blob/master/agents/vuln_scanner.py): analysis agent · Uses Trivy when available, otherwise static CVE checks. · `agents/vuln_scanner.py`
- [Threat intelligence](https://github.com/albinjacob/cybersec-agent/blob/master/agents/threat_intel.py): correlation agent · Enriches CVEs and attack patterns from joined findings. · `agents/threat_intel.py`
- [Incident response](https://github.com/albinjacob/cybersec-agent/blob/master/agents/incident_response.py): response agent · Produces prioritized remediation actions. · `agents/incident_response.py`
- [Policy checker](https://github.com/albinjacob/cybersec-agent/blob/master/agents/policy_checker.py): compliance agent · Maps findings to security controls through retrieval. · `agents/policy_checker.py`

### Knowledge & External Services

- [Authentication log](https://github.com/albinjacob/cybersec-agent/blob/master/data/sample_auth.log): evidence · `data/sample_auth.log`
- [Container dependencies](https://github.com/albinjacob/cybersec-agent/blob/master/data/Dockerfile): evidence · Dockerfile and Python dependency posture. · `data/Dockerfile`
- **NVD API**: external feed · Public CVE enrichment service.
- [Bundled CVE dataset](https://github.com/albinjacob/cybersec-agent/blob/master/data/cve_dataset.json): offline fallback · `data/cve_dataset.json`
- [NIST control catalog](https://github.com/albinjacob/cybersec-agent/blob/master/data/nist_800_53_catalog.json): policy knowledge · Cached NIST 800-53 catalog and vector index. · `data/nist_800_53_catalog.json`
- [Policy excerpt](https://github.com/albinjacob/cybersec-agent/blob/master/data/policy_excerpt.md): retrieval fallback · `data/policy_excerpt.md`

### Output & Actions

- [Notification dispatcher](https://github.com/albinjacob/cybersec-agent/blob/master/agents/notify.py): terminal action · Sends qualifying alerts or records a skipped result. · `agents/notify.py`
- [Markdown report builder](https://github.com/albinjacob/cybersec-agent/blob/master/report_builder.py): reporting · Assembles aggregate stage outputs into a report. · `report_builder.py`
- [Investigation report](https://github.com/albinjacob/cybersec-agent/blob/master/output/report.md): artifact · `output/report.md`
- **Slack / Gmail**: external action · Webhook and SMTP alert channels.

## Connections

- Gradio UI → LangGraph pipeline: starts run
- CLI runner → LangGraph pipeline: starts run
- Gradio UI → UI formatter: renders results
- LangGraph pipeline → Log monitor: parallel branch
- LangGraph pipeline → Vulnerability scanner: parallel branch
- Authentication log → Log monitor: events
- Container dependencies → Vulnerability scanner: artifacts
- Log monitor → Threat intelligence: attack findings
- Vulnerability scanner → Threat intelligence: vulnerability findings
- NVD API → Threat intelligence: online enrichment
- Bundled CVE dataset → Threat intelligence: offline fallback
- Threat intelligence → Incident response: correlated findings
- Threat intelligence → Policy checker: combined findings
- NIST control catalog → Policy checker: semantic retrieval
- Policy excerpt → Policy checker: TF-IDF fallback
- Model access → Log monitor: shared reasoning
- Model access → Threat intelligence: shared reasoning
- Model access → Incident response: shared reasoning
- Incident response → Notification dispatcher: action plan
- Policy checker → Notification dispatcher: control gaps
- Notification dispatcher → Slack / Gmail: qualifying alerts
- LangGraph pipeline → Markdown report builder: aggregate state
- Markdown report builder → Investigation report: writes Markdown
