# boas04/web-security-gateway architecture

> Architecture diagram of the GitHub repository boas04/web-security-gateway, 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/web-security-gateway
- Repository: https://github.com/boas04/web-security-gateway

## Overview

Ruang Guard is a local web-security lab: visitors’ requests pass through the reverse proxy and WAF before reaching a configured private application, while administrators review events and operate monitoring, reporting, and ML-assisted anomaly review. The graph preserves these distinct stages and the separate administrator interface. Relationships among sampled modules are supported by source references; broader service connections use the README’s architecture statements. The independent fictional portal is shown as an origin, not as gateway implementation.

Main entry points: [`ruang-guard/guard/gateway.py`](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/gateway.py) (Reverse proxy), [`ruang-guard/guard/admin.py`](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/admin.py) (Admin API), [`ruang-guard/guard/monitor.py`](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/monitor.py) (Health monitor), [`ruang-guard/guard/reports.py`](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/reports.py) (Metadata reports)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_traffic["Request protection"]
  node_gateway["Reverse proxy<br/>[gateway.py]"]
  node_waf["Coraza WAF<br/>[main.go]"]
  node_security_store[("Security metadata<br/>[core.py]")]
end

subgraph group_operations["Operations and review"]
  node_admin_api["Admin API<br/>[admin.py]"]
  node_dashboard["Dashboard UI<br/>[dashboard.js]"]
  node_statistics["Traffic statistics<br/>[statistics.py]"]
  node_alerts["Incident alerts<br/>[alerts.py]"]
  node_monitor["Health monitor<br/>[monitor.py]"]
  node_reports["Metadata reports<br/>[reports.py]"]
end

subgraph group_learning["ML review lifecycle"]
  node_ml_data["ML data control<br/>[ml.py]"]
  node_coordination["Signal coordination<br/>[coordination.py]"]
  node_ml_worker["ML worker<br/>[ml_worker.py]"]
  node_ml_engine["Model training and scoring<br/>[ml_engine.py]"]
end

subgraph group_origins["Protected applications"]
  node_origin["Configured origin<br/>[app.py]"]
  node_warga["Complaint portal<br/>[app.py]"]
end

node_visitor(("Local visitor"))
node_administrator(("Administrator"))

node_visitor -->|"sends requests"| node_gateway
node_gateway -->|"requests inspection"| node_waf
node_waf -->|"returns verdict"| node_gateway
node_gateway -->|"forwards allowed"| node_origin
node_gateway -.->|"records metadata"| node_security_store
node_administrator -->|"opens dashboard"| node_dashboard
node_dashboard -.->|"calls APIs"| node_admin_api
node_admin_api -.->|"reads and writes"| node_security_store
node_admin_api -->|"requests summaries"| node_statistics
node_admin_api -->|"requests alerts"| node_alerts
node_admin_api -.->|"requests exports"| node_reports
node_monitor -->|"checks health"| node_origin
node_monitor -->|"checks health"| node_waf
node_monitor -->|"stores health"| node_security_store
node_monitor -->|"evaluates incidents"| node_alerts
node_reports -->|"aggregates events"| node_statistics
node_reports -->|"includes findings"| node_ml_data
node_reports -->|"includes coordination"| node_coordination
node_ml_worker -->|"initializes data"| node_ml_data
node_ml_worker -->|"runs cycles"| node_ml_engine
node_ml_engine -->|"validates lineage"| node_ml_data
node_ml_data -->|"collects evidence"| node_coordination
node_security_store -.->|"supplies metadata"| node_ml_worker
node_gateway -.->|"routes to configured origin"| node_warga

click node_gateway "https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/gateway.py"
click node_waf "https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/waf/main.go"
click node_security_store "https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/core.py"
click node_origin "https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/demo-app/app.py"
click node_warga "https://github.com/boas04/web-security-gateway/blob/main/ruang-warga/app.py"
click node_admin_api "https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/admin.py"
click node_dashboard "https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/static/dashboard.js"
click node_statistics "https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/statistics.py"
click node_alerts "https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/alerts.py"
click node_monitor "https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/monitor.py"
click node_reports "https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/reports.py"
click node_ml_data "https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/ml.py"
click node_coordination "https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/coordination.py"
click node_ml_worker "https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/ml_worker.py"
click node_ml_engine "https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/ml_engine.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_gateway,node_waf,node_security_store toneBlue
class node_admin_api,node_dashboard,node_statistics,node_alerts,node_monitor,node_reports toneAmber
class node_ml_data,node_coordination,node_ml_worker,node_ml_engine toneMint
class node_origin,node_warga toneRose
class node_visitor,node_administrator toneIndigo
```

## Components

### Request protection

- [Reverse proxy](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/gateway.py): `ruang-guard/guard/gateway.py`
- [Coraza WAF](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/waf/main.go): `ruang-guard/waf/main.go`
- [Security metadata](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/core.py): `ruang-guard/guard/core.py`

### Operations and review

- [Admin API](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/admin.py): `ruang-guard/guard/admin.py`
- [Dashboard UI](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/static/dashboard.js): `ruang-guard/guard/static/dashboard.js`
- [Traffic statistics](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/statistics.py): `ruang-guard/guard/statistics.py`
- [Incident alerts](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/alerts.py): `ruang-guard/guard/alerts.py`
- [Health monitor](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/monitor.py): `ruang-guard/guard/monitor.py`
- [Metadata reports](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/reports.py): `ruang-guard/guard/reports.py`

### ML review lifecycle

- [ML data control](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/ml.py): `ruang-guard/guard/ml.py`
- [Signal coordination](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/coordination.py): `ruang-guard/guard/coordination.py`
- [ML worker](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/ml_worker.py): `ruang-guard/guard/ml_worker.py`
- [Model training and scoring](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/guard/ml_engine.py): `ruang-guard/guard/ml_engine.py`

### Protected applications

- [Configured origin](https://github.com/boas04/web-security-gateway/blob/main/ruang-guard/demo-app/app.py): `ruang-guard/demo-app/app.py`
- [Complaint portal](https://github.com/boas04/web-security-gateway/blob/main/ruang-warga/app.py): `ruang-warga/app.py`

### Other components

- **Local visitor**
- **Administrator**

## Connections

- Local visitor → Reverse proxy: sends requests (evidence: `README.md`)
- Reverse proxy → Coraza WAF: requests inspection (evidence: `README.md`)
- Coraza WAF → Reverse proxy: returns verdict (evidence: `README.md`)
- Reverse proxy → Configured origin: forwards allowed (evidence: `README.md`)
- Reverse proxy → Security metadata: records metadata (evidence: `ruang-guard/guard/gateway.py`)
- Administrator → Dashboard UI: opens dashboard (evidence: `README.md`)
- Dashboard UI → Admin API: calls APIs
- Admin API → Security metadata: reads and writes (evidence: `ruang-guard/guard/admin.py`)
- Admin API → Traffic statistics: requests summaries (evidence: `ruang-guard/guard/admin.py`)
- Admin API → Incident alerts: requests alerts (evidence: `ruang-guard/guard/admin.py`)
- Admin API → Metadata reports: requests exports (evidence: `ruang-guard/guard/admin.py`)
- Health monitor → Configured origin: checks health (evidence: `README.md`)
- Health monitor → Coraza WAF: checks health (evidence: `README.md`)
- Health monitor → Security metadata: stores health (evidence: `ruang-guard/guard/monitor.py`)
- Health monitor → Incident alerts: evaluates incidents (evidence: `ruang-guard/guard/monitor.py`)
- Metadata reports → Traffic statistics: aggregates events (evidence: `ruang-guard/guard/reports.py`)
- Metadata reports → ML data control: includes findings (evidence: `ruang-guard/guard/reports.py`)
- Metadata reports → Signal coordination: includes coordination (evidence: `ruang-guard/guard/reports.py`)
- ML worker → ML data control: initializes data (evidence: `ruang-guard/guard/ml_worker.py`)
- ML worker → Model training and scoring: runs cycles (evidence: `ruang-guard/guard/ml_worker.py`)
- Model training and scoring → ML data control: validates lineage (evidence: `ruang-guard/guard/ml_engine.py`)
- ML data control → Signal coordination: collects evidence (evidence: `ruang-guard/guard/ml.py`)
- Security metadata → ML worker: supplies metadata (evidence: `ruang-guard/guard/ml_worker.py`)
- Reverse proxy → Complaint portal: routes to configured origin
