# gwill1337/mona architecture

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

- Interactive diagram: https://gitdiagram.com/gwill1337/mona
- Repository: https://github.com/gwill1337/mona

## Overview

MONA provides authenticated device administration and monitoring dashboards backed by a FastAPI service. Users sign in, manage monitored devices, and view periodically refreshed metrics and anomaly results; administrators can also manage users and train models. Background Celery work collects device metrics and performs anomaly analysis, with PostgreSQL holding application and analytics records and Redis supporting sessions and task execution. The README documents these capabilities; several router and UI implementations were not sampled, so their internal call paths are not expanded beyond documented relationships.

Main entry points: [`mona_core/main.py`](https://github.com/gwill1337/mona/blob/main/mona_core/main.py) (FastAPI app), [`mona_core/db.py`](https://github.com/gwill1337/mona/blob/main/mona_core/db.py) (PostgreSQL), [`frontend/src/api.tsx`](https://github.com/gwill1337/mona/blob/main/frontend/src/api.tsx) (HTTP client), [`frontend/src/main.tsx`](https://github.com/gwill1337/mona/blob/main/frontend/src/main.tsx) (Route setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_frontend_routes["Route setup<br/>[main.tsx]"]
  node_login["Sign-in<br/>[Login.tsx]"]
  node_device_admin["Device admin<br/>[DeviceAdmin.tsx]"]
  node_dashboard["Monitoring dashboard<br/>[Dashboard.tsx]"]
  node_user_board["User management<br/>[UserBoard.tsx]"]
  node_model_panel["Model controls<br/>[modelPanel.tsx]"]
  node_api_client["HTTP client<br/>[api.tsx]"]
end

subgraph group_api["API and access"]
  node_api_engine["FastAPI app<br/>[main.py]"]
  node_auth["Authentication<br/>[security.py]"]
  node_device_routes["Device endpoints<br/>[devices.py]"]
  node_monitor_routes["Monitoring endpoints<br/>[monitoring.py]"]
  node_model_routes["Model endpoints<br/>[model.py]"]
  node_user_routes["User endpoints<br/>[users.py]"]
  node_task_routes["Task status<br/>[tasks.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
end

subgraph group_jobs["Collection and analytics"]
  node_celery_tasks["Background tasks<br/>[tasks.py]"]
  node_ml["Anomaly modeling<br/>[ml.py]"]
  node_celery_config["Task configuration<br/>[celery_conf.py]"]
end

subgraph group_state["Application state"]
  node_postgres[("PostgreSQL<br/>[db.py]")]
  node_config["Runtime configuration<br/>[config.py]"]
  node_redis[("Redis")]
end

subgraph group_monitoring["Monitoring integrations"]
  node_node_exporter["Node exporter"]
  node_prometheus["Prometheus"]
end

node_operator(("User"))

node_operator -->|"opens app"| node_frontend_routes
node_frontend_routes -->|"routes to"| node_login
node_frontend_routes -->|"routes to"| node_device_admin
node_frontend_routes -->|"routes to"| node_dashboard
node_frontend_routes -->|"routes to"| node_user_board
node_login -->|"submits credentials"| node_api_client
node_device_admin -->|"requests devices"| node_api_client
node_dashboard -->|"loads monitoring data"| node_api_client
node_dashboard -->|"renders controls"| node_model_panel
node_user_board -->|"requests users"| node_api_client
node_model_panel -->|"requests model actions"| node_api_client
node_api_client -->|"sends API requests"| node_api_engine
node_api_engine -->|"registers auth routes"| node_auth
node_api_engine -->|"registers routes"| node_device_routes
node_api_engine -->|"registers routes"| node_monitor_routes
node_api_engine -->|"registers routes"| node_model_routes
node_api_engine -->|"registers routes"| node_user_routes
node_api_engine -->|"registers routes"| node_task_routes
node_device_routes -->|"reads and writes"| node_postgres
node_monitor_routes -->|"queries metrics"| node_postgres
node_model_routes -->|"accesses model data"| node_postgres
node_user_routes -->|"reads and writes users"| node_postgres
node_user_routes -->|"removes sessions"| node_auth
node_task_routes -->|"queries task result"| node_config
node_auth -->|"checks accounts"| node_postgres
node_auth -->|"stores sessions"| node_redis
node_celery_tasks -->|"stores collected data"| node_postgres
node_celery_tasks -.->|"runs detection"| node_ml
node_ml -->|"reads metrics and models"| node_postgres
node_celery_config -->|"uses settings"| node_config
node_config -->|"configures broker"| node_redis
node_config -->|"configures connection"| node_postgres
node_celery_tasks -.->|"collects device metrics"| node_node_exporter
node_prometheus -.->|"scrapes targets"| node_node_exporter
node_operator -.->|"views monitoring"| node_prometheus

click node_frontend_routes "https://github.com/gwill1337/mona/blob/main/frontend/src/main.tsx"
click node_login "https://github.com/gwill1337/mona/blob/main/frontend/src/Login.tsx"
click node_device_admin "https://github.com/gwill1337/mona/blob/main/frontend/src/pages/DeviceAdmin.tsx"
click node_dashboard "https://github.com/gwill1337/mona/blob/main/frontend/src/pages/Dashboard.tsx"
click node_user_board "https://github.com/gwill1337/mona/blob/main/frontend/src/pages/UserBoard.tsx"
click node_model_panel "https://github.com/gwill1337/mona/blob/main/frontend/src/components/modelPanel.tsx"
click node_api_client "https://github.com/gwill1337/mona/blob/main/frontend/src/api.tsx"
click node_api_engine "https://github.com/gwill1337/mona/blob/main/mona_core/main.py"
click node_auth "https://github.com/gwill1337/mona/blob/main/mona_core/security.py"
click node_device_routes "https://github.com/gwill1337/mona/blob/main/mona_core/routers/devices.py"
click node_monitor_routes "https://github.com/gwill1337/mona/blob/main/mona_core/routers/monitoring.py"
click node_model_routes "https://github.com/gwill1337/mona/blob/main/mona_core/routers/model.py"
click node_user_routes "https://github.com/gwill1337/mona/blob/main/mona_core/routers/users.py"
click node_task_routes "https://github.com/gwill1337/mona/blob/main/mona_core/routers/tasks.py"
click node_schemas "https://github.com/gwill1337/mona/blob/main/mona_core/schemas.py"
click node_celery_tasks "https://github.com/gwill1337/mona/blob/main/mona_core/tasks.py"
click node_ml "https://github.com/gwill1337/mona/blob/main/mona_core/ml.py"
click node_celery_config "https://github.com/gwill1337/mona/blob/main/mona_core/celery_conf.py"
click node_postgres "https://github.com/gwill1337/mona/blob/main/mona_core/db.py"
click node_config "https://github.com/gwill1337/mona/blob/main/mona_core/config.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_frontend_routes,node_login,node_device_admin,node_dashboard,node_user_board,node_model_panel,node_api_client,node_operator toneBlue
class node_api_engine,node_auth,node_device_routes,node_monitor_routes,node_model_routes,node_user_routes,node_task_routes,node_schemas toneAmber
class node_celery_tasks,node_ml,node_celery_config toneMint
class node_postgres,node_config,node_redis toneRose
class node_node_exporter,node_prometheus toneIndigo
```

## Components

### Web application

- [Route setup](https://github.com/gwill1337/mona/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [Sign-in](https://github.com/gwill1337/mona/blob/main/frontend/src/Login.tsx): `frontend/src/Login.tsx`
- [Device admin](https://github.com/gwill1337/mona/blob/main/frontend/src/pages/DeviceAdmin.tsx): `frontend/src/pages/DeviceAdmin.tsx`
- [Monitoring dashboard](https://github.com/gwill1337/mona/blob/main/frontend/src/pages/Dashboard.tsx): `frontend/src/pages/Dashboard.tsx`
- [User management](https://github.com/gwill1337/mona/blob/main/frontend/src/pages/UserBoard.tsx): `frontend/src/pages/UserBoard.tsx`
- [Model controls](https://github.com/gwill1337/mona/blob/main/frontend/src/components/modelPanel.tsx): `frontend/src/components/modelPanel.tsx`
- [HTTP client](https://github.com/gwill1337/mona/blob/main/frontend/src/api.tsx): `frontend/src/api.tsx`

### API and access

- [FastAPI app](https://github.com/gwill1337/mona/blob/main/mona_core/main.py): `mona_core/main.py`
- [Authentication](https://github.com/gwill1337/mona/blob/main/mona_core/security.py): `mona_core/security.py`
- [Device endpoints](https://github.com/gwill1337/mona/blob/main/mona_core/routers/devices.py): `mona_core/routers/devices.py`
- [Monitoring endpoints](https://github.com/gwill1337/mona/blob/main/mona_core/routers/monitoring.py): `mona_core/routers/monitoring.py`
- [Model endpoints](https://github.com/gwill1337/mona/blob/main/mona_core/routers/model.py): `mona_core/routers/model.py`
- [User endpoints](https://github.com/gwill1337/mona/blob/main/mona_core/routers/users.py): `mona_core/routers/users.py`
- [Task status](https://github.com/gwill1337/mona/blob/main/mona_core/routers/tasks.py): `mona_core/routers/tasks.py`
- [Request schemas](https://github.com/gwill1337/mona/blob/main/mona_core/schemas.py): `mona_core/schemas.py`

### Collection and analytics

- [Background tasks](https://github.com/gwill1337/mona/blob/main/mona_core/tasks.py): `mona_core/tasks.py`
- [Anomaly modeling](https://github.com/gwill1337/mona/blob/main/mona_core/ml.py): `mona_core/ml.py`
- [Task configuration](https://github.com/gwill1337/mona/blob/main/mona_core/celery_conf.py): `mona_core/celery_conf.py`

### Application state

- [PostgreSQL](https://github.com/gwill1337/mona/blob/main/mona_core/db.py): `mona_core/db.py`
- [Runtime configuration](https://github.com/gwill1337/mona/blob/main/mona_core/config.py): `mona_core/config.py`
- **Redis**

### Monitoring integrations

- **Node exporter**
- **Prometheus**

### Other components

- **User**

## Connections

- User → Route setup: opens app (evidence: `frontend/src/main.tsx`)
- Route setup → Sign-in: routes to (evidence: `frontend/src/main.tsx`)
- Route setup → Device admin: routes to (evidence: `frontend/src/main.tsx`)
- Route setup → Monitoring dashboard: routes to (evidence: `frontend/src/main.tsx`)
- Route setup → User management: routes to (evidence: `frontend/src/main.tsx`)
- Sign-in → HTTP client: submits credentials (evidence: `frontend/src/Login.tsx`)
- Device admin → HTTP client: requests devices (evidence: `frontend/src/pages/DeviceAdmin.tsx`)
- Monitoring dashboard → HTTP client: loads monitoring data (evidence: `frontend/src/pages/Dashboard.tsx`)
- Monitoring dashboard → Model controls: renders controls (evidence: `frontend/src/pages/Dashboard.tsx`)
- User management → HTTP client: requests users (evidence: `frontend/src/pages/UserBoard.tsx`)
- Model controls → HTTP client: requests model actions (evidence: `frontend/src/components/modelPanel.tsx`)
- HTTP client → FastAPI app: sends API requests (evidence: `frontend/src/api.tsx`)
- FastAPI app → Authentication: registers auth routes (evidence: `mona_core/main.py`)
- FastAPI app → Device endpoints: registers routes (evidence: `mona_core/main.py`)
- FastAPI app → Monitoring endpoints: registers routes (evidence: `mona_core/main.py`)
- FastAPI app → Model endpoints: registers routes (evidence: `mona_core/main.py`)
- FastAPI app → User endpoints: registers routes (evidence: `mona_core/main.py`)
- FastAPI app → Task status: registers routes (evidence: `mona_core/main.py`)
- Device endpoints → PostgreSQL: reads and writes (evidence: `mona_core/routers/devices.py`)
- Monitoring endpoints → PostgreSQL: queries metrics (evidence: `mona_core/routers/monitoring.py`)
- Model endpoints → PostgreSQL: accesses model data (evidence: `mona_core/routers/model.py`)
- User endpoints → PostgreSQL: reads and writes users (evidence: `mona_core/routers/users.py`)
- User endpoints → Authentication: removes sessions (evidence: `mona_core/routers/users.py`)
- Task status → Runtime configuration: queries task result (evidence: `mona_core/routers/tasks.py`)
- Authentication → PostgreSQL: checks accounts (evidence: `mona_core/security.py`)
- Authentication → Redis: stores sessions (evidence: `mona_core/security.py`)
- Background tasks → PostgreSQL: stores collected data (evidence: `mona_core/tasks.py`)
- Background tasks → Anomaly modeling: runs detection
- Anomaly modeling → PostgreSQL: reads metrics and models (evidence: `mona_core/ml.py`)
- Task configuration → Runtime configuration: uses settings (evidence: `mona_core/celery_conf.py`)
- Runtime configuration → Redis: configures broker (evidence: `mona_core/config.py`)
- Runtime configuration → PostgreSQL: configures connection (evidence: `mona_core/db.py`)
- Background tasks → Node exporter: collects device metrics (evidence: `README.md`)
- Prometheus → Node exporter: scrapes targets (evidence: `README.md`)
- User → Prometheus: views monitoring (evidence: `README.md`)
