# nanyoullm/simple-model-monitor architecture

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

- Interactive diagram: https://gitdiagram.com/nanyoullm/simple-model-monitor
- Repository: https://github.com/nanyoullm/simple-model-monitor

## Overview

This Flask application monitors distributions for multiple credit scores and their features across reporting periods. Users view the latest period by default, then select scores and periods to compare model and feature distributions; the browser receives chart-ready data for rendering. The backend queries MySQL and formats results through shared utilities. Fake-data generation populates the same tables for demonstration. The templates and static tree establish the dashboard UI, while excerpts do not expose its exact Ajax or chart wiring; those links are therefore omitted.

Main entry points: [`model_monitor.py`](https://github.com/nanyoullm/simple-model-monitor/blob/master/model_monitor.py) (Flask app), [`utils.py`](https://github.com/nanyoullm/simple-model-monitor/blob/master/utils.py) (Query utilities), [`save_fake_data.py`](https://github.com/nanyoullm/simple-model-monitor/blob/master/save_fake_data.py) (Fake data generator), [`templates/index.html`](https://github.com/nanyoullm/simple-model-monitor/blob/master/templates/index.html) (Dashboard page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_flask["Flask app<br/>[model_monitor.py]"]
  node_tornado["LAN server<br/>[server.py]"]
end

subgraph group_data["Distribution data"]
  node_mysql[("MySQL")]
  node_modelstats[("Model statistics<br/>[init.sql]")]
  node_featurestats[("Feature statistics<br/>[init.sql]")]
  node_queries["Query utilities<br/>[utils.py]"]
  node_formatters["Chart formatting<br/>[utils.py]"]
  node_fakegen["Fake data generator<br/>[save_fake_data.py]"]
  node_randomdata["Synthetic distributions<br/>[utils.py]"]
end

subgraph group_ui["Dashboard UI"]
  node_index["Dashboard page<br/>[index.html]"]
  node_testpage["Test page<br/>[test.html]"]
  node_browser["Browser charts<br/>[china.js]"]
  node_selectors["Score and period selectors"]
  node_styles["Dashboard styles<br/>[bootstrap.css]"]
end

node_user(("Analyst"))

node_user -->|"requests dashboard"| node_flask
node_tornado -->|"hosts app"| node_flask
node_flask -->|"requests data"| node_queries
node_queries -->|"queries"| node_mysql
node_mysql -->|"reads"| node_modelstats
node_mysql -->|"reads"| node_featurestats
node_queries -->|"formats results"| node_formatters
node_flask -->|"renders page"| node_index
node_flask -->|"returns chart data"| node_browser
node_user -->|"selects comparisons"| node_selectors
node_fakegen -->|"generates"| node_randomdata
node_fakegen -->|"writes data"| node_mysql
node_mysql -->|"stores"| node_modelstats
node_mysql -->|"stores"| node_featurestats
node_index -->|"uses styles"| node_styles

click node_flask "https://github.com/nanyoullm/simple-model-monitor/blob/master/model_monitor.py"
click node_tornado "https://github.com/nanyoullm/simple-model-monitor/blob/master/server.py"
click node_modelstats "https://github.com/nanyoullm/simple-model-monitor/blob/master/init.sql"
click node_featurestats "https://github.com/nanyoullm/simple-model-monitor/blob/master/init.sql"
click node_queries "https://github.com/nanyoullm/simple-model-monitor/blob/master/utils.py"
click node_formatters "https://github.com/nanyoullm/simple-model-monitor/blob/master/utils.py"
click node_fakegen "https://github.com/nanyoullm/simple-model-monitor/blob/master/save_fake_data.py"
click node_randomdata "https://github.com/nanyoullm/simple-model-monitor/blob/master/utils.py"
click node_index "https://github.com/nanyoullm/simple-model-monitor/blob/master/templates/index.html"
click node_testpage "https://github.com/nanyoullm/simple-model-monitor/blob/master/templates/test.html"
click node_browser "https://github.com/nanyoullm/simple-model-monitor/blob/master/static/js/china.js"
click node_selectors "https://github.com/nanyoullm/simple-model-monitor/blob/master/static/js/bootstrap-select.js"
click node_styles "https://github.com/nanyoullm/simple-model-monitor/blob/master/static/css/bootstrap.css"

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_tornado toneBlue
class node_mysql,node_modelstats,node_featurestats,node_queries,node_formatters,node_fakegen,node_randomdata toneAmber
class node_index,node_testpage,node_browser,node_selectors,node_styles toneMint
class node_user toneIndigo
```

## Components

### Web application

- [Flask app](https://github.com/nanyoullm/simple-model-monitor/blob/master/model_monitor.py): `model_monitor.py`
- [LAN server](https://github.com/nanyoullm/simple-model-monitor/blob/master/server.py): `server.py`

### Distribution data

- **MySQL**
- [Model statistics](https://github.com/nanyoullm/simple-model-monitor/blob/master/init.sql): `init.sql`
- [Feature statistics](https://github.com/nanyoullm/simple-model-monitor/blob/master/init.sql): `init.sql`
- [Query utilities](https://github.com/nanyoullm/simple-model-monitor/blob/master/utils.py): `utils.py`
- [Chart formatting](https://github.com/nanyoullm/simple-model-monitor/blob/master/utils.py): `utils.py`
- [Fake data generator](https://github.com/nanyoullm/simple-model-monitor/blob/master/save_fake_data.py): `save_fake_data.py`
- [Synthetic distributions](https://github.com/nanyoullm/simple-model-monitor/blob/master/utils.py): `utils.py`

### Dashboard UI

- [Dashboard page](https://github.com/nanyoullm/simple-model-monitor/blob/master/templates/index.html): `templates/index.html`
- [Test page](https://github.com/nanyoullm/simple-model-monitor/blob/master/templates/test.html): `templates/test.html`
- [Browser charts](https://github.com/nanyoullm/simple-model-monitor/blob/master/static/js/china.js): `static/js/china.js`
- [Score and period selectors](https://github.com/nanyoullm/simple-model-monitor/blob/master/static/js/bootstrap-select.js): `static/js/bootstrap-select.js`
- [Dashboard styles](https://github.com/nanyoullm/simple-model-monitor/blob/master/static/css/bootstrap.css): `static/css/bootstrap.css`

### Other components

- **Analyst**

## Connections

- Analyst → Flask app: requests dashboard
- LAN server → Flask app: hosts app
- Flask app → Query utilities: requests data
- Query utilities → MySQL: queries
- MySQL → Model statistics: reads
- MySQL → Feature statistics: reads
- Query utilities → Chart formatting: formats results
- Flask app → Dashboard page: renders page
- Flask app → Browser charts: returns chart data
- Analyst → Score and period selectors: selects comparisons
- Fake data generator → Synthetic distributions: generates
- Fake data generator → MySQL: writes data
- MySQL → Model statistics: stores
- MySQL → Feature statistics: stores
- Dashboard page → Dashboard styles: uses styles
