# alexandermarston/vnstat-dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/alexandermarston/vnstat-dashboard
- Repository: https://github.com/alexandermarston/vnstat-dashboard

## Overview

vnStat Dashboard is a PHP web UI for viewing network-traffic statistics from vnstat. A browser request enters app/index.php, which selects an interface, requests hourly, daily, monthly, and top-10 data, and renders a Smarty page. The vnStat adapter obtains JSON from the local vnstat executable; shared utilities format and scale its values. The README also documents Google Charts and automatic interface selection. Template internals were not excerpted, so their individual rendering relationships are not inferred.

Main entry points: [`app/templates/site_index.tpl`](https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/templates/site_index.tpl) (Smarty page template), [`app/index.php`](https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/index.php) (Page controller), [`app/includes/vnstat.php`](https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/includes/vnstat.php) (vnStat adapter), [`app/templates/module_graph_js.tpl`](https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/templates/module_graph_js.tpl) (Graph script template)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web request and presentation"]
  node_entry["Page controller<br/>[index.php]"]
  node_page["Smarty page template<br/>[site_index.tpl]"]
  node_graph_tpl["Graph template<br/>[module_graph.tpl]"]
  node_graph_js["Graph script template"]
  node_table_tpl["Table template<br/>[module_table.tpl]"]
  node_header_tpl["Header template<br/>[module_header.tpl]"]
  node_footer_tpl["Footer template<br/>[module_footer.tpl]"]
end

subgraph group_traffic["Traffic data processing"]
  node_vnstat["vnStat adapter<br/>[vnstat.php]"]
  node_utilities["Formatting utilities<br/>[utilities.php]"]
end

subgraph group_config["Runtime configuration"]
  node_config_file["Runtime settings<br/>[config.php]"]
end

node_browser(("Browser user"))
node_cli["vnstat executable"]
node_google["Google Charts"]

node_browser -->|"requests page"| node_entry
node_entry -->|"loads settings"| node_config_file
node_entry -->|"requests interface data"| node_vnstat
node_vnstat -->|"runs JSON command"| node_cli
node_vnstat -->|"formats values"| node_utilities
node_entry -->|"renders page"| node_page
node_page -.-> node_graph_tpl
node_page -.-> node_graph_js
node_page -.-> node_table_tpl
node_page -.-> node_header_tpl
node_page -.-> node_footer_tpl
node_graph_js -.->|"uses charts"| node_google

click node_entry "https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/index.php"
click node_page "https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/templates/site_index.tpl"
click node_graph_tpl "https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/templates/module_graph.tpl"
click node_graph_js "https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/templates/module_graph_js.tpl"
click node_table_tpl "https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/templates/module_table.tpl"
click node_header_tpl "https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/templates/module_header.tpl"
click node_footer_tpl "https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/templates/module_footer.tpl"
click node_vnstat "https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/includes/vnstat.php"
click node_utilities "https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/includes/utilities.php"
click node_config_file "https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/includes/config.php"

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_entry,node_page,node_graph_tpl,node_graph_js,node_table_tpl,node_header_tpl,node_footer_tpl,node_browser toneBlue
class node_vnstat,node_utilities toneAmber
class node_config_file toneMint
class node_cli,node_google toneIndigo
```

## Components

### Web request and presentation

- [Page controller](https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/index.php): `app/index.php`
- [Smarty page template](https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/templates/site_index.tpl): `app/templates/site_index.tpl`
- [Graph template](https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/templates/module_graph.tpl): `app/templates/module_graph.tpl`
- [Graph script template](https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/templates/module_graph_js.tpl): `app/templates/module_graph_js.tpl`
- [Table template](https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/templates/module_table.tpl): `app/templates/module_table.tpl`
- [Header template](https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/templates/module_header.tpl): `app/templates/module_header.tpl`
- [Footer template](https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/templates/module_footer.tpl): `app/templates/module_footer.tpl`

### Traffic data processing

- [vnStat adapter](https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/includes/vnstat.php): `app/includes/vnstat.php`
- [Formatting utilities](https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/includes/utilities.php): `app/includes/utilities.php`

### Runtime configuration

- [Runtime settings](https://github.com/alexandermarston/vnstat-dashboard/blob/master/app/includes/config.php): `app/includes/config.php`

### Other components

- **Browser user**
- **vnstat executable**
- **Google Charts**

## Connections

- Browser user → Page controller: requests page
- Page controller → Runtime settings: loads settings (evidence: `app/index.php`)
- Page controller → vnStat adapter: requests interface data (evidence: `app/index.php`)
- vnStat adapter → vnstat executable: runs JSON command (evidence: `app/includes/vnstat.php`)
- vnStat adapter → Formatting utilities: formats values (evidence: `app/includes/vnstat.php`)
- Page controller → Smarty page template: renders page (evidence: `app/index.php`)
- Smarty page template → Graph template
- Smarty page template → Graph script template
- Smarty page template → Table template
- Smarty page template → Header template
- Smarty page template → Footer template
- Graph script template → Google Charts: uses charts (evidence: `README.md`)
