# samuel-gongkl/as400_monitor architecture

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

- Interactive diagram: https://gitdiagram.com/samuel-gongkl/as400_monitor
- Repository: https://github.com/samuel-gongkl/as400_monitor

## Overview

This is a Flask-based IBM i monitoring dashboard for operators. The main workflow is browser polling of the Flask metrics API, which gathers registered monitor results through IBM i queries and returns them for dashboard rendering. Separate LPAR views show CPU history and comparisons; alert monitoring evaluates collector results and can notify configured channels. The map follows documented workflows and source-index references; several route and frontend implementation details were not sampled, so those links rely on README evidence.

Main entry points: [`collectors/base.py`](https://github.com/samuel-gongkl/as400_monitor/blob/main/collectors/base.py) (Collector registry), [`db.py`](https://github.com/samuel-gongkl/as400_monitor/blob/main/db.py) (ODBC query layer), [`app.py`](https://github.com/samuel-gongkl/as400_monitor/blob/main/app.py) (Routes and API), [`notifications.py`](https://github.com/samuel-gongkl/as400_monitor/blob/main/notifications.py) (Alert monitor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web dashboard"]
  node_dashboard["Overview page<br/>[index.html]"]
  node_lpar_page["LPAR CPU page<br/>[lpar.html]"]
  node_dashboard_js["Dashboard renderer<br/>[dashboard.js]"]
  node_lpar_js["LPAR charts<br/>[lpar.js]"]
  node_flask["Routes and API<br/>[app.py]"]
end

subgraph group_monitoring["Metric collection"]
  node_registry["Collector registry<br/>[base.py]"]
  node_system["System status<br/>[system_status.py]"]
  node_memory["Memory pools<br/>[memory.py]"]
  node_disk["Disk units<br/>[disk.py]"]
  node_subsystems["Subsystems<br/>[subsystems.py]"]
  node_cpu_jobs["Highest CPU jobs"]
  node_messages["Operator messages<br/>[messages.py]"]
  node_db["ODBC query layer<br/>[db.py]"]
end

subgraph group_lpar["LPAR history"]
  node_lpar_data["LPAR sampler and stats<br/>[lpar.py]"]
  node_history_db[("CPU history<br/>[lpar.py]")]
end

subgraph group_integrations["Configuration and alerts"]
  node_config["Settings and LPARs<br/>[config.py]"]
  node_notifications["Alert monitor<br/>[notifications.py]"]
end

node_operator(("Operator"))
node_ibmi[("IBM i services")]
node_email["Email service"]
node_teams["Microsoft Teams"]

node_operator -->|"opens"| node_dashboard
node_operator -->|"opens"| node_lpar_page
node_dashboard -->|"renders with"| node_dashboard_js
node_lpar_page -->|"renders with"| node_lpar_js
node_dashboard_js -->|"polls metrics"| node_flask
node_lpar_js -->|"requests LPAR data"| node_flask
node_flask -->|"collects metrics"| node_registry
node_flask -->|"uses settings"| node_config
node_flask -->|"serves LPAR data"| node_lpar_data
node_flask -->|"starts monitor"| node_notifications
node_registry -->|"registers"| node_system
node_registry -->|"registers"| node_memory
node_registry -->|"registers"| node_disk
node_registry -->|"registers"| node_subsystems
node_registry -->|"registers"| node_cpu_jobs
node_registry -->|"registers"| node_messages
node_system -->|"queries"| node_db
node_memory -->|"queries"| node_db
node_disk -->|"queries"| node_db
node_subsystems -->|"queries"| node_db
node_cpu_jobs -->|"samples jobs"| node_db
node_messages -->|"queries"| node_db
node_db -->|"queries over ODBC"| node_ibmi
node_lpar_data -->|"samples CPU"| node_db
node_lpar_data -->|"stores samples"| node_history_db
node_notifications -->|"checks payloads"| node_registry
node_notifications -.->|"sends alerts"| node_email
node_notifications -.->|"sends alerts"| node_teams

click node_dashboard "https://github.com/samuel-gongkl/as400_monitor/blob/main/templates/index.html"
click node_lpar_page "https://github.com/samuel-gongkl/as400_monitor/blob/main/templates/lpar.html"
click node_dashboard_js "https://github.com/samuel-gongkl/as400_monitor/blob/main/static/dashboard.js"
click node_lpar_js "https://github.com/samuel-gongkl/as400_monitor/blob/main/static/lpar.js"
click node_flask "https://github.com/samuel-gongkl/as400_monitor/blob/main/app.py"
click node_registry "https://github.com/samuel-gongkl/as400_monitor/blob/main/collectors/base.py"
click node_system "https://github.com/samuel-gongkl/as400_monitor/blob/main/collectors/system_status.py"
click node_memory "https://github.com/samuel-gongkl/as400_monitor/blob/main/collectors/memory.py"
click node_disk "https://github.com/samuel-gongkl/as400_monitor/blob/main/collectors/disk.py"
click node_subsystems "https://github.com/samuel-gongkl/as400_monitor/blob/main/collectors/subsystems.py"
click node_cpu_jobs "https://github.com/samuel-gongkl/as400_monitor/blob/main/collectors/highest_cpu_jobs.py"
click node_messages "https://github.com/samuel-gongkl/as400_monitor/blob/main/collectors/messages.py"
click node_db "https://github.com/samuel-gongkl/as400_monitor/blob/main/db.py"
click node_config "https://github.com/samuel-gongkl/as400_monitor/blob/main/config.py"
click node_lpar_data "https://github.com/samuel-gongkl/as400_monitor/blob/main/lpar.py"
click node_history_db "https://github.com/samuel-gongkl/as400_monitor/blob/main/lpar.py"
click node_notifications "https://github.com/samuel-gongkl/as400_monitor/blob/main/notifications.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_dashboard,node_lpar_page,node_dashboard_js,node_lpar_js,node_flask toneBlue
class node_registry,node_system,node_memory,node_disk,node_subsystems,node_cpu_jobs,node_messages,node_db,node_ibmi toneAmber
class node_lpar_data,node_history_db toneMint
class node_config,node_notifications toneRose
class node_operator,node_email,node_teams toneIndigo
```

## Components

### Web dashboard

- [Overview page](https://github.com/samuel-gongkl/as400_monitor/blob/main/templates/index.html): `templates/index.html`
- [LPAR CPU page](https://github.com/samuel-gongkl/as400_monitor/blob/main/templates/lpar.html): `templates/lpar.html`
- [Dashboard renderer](https://github.com/samuel-gongkl/as400_monitor/blob/main/static/dashboard.js): `static/dashboard.js`
- [LPAR charts](https://github.com/samuel-gongkl/as400_monitor/blob/main/static/lpar.js): `static/lpar.js`
- [Routes and API](https://github.com/samuel-gongkl/as400_monitor/blob/main/app.py): `app.py`

### Metric collection

- [Collector registry](https://github.com/samuel-gongkl/as400_monitor/blob/main/collectors/base.py): `collectors/base.py`
- [System status](https://github.com/samuel-gongkl/as400_monitor/blob/main/collectors/system_status.py): `collectors/system_status.py`
- [Memory pools](https://github.com/samuel-gongkl/as400_monitor/blob/main/collectors/memory.py): `collectors/memory.py`
- [Disk units](https://github.com/samuel-gongkl/as400_monitor/blob/main/collectors/disk.py): `collectors/disk.py`
- [Subsystems](https://github.com/samuel-gongkl/as400_monitor/blob/main/collectors/subsystems.py): `collectors/subsystems.py`
- [Highest CPU jobs](https://github.com/samuel-gongkl/as400_monitor/blob/main/collectors/highest_cpu_jobs.py): `collectors/highest_cpu_jobs.py`
- [Operator messages](https://github.com/samuel-gongkl/as400_monitor/blob/main/collectors/messages.py): `collectors/messages.py`
- [ODBC query layer](https://github.com/samuel-gongkl/as400_monitor/blob/main/db.py): `db.py`

### LPAR history

- [LPAR sampler and stats](https://github.com/samuel-gongkl/as400_monitor/blob/main/lpar.py): `lpar.py`
- [CPU history](https://github.com/samuel-gongkl/as400_monitor/blob/main/lpar.py): `lpar.py`

### Configuration and alerts

- [Settings and LPARs](https://github.com/samuel-gongkl/as400_monitor/blob/main/config.py): `config.py`
- [Alert monitor](https://github.com/samuel-gongkl/as400_monitor/blob/main/notifications.py): `notifications.py`

### Other components

- **Operator**
- **IBM i services**
- **Email service**
- **Microsoft Teams**

## Connections

- Operator → Overview page: opens (evidence: `README.md`)
- Operator → LPAR CPU page: opens (evidence: `README.md`)
- Overview page → Dashboard renderer: renders with (evidence: `README.md`)
- LPAR CPU page → LPAR charts: renders with (evidence: `README.md`)
- Dashboard renderer → Routes and API: polls metrics (evidence: `README.md`)
- LPAR charts → Routes and API: requests LPAR data (evidence: `README.md`)
- Routes and API → Collector registry: collects metrics (evidence: `README.md`)
- Routes and API → Settings and LPARs: uses settings (evidence: `app.py`)
- Routes and API → LPAR sampler and stats: serves LPAR data (evidence: `app.py`)
- Routes and API → Alert monitor: starts monitor (evidence: `app.py`)
- Collector registry → System status: registers (evidence: `collectors/__init__.py`)
- Collector registry → Memory pools: registers (evidence: `collectors/__init__.py`)
- Collector registry → Disk units: registers (evidence: `collectors/__init__.py`)
- Collector registry → Subsystems: registers (evidence: `collectors/__init__.py`)
- Collector registry → Highest CPU jobs: registers (evidence: `collectors/__init__.py`)
- Collector registry → Operator messages: registers (evidence: `collectors/__init__.py`)
- System status → ODBC query layer: queries (evidence: `collectors/system_status.py`)
- Memory pools → ODBC query layer: queries (evidence: `collectors/memory.py`)
- Disk units → ODBC query layer: queries (evidence: `collectors/disk.py`)
- Subsystems → ODBC query layer: queries (evidence: `collectors/subsystems.py`)
- Highest CPU jobs → ODBC query layer: samples jobs (evidence: `collectors/highest_cpu_jobs.py`)
- Operator messages → ODBC query layer: queries (evidence: `collectors/messages.py`)
- ODBC query layer → IBM i services: queries over ODBC (evidence: `README.md`)
- LPAR sampler and stats → ODBC query layer: samples CPU (evidence: `lpar.py`)
- LPAR sampler and stats → CPU history: stores samples (evidence: `README.md`)
- Alert monitor → Collector registry: checks payloads (evidence: `notifications.py`)
- Alert monitor → Email service: sends alerts (evidence: `notifications.py`)
- Alert monitor → Microsoft Teams: sends alerts (evidence: `notifications.py`)
