# blacksnowmartin/netalmoner architecture

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

- Interactive diagram: https://gitdiagram.com/blacksnowmartin/netalmoner
- Repository: https://github.com/blacksnowmartin/netalmoner

## Overview

Net Almoner manages network-device configuration backups, history, diffs, and backup-health metrics. The main workflow starts in the React dashboard: users manage devices or request a backup, the FastAPI backup route fetches configuration over SSH and stores the result, and users can inspect history and compare backups. The API also serves device CRUD and dashboard metrics. Edges reflect shown calls, imports listed in the SOURCE INDEX, or documented setup; unsampled frontend and backend wiring is not inferred.

Main entry points: [`backend/app/routers/backups.py`](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/routers/backups.py) (Backup Routes), [`backend/app/routers/metrics.py`](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/routers/metrics.py) (Metrics Route), [`backend/app/routers/devices.py`](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/routers/devices.py) (Device Routes), [`backend/app/core/database.py`](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/core/database.py) (SQLite Database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard"]
  node_app["Dashboard UI<br/>[App.jsx]"]
  node_entry["React Mount<br/>[main.jsx]"]
end

subgraph group_api["API Routes"]
  node_server["FastAPI App<br/>[main.py]"]
  node_metrics_routes["Metrics Route<br/>[metrics.py]"]
end

subgraph group_backup["Backup Services"]
  node_backup_routes["Backup Routes<br/>[backups.py]"]
  node_ssh["SSH Config Fetch<br/>[netmiko_ssh.py]"]
  node_diff["Diff Engine<br/>[diff_engine.py]"]
end

subgraph group_devices["Device Management"]
  node_device_routes["Device Routes<br/>[devices.py]"]
end

subgraph group_data["Persistence and Schemas"]
  node_device_model["Device Records<br/>[device.py]"]
  node_backup_model["Backup Records<br/>[backup.py]"]
  node_db[("SQLite Database<br/>[database.py]")]
  node_device_schema["Device Schemas<br/>[device.py]"]
  node_device_internal["Device Write Schemas<br/>[device_internal.py]"]
  node_backup_schema["Backup Schemas<br/>[backup.py]"]
  node_diff_schema["Diff Schema<br/>[diff.py]"]
  node_metrics_schema["Metrics Schemas<br/>[metrics.py]"]
end

node_user(("Operator"))
node_network_device(("Managed Network Device"))

node_user -->|"uses"| node_app
node_entry -->|"mounts"| node_app
node_app -->|"requests device API"| node_device_routes
node_app -->|"requests backup API"| node_backup_routes
node_app -->|"requests dashboard API"| node_metrics_routes
node_server -->|"registers"| node_device_routes
node_server -->|"registers"| node_backup_routes
node_server -->|"registers"| node_metrics_routes
node_server -->|"initializes tables"| node_db
node_device_routes -->|"queries and updates"| node_device_model
node_device_routes -->|"uses sessions"| node_db
node_device_routes -->|"validates responses"| node_device_schema
node_device_routes -->|"validates writes"| node_device_internal
node_backup_routes -->|"looks up device"| node_device_model
node_backup_routes -->|"reads and saves"| node_backup_model
node_backup_routes -->|"uses sessions"| node_db
node_backup_routes -->|"fetches configuration"| node_ssh
node_network_device -->|"provides configuration"| node_ssh
node_backup_routes -->|"generates comparison"| node_diff
node_backup_routes -->|"validates backup data"| node_backup_schema
node_backup_routes -->|"formats diff response"| node_diff_schema
node_metrics_routes -->|"reads devices"| node_device_model
node_metrics_routes -->|"reads backup history"| node_backup_model
node_metrics_routes -->|"uses sessions"| node_db
node_metrics_routes -->|"builds dashboard response"| node_metrics_schema
node_device_model -->|"uses ORM base"| node_db
node_backup_model -->|"uses ORM base"| node_db

click node_app "https://github.com/blacksnowmartin/netalmoner/blob/main/frontend/src/App.jsx"
click node_entry "https://github.com/blacksnowmartin/netalmoner/blob/main/frontend/src/main.jsx"
click node_server "https://github.com/blacksnowmartin/netalmoner/blob/main/backend/main.py"
click node_backup_routes "https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/routers/backups.py"
click node_device_routes "https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/routers/devices.py"
click node_metrics_routes "https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/routers/metrics.py"
click node_ssh "https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/services/netmiko_ssh.py"
click node_diff "https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/services/diff_engine.py"
click node_device_model "https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/models/device.py"
click node_backup_model "https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/models/backup.py"
click node_db "https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/core/database.py"
click node_device_schema "https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/schemas/device.py"
click node_device_internal "https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/schemas/device_internal.py"
click node_backup_schema "https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/schemas/backup.py"
click node_diff_schema "https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/schemas/diff.py"
click node_metrics_schema "https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/schemas/metrics.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_app,node_entry toneBlue
class node_server,node_metrics_routes toneAmber
class node_backup_routes,node_ssh,node_diff toneMint
class node_device_routes toneRose
class node_device_model,node_backup_model,node_db,node_device_schema,node_device_internal,node_backup_schema,node_diff_schema,node_metrics_schema,node_user,node_network_device toneIndigo
```

## Components

### Dashboard

- [Dashboard UI](https://github.com/blacksnowmartin/netalmoner/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [React Mount](https://github.com/blacksnowmartin/netalmoner/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`

### API Routes

- [FastAPI App](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/main.py): `backend/main.py`
- [Metrics Route](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/routers/metrics.py): `backend/app/routers/metrics.py`

### Backup Services

- [Backup Routes](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/routers/backups.py): `backend/app/routers/backups.py`
- [SSH Config Fetch](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/services/netmiko_ssh.py): `backend/app/services/netmiko_ssh.py`
- [Diff Engine](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/services/diff_engine.py): `backend/app/services/diff_engine.py`

### Device Management

- [Device Routes](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/routers/devices.py): `backend/app/routers/devices.py`

### Persistence and Schemas

- [Device Records](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/models/device.py): `backend/app/models/device.py`
- [Backup Records](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/models/backup.py): `backend/app/models/backup.py`
- [SQLite Database](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/core/database.py): `backend/app/core/database.py`
- [Device Schemas](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/schemas/device.py): `backend/app/schemas/device.py`
- [Device Write Schemas](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/schemas/device_internal.py): `backend/app/schemas/device_internal.py`
- [Backup Schemas](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/schemas/backup.py): `backend/app/schemas/backup.py`
- [Diff Schema](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/schemas/diff.py): `backend/app/schemas/diff.py`
- [Metrics Schemas](https://github.com/blacksnowmartin/netalmoner/blob/main/backend/app/schemas/metrics.py): `backend/app/schemas/metrics.py`

### Other components

- **Operator**
- **Managed Network Device**

## Connections

- Operator → Dashboard UI: uses (evidence: `frontend/src/App.jsx`)
- React Mount → Dashboard UI: mounts (evidence: `frontend/src/main.jsx`)
- Dashboard UI → Device Routes: requests device API (evidence: `frontend/src/App.jsx`)
- Dashboard UI → Backup Routes: requests backup API (evidence: `frontend/src/App.jsx`)
- Dashboard UI → Metrics Route: requests dashboard API (evidence: `frontend/src/App.jsx`)
- FastAPI App → Device Routes: registers (evidence: `backend/main.py`)
- FastAPI App → Backup Routes: registers (evidence: `backend/main.py`)
- FastAPI App → Metrics Route: registers (evidence: `backend/main.py`)
- FastAPI App → SQLite Database: initializes tables (evidence: `backend/main.py`)
- Device Routes → Device Records: queries and updates (evidence: `backend/app/routers/devices.py`)
- Device Routes → SQLite Database: uses sessions (evidence: `backend/app/routers/devices.py`)
- Device Routes → Device Schemas: validates responses (evidence: `backend/app/routers/devices.py`)
- Device Routes → Device Write Schemas: validates writes (evidence: `backend/app/routers/devices.py`)
- Backup Routes → Device Records: looks up device (evidence: `backend/app/routers/backups.py`)
- Backup Routes → Backup Records: reads and saves (evidence: `backend/app/routers/backups.py`)
- Backup Routes → SQLite Database: uses sessions (evidence: `backend/app/routers/backups.py`)
- Backup Routes → SSH Config Fetch: fetches configuration (evidence: `backend/app/routers/backups.py`)
- Managed Network Device → SSH Config Fetch: provides configuration (evidence: `backend/app/services/netmiko_ssh.py`)
- Backup Routes → Diff Engine: generates comparison (evidence: `backend/app/routers/backups.py`)
- Backup Routes → Backup Schemas: validates backup data (evidence: `backend/app/routers/backups.py`)
- Backup Routes → Diff Schema: formats diff response (evidence: `backend/app/routers/backups.py`)
- Metrics Route → Device Records: reads devices (evidence: `backend/app/routers/metrics.py`)
- Metrics Route → Backup Records: reads backup history (evidence: `backend/app/routers/metrics.py`)
- Metrics Route → SQLite Database: uses sessions (evidence: `backend/app/routers/metrics.py`)
- Metrics Route → Metrics Schemas: builds dashboard response (evidence: `backend/app/routers/metrics.py`)
- Device Records → SQLite Database: uses ORM base (evidence: `backend/app/models/device.py`)
- Backup Records → SQLite Database: uses ORM base (evidence: `backend/app/models/backup.py`)
