# boas04/aegis architecture

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

- Interactive diagram: https://gitdiagram.com/boas04/aegis
- Repository: https://github.com/boas04/aegis

## Overview

Aegis is a Flask-based web application firewall. Its main workflow accepts login-form input, normalizes it, applies rule-based and machine-learning detection, then records and renders a blocked or allowed result. Separate routes provide dashboard statistics, searchable-style log views, CSV export, and model information. The sampled implementation is concentrated in app.py; the README also describes forwarding safe requests, but the shown code renders a success page instead. The graph reflects only relationships visible in app.py or documented in the README.

Main entry points: [`app.py`](https://github.com/boas04/aegis/blob/main/app.py) (Flask routes), [`aegis_logs.db`](https://github.com/boas04/aegis/blob/main/aegis_logs.db) (SQLite log store), [`vectorizer_v2.pkl`](https://github.com/boas04/aegis/blob/main/vectorizer_v2.pkl) (Feature vectorizer), [`waf_model_v2.pkl`](https://github.com/boas04/aegis/blob/main/waf_model_v2.pkl) (Threat classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inspection["Request Inspection"]
  node_flask_app["Flask routes<br/>[app.py]"]
  node_normalization["Payload normalization<br/>[app.py]"]
  node_rule_filter["Rule pre-filter<br/>[app.py]"]
  node_vectorizer["Feature vectorizer<br/>[vectorizer_v2.pkl]"]
  node_classifier["Threat classifier<br/>[waf_model_v2.pkl]"]
  node_response["Access response<br/>[app.py]"]
end

subgraph group_records["Logging and Analytics"]
  node_logger["Request logger<br/>[app.py]"]
  node_log_store[("SQLite log store<br/>[aegis_logs.db]")]
  node_log_queries["Log queries<br/>[app.py]"]
  node_statistics["Dashboard statistics<br/>[app.py]"]
  node_chart_data["Chart aggregation<br/>[app.py]"]
end

subgraph group_web["Web Interface"]
  node_dashboard["Dashboard page<br/>[dashboard.html]"]
  node_logs_page["Logs page<br/>[logs.html]"]
  node_csv_export["CSV export<br/>[app.py]"]
  node_landing["Landing page<br/>[index.html]"]
  node_blocked_page["Blocked page<br/>[blocked.html]"]
  node_success_page["Success page<br/>[success.html]"]
  node_about_page["About page<br/>[about.html]"]
end

node_visitor(("Web visitor"))

node_visitor -->|"submits request"| node_flask_app
node_flask_app -->|"normalizes input"| node_normalization
node_flask_app -->|"checks rules"| node_rule_filter
node_flask_app -->|"transforms features"| node_vectorizer
node_flask_app -->|"predicts threat"| node_classifier
node_flask_app -->|"renders outcome"| node_response
node_flask_app -->|"records decision"| node_logger
node_logger -->|"writes entries"| node_log_store
node_log_queries -->|"reads entries"| node_log_store
node_flask_app -->|"fetches logs"| node_log_queries
node_flask_app -->|"fetches metrics"| node_statistics
node_statistics -->|"counts records"| node_log_store
node_flask_app -->|"builds chart data"| node_chart_data
node_chart_data -->|"counts daily logs"| node_log_store
node_flask_app -->|"renders dashboard"| node_dashboard
node_flask_app -->|"renders logs"| node_logs_page
node_flask_app -->|"exports logs"| node_csv_export
node_csv_export -->|"fetches entries"| node_log_queries
node_flask_app -->|"renders landing"| node_landing
node_response -->|"renders blocked"| node_blocked_page
node_response -->|"renders allowed"| node_success_page
node_flask_app -->|"renders about"| node_about_page

click node_flask_app "https://github.com/boas04/aegis/blob/main/app.py"
click node_normalization "https://github.com/boas04/aegis/blob/main/app.py"
click node_rule_filter "https://github.com/boas04/aegis/blob/main/app.py"
click node_vectorizer "https://github.com/boas04/aegis/blob/main/vectorizer_v2.pkl"
click node_classifier "https://github.com/boas04/aegis/blob/main/waf_model_v2.pkl"
click node_response "https://github.com/boas04/aegis/blob/main/app.py"
click node_logger "https://github.com/boas04/aegis/blob/main/app.py"
click node_log_store "https://github.com/boas04/aegis/blob/main/aegis_logs.db"
click node_log_queries "https://github.com/boas04/aegis/blob/main/app.py"
click node_statistics "https://github.com/boas04/aegis/blob/main/app.py"
click node_chart_data "https://github.com/boas04/aegis/blob/main/app.py"
click node_dashboard "https://github.com/boas04/aegis/blob/main/templates/dashboard.html"
click node_logs_page "https://github.com/boas04/aegis/blob/main/templates/logs.html"
click node_csv_export "https://github.com/boas04/aegis/blob/main/app.py"
click node_landing "https://github.com/boas04/aegis/blob/main/templates/index.html"
click node_blocked_page "https://github.com/boas04/aegis/blob/main/templates/blocked.html"
click node_success_page "https://github.com/boas04/aegis/blob/main/templates/success.html"
click node_about_page "https://github.com/boas04/aegis/blob/main/templates/about.html"

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_flask_app,node_normalization,node_rule_filter,node_vectorizer,node_classifier,node_response toneBlue
class node_logger,node_log_store,node_log_queries,node_statistics,node_chart_data toneAmber
class node_dashboard,node_logs_page,node_csv_export,node_landing,node_blocked_page,node_success_page,node_about_page toneMint
class node_visitor toneIndigo
```

## Components

### Request Inspection

- [Flask routes](https://github.com/boas04/aegis/blob/main/app.py): `app.py`
- [Payload normalization](https://github.com/boas04/aegis/blob/main/app.py): `app.py`
- [Rule pre-filter](https://github.com/boas04/aegis/blob/main/app.py): `app.py`
- [Feature vectorizer](https://github.com/boas04/aegis/blob/main/vectorizer_v2.pkl): `vectorizer_v2.pkl`
- [Threat classifier](https://github.com/boas04/aegis/blob/main/waf_model_v2.pkl): `waf_model_v2.pkl`
- [Access response](https://github.com/boas04/aegis/blob/main/app.py): `app.py`

### Logging and Analytics

- [Request logger](https://github.com/boas04/aegis/blob/main/app.py): `app.py`
- [SQLite log store](https://github.com/boas04/aegis/blob/main/aegis_logs.db): `aegis_logs.db`
- [Log queries](https://github.com/boas04/aegis/blob/main/app.py): `app.py`
- [Dashboard statistics](https://github.com/boas04/aegis/blob/main/app.py): `app.py`
- [Chart aggregation](https://github.com/boas04/aegis/blob/main/app.py): `app.py`

### Web Interface

- [Dashboard page](https://github.com/boas04/aegis/blob/main/templates/dashboard.html): `templates/dashboard.html`
- [Logs page](https://github.com/boas04/aegis/blob/main/templates/logs.html): `templates/logs.html`
- [CSV export](https://github.com/boas04/aegis/blob/main/app.py): `app.py`
- [Landing page](https://github.com/boas04/aegis/blob/main/templates/index.html): `templates/index.html`
- [Blocked page](https://github.com/boas04/aegis/blob/main/templates/blocked.html): `templates/blocked.html`
- [Success page](https://github.com/boas04/aegis/blob/main/templates/success.html): `templates/success.html`
- [About page](https://github.com/boas04/aegis/blob/main/templates/about.html): `templates/about.html`

### Other components

- **Web visitor**

## Connections

- Web visitor → Flask routes: submits request (evidence: `README.md`)
- Flask routes → Payload normalization: normalizes input (evidence: `app.py`)
- Flask routes → Rule pre-filter: checks rules (evidence: `app.py`)
- Flask routes → Feature vectorizer: transforms features (evidence: `app.py`)
- Flask routes → Threat classifier: predicts threat (evidence: `app.py`)
- Flask routes → Access response: renders outcome (evidence: `app.py`)
- Flask routes → Request logger: records decision (evidence: `app.py`)
- Request logger → SQLite log store: writes entries (evidence: `app.py`)
- Log queries → SQLite log store: reads entries (evidence: `app.py`)
- Flask routes → Log queries: fetches logs (evidence: `app.py`)
- Flask routes → Dashboard statistics: fetches metrics (evidence: `app.py`)
- Dashboard statistics → SQLite log store: counts records (evidence: `app.py`)
- Flask routes → Chart aggregation: builds chart data (evidence: `app.py`)
- Chart aggregation → SQLite log store: counts daily logs (evidence: `app.py`)
- Flask routes → Dashboard page: renders dashboard (evidence: `app.py`)
- Flask routes → Logs page: renders logs (evidence: `app.py`)
- Flask routes → CSV export: exports logs (evidence: `app.py`)
- CSV export → Log queries: fetches entries (evidence: `app.py`)
- Flask routes → Landing page: renders landing (evidence: `app.py`)
- Access response → Blocked page: renders blocked (evidence: `app.py`)
- Access response → Success page: renders allowed (evidence: `app.py`)
- Flask routes → About page: renders about (evidence: `app.py`)
