# alonz22/haproxy-dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/alonz22/haproxy-dashboard
- Repository: https://github.com/alonz22/haproxy-dashboard

## Overview

HAProxy Configurator is a Flask web application for creating and editing HAProxy configuration, reviewing security events, and viewing traffic statistics. The main workflow authenticates a user, accepts frontend/backend and security options, and appends generated configuration; a separate editor saves, validates, and can restart HAProxy. The README also describes SSL, health checks, ACL/WAF rules, and homepage summaries. These capabilities are grouped where their implementation is documented or visible; unsampled template behavior is not inferred beyond the routes that render it.

Main entry points: [`routes/main_routes.py`](https://github.com/alonz22/haproxy-dashboard/blob/main/routes/main_routes.py) (Frontend setup), [`app.py`](https://github.com/alonz22/haproxy-dashboard/blob/main/app.py) (Flask application), [`routes/edit_routes.py`](https://github.com/alonz22/haproxy-dashboard/blob/main/routes/edit_routes.py) (Config editor), [`utils/haproxy_config.py`](https://github.com/alonz22/haproxy-dashboard/blob/main/utils/haproxy_config.py) (Config generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_flask["Flask application<br/>[app.py]"]
  node_auth["HTTP authentication<br/>[auth_middleware.py]"]
  node_setup_view["Setup form<br/>[index.html]"]
  node_home_view["Summary view<br/>[home.html]"]
  node_edit_view["Editor view<br/>[edit.html]"]
  node_logs_view["Security events view<br/>[logs.html]"]
end

subgraph group_config["Configuration management"]
  node_setup_route["Frontend setup<br/>[main_routes.py]"]
  node_config_builder["Config generation<br/>[haproxy_config.py]"]
  node_haproxy_config[("HAProxy config")]
  node_home_route["Homepage summary<br/>[main_routes.py]"]
  node_edit_route["Config editor<br/>[edit_routes.py]"]
end

subgraph group_operations["Monitoring and security"]
  node_validator["HAProxy validation<br/>[edit_routes.py]"]
  node_service["HAProxy service"]
  node_stats_route["Traffic statistics<br/>[app.py]"]
  node_stats_utils["Stats fetch and parse<br/>[stats_utils.py]"]
  node_haproxy_stats["HAProxy stats endpoint"]
  node_logs_route["Security events route<br/>[app.py]"]
  node_log_parser["Security log analysis<br/>[log_parser.py]"]
  node_haproxy_log["HAProxy log"]
end

node_user(("Administrator"))

node_user -->|"uses over HTTPS"| node_flask
node_flask -->|"registers blueprint"| node_setup_route
node_flask -->|"registers blueprint"| node_edit_route
node_setup_route -->|"requires authentication"| node_auth
node_edit_route -->|"requires authentication"| node_auth
node_setup_route -->|"renders"| node_setup_view
node_setup_route -->|"generates configuration"| node_config_builder
node_config_builder -->|"reads and appends"| node_haproxy_config
node_setup_route -->|"renders summary"| node_home_view
node_setup_route -->|"counts config items"| node_home_route
node_home_route -->|"reads counts"| node_haproxy_config
node_edit_route -->|"renders"| node_edit_view
node_edit_route -->|"reads and writes"| node_haproxy_config
node_edit_route -->|"runs validation"| node_validator
node_validator -->|"restarts after validation"| node_service
node_flask -->|"serves statistics route"| node_stats_route
node_stats_route -->|"fetches and parses"| node_stats_utils
node_stats_utils -->|"requests CSV stats"| node_haproxy_stats
node_flask -->|"serves logs route"| node_logs_route
node_logs_route -->|"parses log file"| node_log_parser
node_log_parser -->|"reads"| node_haproxy_log
node_logs_route -->|"renders events"| node_logs_view

click node_flask "https://github.com/alonz22/haproxy-dashboard/blob/main/app.py"
click node_auth "https://github.com/alonz22/haproxy-dashboard/blob/main/auth/auth_middleware.py"
click node_setup_route "https://github.com/alonz22/haproxy-dashboard/blob/main/routes/main_routes.py"
click node_setup_view "https://github.com/alonz22/haproxy-dashboard/blob/main/templates/index.html"
click node_config_builder "https://github.com/alonz22/haproxy-dashboard/blob/main/utils/haproxy_config.py"
click node_home_route "https://github.com/alonz22/haproxy-dashboard/blob/main/routes/main_routes.py"
click node_home_view "https://github.com/alonz22/haproxy-dashboard/blob/main/templates/home.html"
click node_edit_route "https://github.com/alonz22/haproxy-dashboard/blob/main/routes/edit_routes.py"
click node_edit_view "https://github.com/alonz22/haproxy-dashboard/blob/main/templates/edit.html"
click node_validator "https://github.com/alonz22/haproxy-dashboard/blob/main/routes/edit_routes.py"
click node_stats_route "https://github.com/alonz22/haproxy-dashboard/blob/main/app.py"
click node_stats_utils "https://github.com/alonz22/haproxy-dashboard/blob/main/utils/stats_utils.py"
click node_logs_route "https://github.com/alonz22/haproxy-dashboard/blob/main/app.py"
click node_log_parser "https://github.com/alonz22/haproxy-dashboard/blob/main/log_parser.py"
click node_logs_view "https://github.com/alonz22/haproxy-dashboard/blob/main/templates/logs.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,node_auth,node_setup_view,node_home_view,node_edit_view,node_logs_view toneBlue
class node_setup_route,node_config_builder,node_haproxy_config,node_home_route,node_edit_route toneAmber
class node_validator,node_service,node_stats_route,node_stats_utils,node_haproxy_stats,node_logs_route,node_log_parser,node_haproxy_log toneMint
class node_user toneIndigo
```

## Components

### Web application

- [Flask application](https://github.com/alonz22/haproxy-dashboard/blob/main/app.py): `app.py`
- [HTTP authentication](https://github.com/alonz22/haproxy-dashboard/blob/main/auth/auth_middleware.py): `auth/auth_middleware.py`
- [Setup form](https://github.com/alonz22/haproxy-dashboard/blob/main/templates/index.html): `templates/index.html`
- [Summary view](https://github.com/alonz22/haproxy-dashboard/blob/main/templates/home.html): `templates/home.html`
- [Editor view](https://github.com/alonz22/haproxy-dashboard/blob/main/templates/edit.html): `templates/edit.html`
- [Security events view](https://github.com/alonz22/haproxy-dashboard/blob/main/templates/logs.html): `templates/logs.html`

### Configuration management

- [Frontend setup](https://github.com/alonz22/haproxy-dashboard/blob/main/routes/main_routes.py): `routes/main_routes.py`
- [Config generation](https://github.com/alonz22/haproxy-dashboard/blob/main/utils/haproxy_config.py): `utils/haproxy_config.py`
- **HAProxy config**
- [Homepage summary](https://github.com/alonz22/haproxy-dashboard/blob/main/routes/main_routes.py): `routes/main_routes.py`
- [Config editor](https://github.com/alonz22/haproxy-dashboard/blob/main/routes/edit_routes.py): `routes/edit_routes.py`

### Monitoring and security

- [HAProxy validation](https://github.com/alonz22/haproxy-dashboard/blob/main/routes/edit_routes.py): `routes/edit_routes.py`
- **HAProxy service**
- [Traffic statistics](https://github.com/alonz22/haproxy-dashboard/blob/main/app.py): `app.py`
- [Stats fetch and parse](https://github.com/alonz22/haproxy-dashboard/blob/main/utils/stats_utils.py): `utils/stats_utils.py`
- **HAProxy stats endpoint**
- [Security events route](https://github.com/alonz22/haproxy-dashboard/blob/main/app.py): `app.py`
- [Security log analysis](https://github.com/alonz22/haproxy-dashboard/blob/main/log_parser.py): `log_parser.py`
- **HAProxy log**

### Other components

- **Administrator**

## Connections

- Administrator → Flask application: uses over HTTPS (evidence: `README.md`)
- Flask application → Frontend setup: registers blueprint (evidence: `app.py`)
- Flask application → Config editor: registers blueprint (evidence: `app.py`)
- Frontend setup → HTTP authentication: requires authentication (evidence: `routes/main_routes.py`)
- Config editor → HTTP authentication: requires authentication (evidence: `routes/edit_routes.py`)
- Frontend setup → Setup form: renders (evidence: `routes/main_routes.py`)
- Frontend setup → Config generation: generates configuration (evidence: `routes/main_routes.py`)
- Config generation → HAProxy config: reads and appends (evidence: `utils/haproxy_config.py`)
- Frontend setup → Summary view: renders summary (evidence: `routes/main_routes.py`)
- Frontend setup → Homepage summary: counts config items (evidence: `routes/main_routes.py`)
- Homepage summary → HAProxy config: reads counts
- Config editor → Editor view: renders (evidence: `routes/edit_routes.py`)
- Config editor → HAProxy config: reads and writes (evidence: `routes/edit_routes.py`)
- Config editor → HAProxy validation: runs validation (evidence: `routes/edit_routes.py`)
- HAProxy validation → HAProxy service: restarts after validation (evidence: `routes/edit_routes.py`)
- Flask application → Traffic statistics: serves statistics route (evidence: `app.py`)
- Traffic statistics → Stats fetch and parse: fetches and parses (evidence: `app.py`)
- Stats fetch and parse → HAProxy stats endpoint: requests CSV stats (evidence: `utils/stats_utils.py`)
- Flask application → Security events route: serves logs route (evidence: `app.py`)
- Security events route → Security log analysis: parses log file (evidence: `app.py`)
- Security log analysis → HAProxy log: reads (evidence: `log_parser.py`)
- Security events route → Security events view: renders events (evidence: `app.py`)
