⬅ Back to Home | Overview | Setup | Usage | Maintenance | Technology Choices | Future Improvements |
This page describes how Host Monitor is structured, how data flows through the system, and the key runtime behaviors.
What’s shown: Angular UI, WebSocket server, Go services (MonitorService
, MetricsStore
), persistence (PostgreSQL), and core data models. The Angular UI is embedded into the Go binary using go:embed
and served by the backend (no separate backend/web
directory).
What’s shown: Method‑level view of domain models (HostMetrics
, DTO), services (MonitorService
, MetricsStore
), settings/threshold API, and relationships.
Flow: Browser → Angular Dashboard → WebSocket → Backend → Pingers → DB → WebSocket → UI.
Flow: Pingers report → MetricsService
aggregates → DB upsert → broadcast JSON over /ws
→ UI renders.
Flow: UI slider (debounced) → send { setThreshold }
over /ws
→ backend acks and applies → UI toast.
Strategy: Exponential backoff (1s, 2s, 4s … max 30s). On reconnect, UI resubscribes and resumes live updates.
Rules:
backend/web
)The production Angular build is embedded in the Go binary. At build time we copy the UI artifacts into the backend and embed them via go:embed
:
ui/dist/host-monitor-ui/browser/ → backend/internal/handlers/dist/browser/
Example (in internal/handlers/static.go
):
//go:embed dist/browser/*
var uiFS embed.FS
var staticFS, _ = fs.Sub(uiFS, "dist/browser")
// mux.Handle("/", http.FileServer(http.FS(staticFS)))
Why:
The Host Monitor repository is organized into the following main components:
host-monitor
.
├── backend # Go backend service
│ ├── cmd # Entry points (CLI / main)
│ ├── deployments # systemd, Docker, Kubernetes manifests
│ ├── internal # Core app modules (config, services, handlers, models, utils)
│ │ ├── handlers
│ │ │ └── dist
│ │ │ └── browser # Embedded Angular UI (copied from ui/dist/host-monitor-ui/browser)
│ ├── migrations # SQL migrations for PostgreSQL
│ ├── pkg # Reusable packages (ping, websocket, etc.)
│ ├── scripts # Helper scripts (e.g., ping-many.sh)
│ ├── Dockerfile # Backend container build
│ ├── go.mod / go.sum # Go dependencies
│ ├── host-monitor # Compiled binary (after build; git-ignored)
│ ├── Makefile # Build/install tasks
│ └── README.md
├── docs # Documentation site
│ ├── diagrams # Architecture, sequence, and flow diagrams
│ ├── images # Screenshots and visuals for docs
│ ├── architecture.md # This page
│ ├── future_improvements.md
│ ├── index.md
│ ├── maintenance.md
│ ├── overview.md
│ ├── setup.md
│ ├── tech.md
│ └── usage.md
├── ui # Angular frontend
│ ├── dist # Production build output
│ ├── node_modules # Frontend dependencies
│ ├── public # Static assets
│ ├── src # Angular components, services, styles
│ ├── angular.json # Angular CLI config
│ ├── Dockerfile # UI container build
│ ├── package*.json # NPM dependencies
│ ├── proxy.conf.json # Dev proxy settings
│ ├── README.md
│ └── tsconfig*.json # TypeScript configs
├── docker-compose.dev.yml # Multi-container dev environment
└── README.md # Root project overview
Key conventions:
backend/internal/handlers/dist/browser
..md
files you’re reading now).public.checks (host, up, latency_ms, packet_loss, checked_at)
.Overview | Setup | Usage | Maintenance | Technology Choices | Future Improvements |
© 2025 Host Monitor • GitHub Repo