88ab5b917e
Renames the Python package directory, CLI command, env var prefix, docker-compose service/container/image, Postgres role/db, and all visible branding. Marketing form is "Fabled Steward". Clean break from the previous rebrand: drops the fabledscryer→roundtable import shim in __init__.py and the FABLEDSCRYER_* env var fallback in config.py and migrations/env.py. Env vars are now STEWARD_* only. Heads-up for existing deployments: - Postgres user/db renamed fabledscryer → steward in docker-compose.yml. Existing volumes need the role/db renamed inside Postgres, or override POSTGRES_USER/POSTGRES_DB to keep the old names. - Host-agent systemd unit is now steward-agent.service. Existing agents keep running under the old name; reinstall to switch. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
5.4 KiB
5.4 KiB
Code Map
Quick reference for where key functions, models, and entry points live in the codebase.
Application Bootstrap
| What | File | Function / Class |
|---|---|---|
| App factory | steward/app.py |
create_app() |
| CLI entry point | steward/cli.py |
main() |
| Bootstrap config loading | steward/config.py |
load_bootstrap() |
| Secret key resolution | steward/config.py |
_resolve_secret_key() |
| DB engine init | steward/database.py |
init_db() |
| Core migrations | steward/core/migration_runner.py |
run_core_migrations() |
| Plugin migrations | steward/core/migration_runner.py |
run_plugin_migrations() |
| Core task registration | steward/app.py |
_register_core_tasks() |
| Scheduler loop | steward/core/scheduler.py |
start_scheduler() |
Settings System
| What | File | Function |
|---|---|---|
| All defaults | steward/core/settings.py |
DEFAULTS dict |
| Read a setting | steward/core/settings.py |
get_setting(session, key) |
| Write a setting | steward/core/settings.py |
set_setting(session, key, value) |
| Read all settings | steward/core/settings.py |
get_all_settings(session) |
| Sync load at startup | steward/core/settings.py |
load_settings_sync(db_url) |
| Extract SMTP dict | steward/core/settings.py |
to_smtp_cfg(settings) |
| Extract webhook dict | steward/core/settings.py |
to_webhook_cfg(settings) |
| Extract Ansible dict | steward/core/settings.py |
to_ansible_cfg(settings) |
| Extract plugins dict | steward/core/settings.py |
to_plugins_cfg(settings) |
Plugin System
| What | File | Function |
|---|---|---|
| Plugin loading | steward/core/plugin_manager.py |
load_plugins(app) |
| ScheduledTask dataclass | steward/core/scheduler.py |
ScheduledTask |
| Task runner | steward/core/scheduler.py |
start_scheduler(tasks) |
Alert Pipeline
| What | File | Function |
|---|---|---|
| Write metric + evaluate alerts | steward/core/alerts.py |
record_metric(session, source_module, resource_name, metric_name, value) |
| Init alert pipeline | steward/core/alerts.py |
init_alerts(app) |
| Rule evaluation | steward/core/alerts.py |
_evaluate_rule() (internal) |
| Notification dispatch | steward/core/alerts.py |
_dispatch_notification() (internal) |
| Email + webhook send | steward/core/notifications.py |
dispatch_notifications() |
Monitors
| What | File | Function |
|---|---|---|
| Ping a host | steward/monitors/ping.py |
ping_check(host, session) |
| DNS check a host | steward/monitors/dns.py |
dns_check(host, session) |
| Data cleanup | steward/core/cleanup.py |
run_cleanup(app) |
Auth
| What | File | Function / Class |
|---|---|---|
| Role-based access decorator | steward/auth/middleware.py |
@require_role(UserRole.X) |
| Login / session handling | steward/auth/middleware.py |
login_user(), logout_user() |
| User count (for first-run) | steward/auth/middleware.py |
get_user_count(app) |
Data Models
| Model | File | Table |
|---|---|---|
Host |
steward/models/hosts.py |
hosts |
PingResult |
steward/models/monitors.py |
ping_results |
DnsResult |
steward/models/monitors.py |
dns_results |
AlertRule |
steward/models/alerts.py |
alert_rules |
AlertState |
steward/models/alerts.py |
alert_states |
AlertEvent |
steward/models/alerts.py |
alert_events |
PluginMetric |
steward/models/metrics.py |
plugin_metrics |
AnsibleRun |
steward/models/ansible.py |
ansible_runs |
User |
steward/models/users.py |
users |
AppSetting |
steward/models/settings.py |
app_settings |
TraefikMetric |
plugins/traefik/models.py |
traefik_metrics |
SQLAlchemy Base |
steward/models/base.py |
(shared declarative base) |
HTTP Routes
| URL pattern | Blueprint | File |
|---|---|---|
/ (dashboard) |
dashboard_bp |
steward/dashboard/routes.py |
/auth/login, /auth/logout |
auth_bp |
steward/auth/routes.py |
/hosts/ |
hosts_bp |
steward/hosts/routes.py |
/ping/, /ping/rows, /ping/settings |
ping_bp |
steward/ping/routes.py |
/dns/, /dns/rows |
dns_bp |
steward/dns/routes.py |
/alerts/ |
alerts_bp |
steward/alerts/routes.py |
/ansible/ |
ansible_bp |
steward/ansible/routes.py |
/settings/ |
settings_bp |
steward/settings/routes.py |
/plugins/traefik/, /plugins/traefik/widget |
traefik_bp |
plugins/traefik/routes.py |
/health |
(inline) | steward/app.py |
Templates
| Template | Purpose |
|---|---|
steward/templates/base.html |
Layout, navigation, full CSS design system |
steward/templates/dashboard/index.html |
Dashboard with stat strip and widget grid |
steward/templates/ping/rows.html |
HTMX fragment: ping pill rows (shared by dashboard and /ping/) |
steward/templates/ping/index.html |
Full /ping/ page |
steward/templates/dns/rows.html |
HTMX fragment: DNS status rows |
steward/templates/dns/index.html |
Full /dns/ page |
plugins/traefik/templates/traefik/widget.html |
HTMX fragment: Traefik dashboard widget |
plugins/traefik/templates/traefik/index.html |
Full Traefik detail page |
Migrations
| Location | Covers |
|---|---|
steward/migrations/versions/ |
Core schema (hosts, users, monitors, alerts, app_settings) |
plugins/traefik/migrations/versions/ |
traefik_metrics table |
alembic.ini |
Alembic config; version_locations lists all migration directories |