# jnjt2935/ai-powered_security_chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/jnjt2935/ai-powered_security_chatbot
- Repository: https://github.com/jnjt2935/ai-powered_security_chatbot

## Overview

This is a cybersecurity-awareness learning chatbot: course notes are ingested into a persistent vector store, relevant chunks are retrieved for questions, and an LLM generates grounded answers. The README also describes quiz generation, document upload, and a Streamlit interface, but those implementation files are absent from the tree. The sampled code confirms ingestion, retrieval, answer-generation, and evaluation behavior; UI wiring and quiz internals are therefore shown only where documented.

Main entry points: [`llm_answering.py`](https://github.com/jnjt2935/ai-powered_security_chatbot/blob/main/llm_answering.py) (Grounded answers), [`retrieval.py`](https://github.com/jnjt2935/ai-powered_security_chatbot/blob/main/retrieval.py) (Chunk retrieval), [`data_ingestion.py`](https://github.com/jnjt2935/ai-powered_security_chatbot/blob/main/data_ingestion.py) (Chunking and embeddings), [`vector_db`](https://github.com/jnjt2935/ai-powered_security_chatbot/tree/main/vector_db) (Vector store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_knowledge["Knowledge preparation"]
  node_course_notes["Course notes"]
  node_ingestion["Chunking and embeddings<br/>[data_ingestion.py]"]
  node_vector_store[("Vector store")]
end

subgraph group_answering["Question answering"]
  node_retrieval["Chunk retrieval<br/>[retrieval.py]"]
  node_answering["Grounded answers<br/>[llm_answering.py]"]
  node_llm_provider{{"LLM provider"}}
  node_quiz["Quiz generation"]
end

subgraph group_quality["Evaluation and interface"]
  node_interface["Chat and upload UI"]
  node_retrieval_eval["Retrieval evaluation"]
  node_gate_check["Scope gate checks<br/>[gate_check.py]"]
end

node_student(("Student"))

node_student -.->|"asks or uploads"| node_interface
node_course_notes -->|"chunks and embeds"| node_ingestion
node_ingestion -->|"stores chunks"| node_vector_store
node_retrieval -->|"queries chunks"| node_vector_store
node_answering -->|"gets context"| node_retrieval
node_answering -.->|"generates answer"| node_llm_provider
node_interface -.->|"requests answers"| node_answering
node_interface -.->|"requests quizzes"| node_quiz
node_retrieval_eval -->|"measures retrieval"| node_retrieval
node_gate_check -->|"checks scope gate"| node_answering

click node_course_notes "https://github.com/jnjt2935/ai-powered_security_chatbot/tree/main/data/knowledge_base"
click node_ingestion "https://github.com/jnjt2935/ai-powered_security_chatbot/blob/main/data_ingestion.py"
click node_vector_store "https://github.com/jnjt2935/ai-powered_security_chatbot/tree/main/vector_db"
click node_retrieval "https://github.com/jnjt2935/ai-powered_security_chatbot/blob/main/retrieval.py"
click node_answering "https://github.com/jnjt2935/ai-powered_security_chatbot/blob/main/llm_answering.py"
click node_retrieval_eval "https://github.com/jnjt2935/ai-powered_security_chatbot/blob/main/retrieval_evaluation.py"
click node_gate_check "https://github.com/jnjt2935/ai-powered_security_chatbot/blob/main/gate_check.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_course_notes,node_ingestion,node_vector_store toneBlue
class node_retrieval,node_answering,node_llm_provider,node_quiz toneAmber
class node_interface,node_retrieval_eval,node_gate_check toneMint
class node_student toneIndigo
```

## Components

### Knowledge preparation

- [Course notes](https://github.com/jnjt2935/ai-powered_security_chatbot/tree/main/data/knowledge_base): `data/knowledge_base`
- [Chunking and embeddings](https://github.com/jnjt2935/ai-powered_security_chatbot/blob/main/data_ingestion.py): `data_ingestion.py`
- [Vector store](https://github.com/jnjt2935/ai-powered_security_chatbot/tree/main/vector_db): `vector_db`

### Question answering

- [Chunk retrieval](https://github.com/jnjt2935/ai-powered_security_chatbot/blob/main/retrieval.py): `retrieval.py`
- [Grounded answers](https://github.com/jnjt2935/ai-powered_security_chatbot/blob/main/llm_answering.py): `llm_answering.py`
- **LLM provider**
- **Quiz generation**

### Evaluation and interface

- **Chat and upload UI**
- [Retrieval evaluation](https://github.com/jnjt2935/ai-powered_security_chatbot/blob/main/retrieval_evaluation.py): `retrieval_evaluation.py`
- [Scope gate checks](https://github.com/jnjt2935/ai-powered_security_chatbot/blob/main/gate_check.py): `gate_check.py`

### Other components

- **Student**

## Connections

- Student → Chat and upload UI: asks or uploads (evidence: `README.MD`)
- Course notes → Chunking and embeddings: chunks and embeds (evidence: `README.MD`)
- Chunking and embeddings → Vector store: stores chunks (evidence: `data_ingestion.py`)
- Chunk retrieval → Vector store: queries chunks (evidence: `retrieval.py`)
- Grounded answers → Chunk retrieval: gets context (evidence: `llm_answering.py`)
- Grounded answers → LLM provider: generates answer (evidence: `llm_answering.py`)
- Chat and upload UI → Grounded answers: requests answers (evidence: `README.MD`)
- Chat and upload UI → Quiz generation: requests quizzes (evidence: `README.MD`)
- Retrieval evaluation → Chunk retrieval: measures retrieval (evidence: `retrieval_evaluation.py`)
- Scope gate checks → Grounded answers: checks scope gate (evidence: `gate_check.py`)
