# scotteelp/netbox-automation architecture

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

- Interactive diagram: https://gitdiagram.com/scotteelp/netbox-automation
- Repository: https://github.com/scotteelp/netbox-automation

## Overview

This is a command-line NetBox automation script. A user selects a command; the script validates configuration, then retrieves device or rack data for reports, updates device ages, or fetches and displays a joke. Logging and terminal presentation support these workflows. The README documents the feature relationships; excerpts show configuration validation, API connectivity checks, device-age updates, and joke retrieval. Other internal feature boundaries are inferred from documented commands, not inspected source.

Main entry points: [`netbox_api.py`](https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py) (Command dispatcher), [`config.py`](https://github.com/scotteelp/netbox-automation/blob/main/config.py) (API configuration), [`ascii_art.py`](https://github.com/scotteelp/netbox-automation/blob/main/ascii_art.py) (ASCII art), [`color_definitions.py`](https://github.com/scotteelp/netbox-automation/blob/main/color_definitions.py) (Color definitions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Command and setup"]
  node_main["Command dispatcher<br/>[netbox_api.py]"]
  node_config["API configuration<br/>[config.py]"]
  node_validation["Config validation<br/>[netbox_api.py]"]
end

subgraph group_inventory["NetBox inventory"]
  node_devices["Device retrieval<br/>[netbox_api.py]"]
  node_age["Age calculation<br/>[netbox_api.py]"]
  node_age_update["Age updates<br/>[netbox_api.py]"]
  node_racks["Rack retrieval<br/>[netbox_api.py]"]
end

subgraph group_output["Reports and logging"]
  node_device_report["Device export<br/>[netbox_api.py]"]
  node_rack_report["Rack export<br/>[netbox_api.py]"]
  node_csv["Device CSV"]
  node_xlsx["Device XLSX"]
  node_rack_xlsx["Rack XLSX"]
  node_logging["Action logging<br/>[netbox_api.py]"]
  node_logfile["Log file"]
end

subgraph group_presentation["Terminal presentation"]
  node_joke["Joke retrieval<br/>[netbox_api.py]"]
  node_display["Terminal display<br/>[netbox_api.py]"]
  node_art["ASCII art<br/>[ascii_art.py]"]
  node_colors["Color definitions"]
end

node_user(("CLI user"))
node_netbox["NetBox API"]
node_joke_api["Jokes API"]

node_user -->|"runs command"| node_main
node_main -->|"validates config"| node_validation
node_validation -->|"reads settings"| node_config
node_validation -->|"checks connection"| node_netbox
node_main -->|"dispatches command"| node_devices
node_main -->|"dispatches command"| node_racks
node_main -->|"dispatches command"| node_age_update
node_main -->|"dispatches command"| node_joke
node_devices -->|"retrieves devices"| node_netbox
node_devices -->|"calculates age"| node_age
node_devices -->|"exports data"| node_device_report
node_device_report -->|"writes CSV"| node_csv
node_device_report -->|"writes XLSX"| node_xlsx
node_racks -->|"retrieves racks"| node_netbox
node_racks -->|"provides details"| node_rack_report
node_rack_report -->|"writes workbook"| node_rack_xlsx
node_age_update -->|"updates devices"| node_netbox
node_age_update -->|"calculates age"| node_age
node_main -->|"records actions"| node_logging
node_logging -->|"writes logs"| node_logfile
node_joke -->|"fetches joke"| node_joke_api
node_joke -->|"prints joke"| node_display
node_display -->|"uses artwork"| node_art
node_display -->|"uses colors"| node_colors

click node_main "https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py"
click node_config "https://github.com/scotteelp/netbox-automation/blob/main/config.py"
click node_validation "https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py"
click node_devices "https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py"
click node_age "https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py"
click node_age_update "https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py"
click node_racks "https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py"
click node_device_report "https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py"
click node_rack_report "https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py"
click node_logging "https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py"
click node_joke "https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py"
click node_display "https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py"
click node_art "https://github.com/scotteelp/netbox-automation/blob/main/ascii_art.py"
click node_colors "https://github.com/scotteelp/netbox-automation/blob/main/color_definitions.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_main,node_config,node_validation,node_user toneBlue
class node_devices,node_age,node_age_update,node_racks toneAmber
class node_device_report,node_rack_report,node_csv,node_xlsx,node_rack_xlsx,node_logging,node_logfile,node_netbox,node_joke_api toneMint
class node_joke,node_display,node_art,node_colors toneRose
```

## Components

### Command and setup

- [Command dispatcher](https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py): `netbox_api.py`
- [API configuration](https://github.com/scotteelp/netbox-automation/blob/main/config.py): `config.py`
- [Config validation](https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py): `netbox_api.py`

### NetBox inventory

- [Device retrieval](https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py): `netbox_api.py`
- [Age calculation](https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py): `netbox_api.py`
- [Age updates](https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py): `netbox_api.py`
- [Rack retrieval](https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py): `netbox_api.py`

### Reports and logging

- [Device export](https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py): `netbox_api.py`
- [Rack export](https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py): `netbox_api.py`
- **Device CSV**
- **Device XLSX**
- **Rack XLSX**
- [Action logging](https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py): `netbox_api.py`
- **Log file**

### Terminal presentation

- [Joke retrieval](https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py): `netbox_api.py`
- [Terminal display](https://github.com/scotteelp/netbox-automation/blob/main/netbox_api.py): `netbox_api.py`
- [ASCII art](https://github.com/scotteelp/netbox-automation/blob/main/ascii_art.py): `ascii_art.py`
- [Color definitions](https://github.com/scotteelp/netbox-automation/blob/main/color_definitions.py): `color_definitions.py`

### Other components

- **CLI user**
- **NetBox API**
- **Jokes API**

## Connections

- CLI user → Command dispatcher: runs command (evidence: `README.md`)
- Command dispatcher → Config validation: validates config (evidence: `netbox_api.py`)
- Config validation → API configuration: reads settings (evidence: `netbox_api.py`)
- Config validation → NetBox API: checks connection (evidence: `netbox_api.py`)
- Command dispatcher → Device retrieval: dispatches command (evidence: `README.md`)
- Command dispatcher → Rack retrieval: dispatches command (evidence: `README.md`)
- Command dispatcher → Age updates: dispatches command (evidence: `README.md`)
- Command dispatcher → Joke retrieval: dispatches command (evidence: `README.md`)
- Device retrieval → NetBox API: retrieves devices (evidence: `README.md`)
- Device retrieval → Age calculation: calculates age (evidence: `README.md`)
- Device retrieval → Device export: exports data (evidence: `README.md`)
- Device export → Device CSV: writes CSV (evidence: `README.md`)
- Device export → Device XLSX: writes XLSX (evidence: `README.md`)
- Rack retrieval → NetBox API: retrieves racks (evidence: `README.md`)
- Rack retrieval → Rack export: provides details (evidence: `README.md`)
- Rack export → Rack XLSX: writes workbook (evidence: `README.md`)
- Age updates → NetBox API: updates devices (evidence: `netbox_api.py`)
- Age updates → Age calculation: calculates age (evidence: `netbox_api.py`)
- Command dispatcher → Action logging: records actions (evidence: `README.md`)
- Action logging → Log file: writes logs (evidence: `README.md`)
- Joke retrieval → Jokes API: fetches joke (evidence: `netbox_api.py`)
- Joke retrieval → Terminal display: prints joke (evidence: `README.md`)
- Terminal display → ASCII art: uses artwork (evidence: `netbox_api.py`)
- Terminal display → Color definitions: uses colors (evidence: `netbox_api.py`)
