# tds2k5/system-monitor architecture

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

- Interactive diagram: https://gitdiagram.com/tds2k5/system-monitor
- Repository: https://github.com/tds2k5/system-monitor

## Overview

System Monitor is a Flask web application for viewing live system resource usage. A browser reaches the login page, submits credentials, and—after authentication—opens a dashboard. The dashboard requests updates every five seconds; the server samples CPU, memory, disk, and network usage, applies the CPU/memory warning threshold, and returns JSON for display and chart updates. Session handling and dark-mode preference are supporting concerns. The README mentions historical analysis, but the available source shows live sampling and no historical-data store; templates were not sampled, so their internal structure is not mapped.

Main entry points: [`app.py`](https://github.com/tds2k5/system-monitor/blob/main/app.py) (Flask routes), [`static/js/index-script.js`](https://github.com/tds2k5/system-monitor/blob/main/static/js/index-script.js) (Data polling), [`templates/index.html`](https://github.com/tds2k5/system-monitor/blob/main/templates/index.html) (Dashboard page), [`templates/login.html`](https://github.com/tds2k5/system-monitor/blob/main/templates/login.html) (Login page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_flask_app["Flask routes<br/>[app.py]"]
  node_login_page["Login page<br/>[login.html]"]
  node_dashboard_page["Dashboard page<br/>[index.html]"]
end

subgraph group_monitor["Live monitoring"]
  node_sampling["System sampling<br/>[app.py]"]
  node_psutil["psutil metrics"]
  node_warning["Warning threshold<br/>[app.py]"]
end

subgraph group_interface["Dashboard interface"]
  node_polling["Data polling<br/>[index-script.js]"]
  node_charts["Usage charts<br/>[index-script.js]"]
  node_status_display["Status display<br/>[index-script.js]"]
  node_dark_mode["Dark mode<br/>[index-script.js]"]
end

subgraph group_state["Session and preference state"]
  node_session["Session handling<br/>[app.py]"]
  node_flask_session["Flask-Session"]
  node_preference_store[("Browser preference<br/>[index-script.js]")]
end

node_browser(("Browser user"))

node_browser -->|"opens app"| node_flask_app
node_flask_app -->|"renders login"| node_login_page
node_flask_app -->|"renders dashboard"| node_dashboard_page
node_flask_app -->|"checks login"| node_session
node_flask_app -->|"sets login"| node_session
node_flask_app -->|"samples metrics"| node_sampling
node_sampling -->|"reads metrics"| node_psutil
node_flask_app -->|"checks threshold"| node_warning
node_flask_app -->|"configures sessions"| node_flask_session
node_polling -->|"requests /data"| node_flask_app
node_flask_app -->|"returns JSON"| node_polling
node_polling -->|"updates charts"| node_charts
node_polling -->|"updates status"| node_status_display
node_polling -->|"updates page"| node_dashboard_page
node_dark_mode -->|"stores preference"| node_preference_store

click node_flask_app "https://github.com/tds2k5/system-monitor/blob/main/app.py"
click node_login_page "https://github.com/tds2k5/system-monitor/blob/main/templates/login.html"
click node_dashboard_page "https://github.com/tds2k5/system-monitor/blob/main/templates/index.html"
click node_sampling "https://github.com/tds2k5/system-monitor/blob/main/app.py"
click node_warning "https://github.com/tds2k5/system-monitor/blob/main/app.py"
click node_polling "https://github.com/tds2k5/system-monitor/blob/main/static/js/index-script.js"
click node_charts "https://github.com/tds2k5/system-monitor/blob/main/static/js/index-script.js"
click node_status_display "https://github.com/tds2k5/system-monitor/blob/main/static/js/index-script.js"
click node_dark_mode "https://github.com/tds2k5/system-monitor/blob/main/static/js/index-script.js"
click node_session "https://github.com/tds2k5/system-monitor/blob/main/app.py"
click node_preference_store "https://github.com/tds2k5/system-monitor/blob/main/static/js/index-script.js"

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_login_page,node_dashboard_page,node_browser toneBlue
class node_sampling,node_psutil,node_warning toneAmber
class node_polling,node_charts,node_status_display,node_dark_mode toneMint
class node_session,node_flask_session,node_preference_store toneRose
```

## Components

### Web application

- [Flask routes](https://github.com/tds2k5/system-monitor/blob/main/app.py): `app.py`
- [Login page](https://github.com/tds2k5/system-monitor/blob/main/templates/login.html): `templates/login.html`
- [Dashboard page](https://github.com/tds2k5/system-monitor/blob/main/templates/index.html): `templates/index.html`

### Live monitoring

- [System sampling](https://github.com/tds2k5/system-monitor/blob/main/app.py): `app.py`
- **psutil metrics**
- [Warning threshold](https://github.com/tds2k5/system-monitor/blob/main/app.py): `app.py`

### Dashboard interface

- [Data polling](https://github.com/tds2k5/system-monitor/blob/main/static/js/index-script.js): `static/js/index-script.js`
- [Usage charts](https://github.com/tds2k5/system-monitor/blob/main/static/js/index-script.js): `static/js/index-script.js`
- [Status display](https://github.com/tds2k5/system-monitor/blob/main/static/js/index-script.js): `static/js/index-script.js`
- [Dark mode](https://github.com/tds2k5/system-monitor/blob/main/static/js/index-script.js): `static/js/index-script.js`

### Session and preference state

- [Session handling](https://github.com/tds2k5/system-monitor/blob/main/app.py): `app.py`
- **Flask-Session**
- [Browser preference](https://github.com/tds2k5/system-monitor/blob/main/static/js/index-script.js): `static/js/index-script.js`

### Other components

- **Browser user**

## Connections

- Browser user → Flask routes: opens app (evidence: `README.md`)
- Flask routes → Login page: renders login (evidence: `app.py`)
- Flask routes → Dashboard page: renders dashboard (evidence: `app.py`)
- Flask routes → Session handling: checks login (evidence: `app.py`)
- Flask routes → Session handling: sets login (evidence: `app.py`)
- Flask routes → System sampling: samples metrics (evidence: `app.py`)
- System sampling → psutil metrics: reads metrics (evidence: `app.py`)
- Flask routes → Warning threshold: checks threshold (evidence: `app.py`)
- Flask routes → Flask-Session: configures sessions (evidence: `app.py`)
- Data polling → Flask routes: requests /data (evidence: `static/js/index-script.js`)
- Flask routes → Data polling: returns JSON (evidence: `app.py`)
- Data polling → Usage charts: updates charts (evidence: `static/js/index-script.js`)
- Data polling → Status display: updates status (evidence: `static/js/index-script.js`)
- Data polling → Dashboard page: updates page (evidence: `static/js/index-script.js`)
- Dark mode → Browser preference: stores preference (evidence: `static/js/index-script.js`)
