# monal95/llm-based-security-copilot architecture

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

- Interactive diagram: https://gitdiagram.com/monal95/llm-based-security-copilot
- Repository: https://github.com/monal95/llm-based-security-copilot

## Overview

SecureRAG is a local RAG copilot for SOC analysts: public threat-intelligence feeds become searchable evidence, analyst queries produce grounded and claim-verified answers, and the API also exposes vulnerability triage, evidence search, MITRE details, runbooks, and evaluation results to the web UI. The core query workflow and several API calls are visible in excerpts; other product capabilities and ingestion/indexing links are documented in the README. Some UI-to-API and evaluation wiring is not shown in sampled source, so those relationships are marked unverified.

Main entry points: [`modules/pipeline.py`](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/pipeline.py) (RAG orchestrator), [`backend/main.py`](https://github.com/monal95/llm-based-security-copilot/blob/main/backend/main.py) (REST API), [`modules/Chunking/build_knowledge_base.py`](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Chunking/build_knowledge_base.py) (Chunk and embed), [`modules/retriever.py`](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/retriever.py) (Evidence search service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intelligence["Threat intelligence"]
  node_ingest["Feed ingestion"]
end

subgraph group_knowledge["Knowledge base"]
  node_kb_build["Chunk and embed"]
  node_chunker["Document chunking<br/>[chunker.py]"]
  node_embedder["Text embeddings<br/>[embedder.py]"]
  node_vector_store[("Vector index<br/>[vector_store.py]")]
  node_bm25_index[("BM25 index<br/>[bm25_index.py]")]
end

subgraph group_rag["Grounded answers"]
  node_pipeline["RAG orchestrator<br/>[pipeline.py]"]
  node_query_expand["Query expansion<br/>[query_expander.py]"]
  node_dense["Dense retrieval<br/>[dense_retriever.py]"]
  node_sparse["Sparse retrieval"]
  node_fusion["Hybrid fusion<br/>[hybrid_fusion.py]"]
  node_reranker["Evidence reranking<br/>[reranker.py]"]
  node_prompt["Grounded prompting<br/>[prompt_template.py]"]
  node_generation["Local LLM generation<br/>[llm_chain.py]"]
  node_verification["Claim verification"]
end

subgraph group_analyst["Analyst services"]
  node_retriever["Evidence search service<br/>[retriever.py]"]
  node_priority["Patch prioritization<br/>[priority_scorer.py]"]
  node_patch_explainer["Priority explanations<br/>[patch_explainer.py]"]
  node_runbook["Incident runbooks"]
  node_evaluation["Retrieval evaluation"]
end

subgraph group_interface["API and analyst UI"]
  node_ui["Analyst web views"]
  node_frontend_api["Frontend API client<br/>[api.ts]"]
  node_api["REST API<br/>[main.py]"]
end

node_feeds(("CTI feeds"))
node_analyst_user(("SOC analyst"))

node_feeds -->|"provides feeds"| node_ingest
node_ingest -->|"supplies records"| node_kb_build
node_kb_build -->|"chunks records"| node_chunker
node_kb_build -->|"embeds chunks"| node_embedder
node_kb_build -->|"builds vector index"| node_vector_store
node_kb_build -->|"builds sparse index"| node_bm25_index
node_analyst_user -.->|"uses"| node_ui
node_ui -.->|"requests data"| node_frontend_api
node_frontend_api -.->|"calls REST"| node_api
node_api -->|"runs chat"| node_pipeline
node_api -->|"requests evidence"| node_retriever
node_api -->|"scores CVEs"| node_priority
node_api -->|"requests rationale"| node_patch_explainer
node_api -->|"generates runbook"| node_runbook
node_api -.->|"serves evaluation results"| node_evaluation
node_pipeline -->|"expands query"| node_query_expand
node_pipeline -->|"retrieves dense"| node_dense
node_pipeline -->|"retrieves sparse"| node_sparse
node_pipeline -->|"fuses rankings"| node_fusion
node_pipeline -->|"reranks evidence"| node_reranker
node_pipeline -->|"constructs prompt"| node_prompt
node_pipeline -->|"generates answer"| node_generation
node_pipeline -->|"verifies claims"| node_verification
node_retriever -->|"retrieves dense"| node_dense
node_retriever -->|"retrieves sparse"| node_sparse
node_retriever -->|"fuses rankings"| node_fusion
node_retriever -->|"reranks evidence"| node_reranker

click node_ingest "https://github.com/monal95/llm-based-security-copilot/tree/main/modules/ingestion"
click node_kb_build "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Chunking/build_knowledge_base.py"
click node_chunker "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Chunking/chunker.py"
click node_embedder "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Chunking/embedder.py"
click node_vector_store "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Chunking/vector_store.py"
click node_bm25_index "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Chunking/bm25_index.py"
click node_pipeline "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/pipeline.py"
click node_query_expand "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Retrieval/query_expander.py"
click node_dense "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Retrieval/dense_retriever.py"
click node_sparse "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Retrieval/sparse_retriever.py"
click node_fusion "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Retrieval/hybrid_fusion.py"
click node_reranker "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Retrieval/reranker.py"
click node_prompt "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Generation/prompt_template.py"
click node_generation "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Generation/llm_chain.py"
click node_verification "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Verification/hallucination_guard.py"
click node_retriever "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/retriever.py"
click node_priority "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/priority_scorer.py"
click node_patch_explainer "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/patch_explainer.py"
click node_runbook "https://github.com/monal95/llm-based-security-copilot/blob/main/modules/runbook_generator.py"
click node_evaluation "https://github.com/monal95/llm-based-security-copilot/blob/main/evaluation/evaluation_engine.py"
click node_ui "https://github.com/monal95/llm-based-security-copilot/tree/main/frontend/src/components"
click node_frontend_api "https://github.com/monal95/llm-based-security-copilot/blob/main/frontend/src/services/api.ts"
click node_api "https://github.com/monal95/llm-based-security-copilot/blob/main/backend/main.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_ingest toneBlue
class node_kb_build,node_chunker,node_embedder,node_vector_store,node_bm25_index toneAmber
class node_pipeline,node_query_expand,node_dense,node_sparse,node_fusion,node_reranker,node_prompt,node_generation,node_verification toneMint
class node_retriever,node_priority,node_patch_explainer,node_runbook,node_evaluation toneRose
class node_ui,node_frontend_api,node_api,node_feeds,node_analyst_user toneIndigo
```

## Components

### Threat intelligence

- [Feed ingestion](https://github.com/monal95/llm-based-security-copilot/tree/main/modules/ingestion): `modules/ingestion`

### Knowledge base

- [Chunk and embed](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Chunking/build_knowledge_base.py): `modules/Chunking/build_knowledge_base.py`
- [Document chunking](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Chunking/chunker.py): `modules/Chunking/chunker.py`
- [Text embeddings](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Chunking/embedder.py): `modules/Chunking/embedder.py`
- [Vector index](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Chunking/vector_store.py): `modules/Chunking/vector_store.py`
- [BM25 index](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Chunking/bm25_index.py): `modules/Chunking/bm25_index.py`

### Grounded answers

- [RAG orchestrator](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/pipeline.py): `modules/pipeline.py`
- [Query expansion](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Retrieval/query_expander.py): `modules/Retrieval/query_expander.py`
- [Dense retrieval](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Retrieval/dense_retriever.py): `modules/Retrieval/dense_retriever.py`
- [Sparse retrieval](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Retrieval/sparse_retriever.py): `modules/Retrieval/sparse_retriever.py`
- [Hybrid fusion](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Retrieval/hybrid_fusion.py): `modules/Retrieval/hybrid_fusion.py`
- [Evidence reranking](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Retrieval/reranker.py): `modules/Retrieval/reranker.py`
- [Grounded prompting](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Generation/prompt_template.py): `modules/Generation/prompt_template.py`
- [Local LLM generation](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Generation/llm_chain.py): `modules/Generation/llm_chain.py`
- [Claim verification](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/Verification/hallucination_guard.py): `modules/Verification/hallucination_guard.py`

### Analyst services

- [Evidence search service](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/retriever.py): `modules/retriever.py`
- [Patch prioritization](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/priority_scorer.py): `modules/priority_scorer.py`
- [Priority explanations](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/patch_explainer.py): `modules/patch_explainer.py`
- [Incident runbooks](https://github.com/monal95/llm-based-security-copilot/blob/main/modules/runbook_generator.py): `modules/runbook_generator.py`
- [Retrieval evaluation](https://github.com/monal95/llm-based-security-copilot/blob/main/evaluation/evaluation_engine.py): `evaluation/evaluation_engine.py`

### API and analyst UI

- [Analyst web views](https://github.com/monal95/llm-based-security-copilot/tree/main/frontend/src/components): `frontend/src/components`
- [Frontend API client](https://github.com/monal95/llm-based-security-copilot/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [REST API](https://github.com/monal95/llm-based-security-copilot/blob/main/backend/main.py): `backend/main.py`

### Other components

- **CTI feeds**
- **SOC analyst**

## Connections

- CTI feeds → Feed ingestion: provides feeds
- Feed ingestion → Chunk and embed: supplies records
- Chunk and embed → Document chunking: chunks records
- Chunk and embed → Text embeddings: embeds chunks
- Chunk and embed → Vector index: builds vector index
- Chunk and embed → BM25 index: builds sparse index
- SOC analyst → Analyst web views: uses
- Analyst web views → Frontend API client: requests data
- Frontend API client → REST API: calls REST
- REST API → RAG orchestrator: runs chat (evidence: `backend/main.py`)
- REST API → Evidence search service: requests evidence (evidence: `backend/main.py`)
- REST API → Patch prioritization: scores CVEs (evidence: `backend/main.py`)
- REST API → Priority explanations: requests rationale (evidence: `backend/main.py`)
- REST API → Incident runbooks: generates runbook (evidence: `backend/main.py`)
- REST API → Retrieval evaluation: serves evaluation results
- RAG orchestrator → Query expansion: expands query (evidence: `modules/pipeline.py`)
- RAG orchestrator → Dense retrieval: retrieves dense (evidence: `modules/pipeline.py`)
- RAG orchestrator → Sparse retrieval: retrieves sparse (evidence: `modules/pipeline.py`)
- RAG orchestrator → Hybrid fusion: fuses rankings (evidence: `modules/pipeline.py`)
- RAG orchestrator → Evidence reranking: reranks evidence (evidence: `modules/pipeline.py`)
- RAG orchestrator → Grounded prompting: constructs prompt (evidence: `modules/pipeline.py`)
- RAG orchestrator → Local LLM generation: generates answer (evidence: `modules/pipeline.py`)
- RAG orchestrator → Claim verification: verifies claims (evidence: `modules/pipeline.py`)
- Evidence search service → Dense retrieval: retrieves dense (evidence: `modules/retriever.py`)
- Evidence search service → Sparse retrieval: retrieves sparse (evidence: `modules/retriever.py`)
- Evidence search service → Hybrid fusion: fuses rankings (evidence: `modules/retriever.py`)
- Evidence search service → Evidence reranking: reranks evidence (evidence: `modules/retriever.py`)
