# s4ntrx/s4ntrx-bot architecture

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

- Interactive diagram: https://gitdiagram.com/s4ntrx/s4ntrx-bot
- Repository: https://github.com/s4ntrx/s4ntrx-bot

## Overview

S4ntrx Bot is a multi-user cybersecurity education web app. Students register or log in, then use chat, phishing and URL analysis, password checking, and incident reporting; administrators view aggregate statistics. Flask routes handle requests and use SQLAlchemy-backed models for persistent records. Chat selects an offline knowledge-base responder by default, with Ollama as an optional provider. The graph preserves the documented capabilities, but the sampled excerpts do not show admin and incident route internals, so those connections rely on SOURCE INDEX references or README statements.

Main entry points: [`app.py`](https://github.com/s4ntrx/s4ntrx-bot/blob/main/app.py) (Flask app), [`routes/admin.py`](https://github.com/s4ntrx/s4ntrx-bot/blob/main/routes/admin.py) (Admin statistics), [`routes/security.py`](https://github.com/s4ntrx/s4ntrx-bot/blob/main/routes/security.py) (Security tool routes), [`routes/auth.py`](https://github.com/s4ntrx/s4ntrx-bot/blob/main/routes/auth.py) (Account routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web entry and identity"]
  node_app["Flask app<br/>[app.py]"]
  node_config["App configuration<br/>[config.py]"]
  node_extensions["Flask extensions<br/>[extensions.py]"]
  node_forms["Validated forms<br/>[forms.py]"]
  node_auth_routes["Account routes<br/>[auth.py]"]
  node_user_model["User accounts<br/>[user.py]"]
  node_main_routes["Landing and dashboard<br/>[main.py]"]
end

subgraph group_chat["Education chat"]
  node_chat_routes["Chat routes<br/>[chat.py]"]
  node_chat_model["Chat sessions<br/>[chat.py]"]
  node_ai_service["AI provider selection<br/>[ai_service.py]"]
  node_knowledge["Cybersecurity knowledge"]
end

subgraph group_security["Security tools"]
  node_security_routes["Security tool routes<br/>[security.py]"]
  node_phishing["Phishing detector"]
  node_url_analyzer["URL analyzer<br/>[url_analyzer.py]"]
  node_password_checker["Client-side password checker"]
  node_analysis_model["Analysis records<br/>[analysis.py]"]
end

subgraph group_records["Reports and administration"]
  node_incident_routes["Incident reporting<br/>[incidents.py]"]
  node_incident_model["Incident reports<br/>[incident.py]"]
  node_admin_routes["Admin statistics<br/>[admin.py]"]
  node_database[("SQL database")]
end

node_student(("Student"))
node_admin(("Administrator"))
node_browser["Browser UI"]
node_ollama["Ollama server"]

node_student -->|"uses"| node_browser
node_admin -->|"uses"| node_browser
node_browser -->|"sends requests"| node_app
node_app -->|"loads"| node_config
node_app -->|"initializes"| node_extensions
node_app -->|"registers"| node_auth_routes
node_app -->|"registers"| node_main_routes
node_app -->|"registers"| node_chat_routes
node_app -->|"registers"| node_security_routes
node_app -->|"registers"| node_incident_routes
node_app -->|"registers"| node_admin_routes
node_auth_routes -->|"validates with"| node_forms
node_auth_routes -->|"queries and creates"| node_user_model
node_auth_routes -->|"commits accounts"| node_database
node_user_model -->|"persists account"| node_database
node_chat_routes -->|"reads and writes"| node_chat_model
node_chat_routes -->|"gets provider and replies"| node_ai_service
node_chat_model -->|"persists sessions"| node_database
node_ai_service -->|"loads documents"| node_knowledge
node_ai_service -.->|"requests chat"| node_ollama
node_ai_service -->|"falls back to"| node_knowledge
node_security_routes -->|"validates with"| node_forms
node_security_routes -->|"analyzes messages"| node_phishing
node_security_routes -->|"analyzes URLs"| node_url_analyzer
node_security_routes -->|"records results"| node_analysis_model
node_analysis_model -->|"persists analyses"| node_database
node_browser -->|"runs locally"| node_password_checker
node_incident_routes -->|"uses"| node_forms
node_incident_routes -->|"creates and lists"| node_incident_model
node_incident_model -->|"persists reports"| node_database
node_admin_routes -->|"queries aggregates"| node_user_model
node_admin_routes -->|"queries aggregates"| node_chat_model
node_admin_routes -->|"queries aggregates"| node_incident_model
node_admin_routes -->|"queries aggregates"| node_analysis_model
node_browser -->|"submits reports"| node_incident_routes
node_browser -->|"views statistics"| node_admin_routes

click node_app "https://github.com/s4ntrx/s4ntrx-bot/blob/main/app.py"
click node_config "https://github.com/s4ntrx/s4ntrx-bot/blob/main/config.py"
click node_extensions "https://github.com/s4ntrx/s4ntrx-bot/blob/main/extensions.py"
click node_forms "https://github.com/s4ntrx/s4ntrx-bot/blob/main/forms.py"
click node_auth_routes "https://github.com/s4ntrx/s4ntrx-bot/blob/main/routes/auth.py"
click node_user_model "https://github.com/s4ntrx/s4ntrx-bot/blob/main/models/user.py"
click node_main_routes "https://github.com/s4ntrx/s4ntrx-bot/blob/main/routes/main.py"
click node_chat_routes "https://github.com/s4ntrx/s4ntrx-bot/blob/main/routes/chat.py"
click node_chat_model "https://github.com/s4ntrx/s4ntrx-bot/blob/main/models/chat.py"
click node_ai_service "https://github.com/s4ntrx/s4ntrx-bot/blob/main/services/ai_service.py"
click node_knowledge "https://github.com/s4ntrx/s4ntrx-bot/tree/main/knowledge"
click node_security_routes "https://github.com/s4ntrx/s4ntrx-bot/blob/main/routes/security.py"
click node_phishing "https://github.com/s4ntrx/s4ntrx-bot/blob/main/services/phishing_detector.py"
click node_url_analyzer "https://github.com/s4ntrx/s4ntrx-bot/blob/main/services/url_analyzer.py"
click node_password_checker "https://github.com/s4ntrx/s4ntrx-bot/blob/main/static/js/password_checker.js"
click node_analysis_model "https://github.com/s4ntrx/s4ntrx-bot/blob/main/models/analysis.py"
click node_incident_routes "https://github.com/s4ntrx/s4ntrx-bot/blob/main/routes/incidents.py"
click node_incident_model "https://github.com/s4ntrx/s4ntrx-bot/blob/main/models/incident.py"
click node_admin_routes "https://github.com/s4ntrx/s4ntrx-bot/blob/main/routes/admin.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_app,node_config,node_extensions,node_forms,node_auth_routes,node_user_model,node_main_routes,node_browser toneBlue
class node_chat_routes,node_chat_model,node_ai_service,node_knowledge toneAmber
class node_security_routes,node_phishing,node_url_analyzer,node_password_checker,node_analysis_model,node_ollama toneMint
class node_incident_routes,node_incident_model,node_admin_routes,node_database toneRose
class node_student,node_admin toneIndigo
```

## Components

### Web entry and identity

- [Flask app](https://github.com/s4ntrx/s4ntrx-bot/blob/main/app.py): `app.py`
- [App configuration](https://github.com/s4ntrx/s4ntrx-bot/blob/main/config.py): `config.py`
- [Flask extensions](https://github.com/s4ntrx/s4ntrx-bot/blob/main/extensions.py): `extensions.py`
- [Validated forms](https://github.com/s4ntrx/s4ntrx-bot/blob/main/forms.py): `forms.py`
- [Account routes](https://github.com/s4ntrx/s4ntrx-bot/blob/main/routes/auth.py): `routes/auth.py`
- [User accounts](https://github.com/s4ntrx/s4ntrx-bot/blob/main/models/user.py): `models/user.py`
- [Landing and dashboard](https://github.com/s4ntrx/s4ntrx-bot/blob/main/routes/main.py): `routes/main.py`

### Education chat

- [Chat routes](https://github.com/s4ntrx/s4ntrx-bot/blob/main/routes/chat.py): `routes/chat.py`
- [Chat sessions](https://github.com/s4ntrx/s4ntrx-bot/blob/main/models/chat.py): `models/chat.py`
- [AI provider selection](https://github.com/s4ntrx/s4ntrx-bot/blob/main/services/ai_service.py): `services/ai_service.py`
- [Cybersecurity knowledge](https://github.com/s4ntrx/s4ntrx-bot/tree/main/knowledge): `knowledge`

### Security tools

- [Security tool routes](https://github.com/s4ntrx/s4ntrx-bot/blob/main/routes/security.py): `routes/security.py`
- [Phishing detector](https://github.com/s4ntrx/s4ntrx-bot/blob/main/services/phishing_detector.py): `services/phishing_detector.py`
- [URL analyzer](https://github.com/s4ntrx/s4ntrx-bot/blob/main/services/url_analyzer.py): `services/url_analyzer.py`
- [Client-side password checker](https://github.com/s4ntrx/s4ntrx-bot/blob/main/static/js/password_checker.js): `static/js/password_checker.js`
- [Analysis records](https://github.com/s4ntrx/s4ntrx-bot/blob/main/models/analysis.py): `models/analysis.py`

### Reports and administration

- [Incident reporting](https://github.com/s4ntrx/s4ntrx-bot/blob/main/routes/incidents.py): `routes/incidents.py`
- [Incident reports](https://github.com/s4ntrx/s4ntrx-bot/blob/main/models/incident.py): `models/incident.py`
- [Admin statistics](https://github.com/s4ntrx/s4ntrx-bot/blob/main/routes/admin.py): `routes/admin.py`
- **SQL database**

### Other components

- **Student**
- **Administrator**
- **Browser UI**
- **Ollama server**

## Connections

- Student → Browser UI: uses (evidence: `README.md`)
- Administrator → Browser UI: uses (evidence: `README.md`)
- Browser UI → Flask app: sends requests (evidence: `README.md`)
- Flask app → App configuration: loads (evidence: `app.py`)
- Flask app → Flask extensions: initializes (evidence: `app.py`)
- Flask app → Account routes: registers (evidence: `app.py`)
- Flask app → Landing and dashboard: registers (evidence: `app.py`)
- Flask app → Chat routes: registers (evidence: `app.py`)
- Flask app → Security tool routes: registers (evidence: `app.py`)
- Flask app → Incident reporting: registers (evidence: `app.py`)
- Flask app → Admin statistics: registers (evidence: `app.py`)
- Account routes → Validated forms: validates with (evidence: `routes/auth.py`)
- Account routes → User accounts: queries and creates (evidence: `routes/auth.py`)
- Account routes → SQL database: commits accounts (evidence: `routes/auth.py`)
- User accounts → SQL database: persists account (evidence: `models/user.py`)
- Chat routes → Chat sessions: reads and writes (evidence: `routes/chat.py`)
- Chat routes → AI provider selection: gets provider and replies (evidence: `routes/chat.py`)
- Chat sessions → SQL database: persists sessions (evidence: `models/chat.py`)
- AI provider selection → Cybersecurity knowledge: loads documents (evidence: `services/ai_service.py`)
- AI provider selection → Ollama server: requests chat (evidence: `services/ai_service.py`)
- AI provider selection → Cybersecurity knowledge: falls back to (evidence: `services/ai_service.py`)
- Security tool routes → Validated forms: validates with (evidence: `routes/security.py`)
- Security tool routes → Phishing detector: analyzes messages (evidence: `routes/security.py`)
- Security tool routes → URL analyzer: analyzes URLs (evidence: `routes/security.py`)
- Security tool routes → Analysis records: records results (evidence: `routes/security.py`)
- Analysis records → SQL database: persists analyses (evidence: `models/analysis.py`)
- Browser UI → Client-side password checker: runs locally (evidence: `README.md`)
- Incident reporting → Validated forms: uses (evidence: `routes/incidents.py`)
- Incident reporting → Incident reports: creates and lists (evidence: `routes/incidents.py`)
- Incident reports → SQL database: persists reports (evidence: `models/incident.py`)
- Admin statistics → User accounts: queries aggregates (evidence: `routes/admin.py`)
- Admin statistics → Chat sessions: queries aggregates (evidence: `routes/admin.py`)
- Admin statistics → Incident reports: queries aggregates (evidence: `routes/admin.py`)
- Admin statistics → Analysis records: queries aggregates (evidence: `routes/admin.py`)
- Browser UI → Incident reporting: submits reports (evidence: `README.md`)
- Browser UI → Admin statistics: views statistics (evidence: `README.md`)
