Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Ship the architecture and contributing docs the index links to
rcourtmanc37a62b3ad0c
diff --git a/frontend-modern/public/docs/ARCHITECTURE.md b/frontend-modern/public/docs/ARCHITECTURE.mdnew file mode 100644index 0000000000..67efea60dc--- /dev/null+++ b/frontend-modern/public/docs/ARCHITECTURE.md@@ -0,0 +1,190 @@+# Pulse Architecture++Pulse is a real-time infrastructure monitoring platform for **Proxmox VE**, **Proxmox Backup Server**, **Proxmox Mail Gateway**, **Docker**, **Host** systems, **Kubernetes**, and **TrueNAS**. It is built with a **Go 1.25+** backend and a **SolidJS / TypeScript** frontend, focusing on low latency, high concurrency, and a premium user experience.++## π High-Level Overview++The system runs as a single binary that serves both the API and the embedded frontend assets. It connects to infrastructure via platform-specific REST APIs and lightweight push-based agents, normalises everything into a **Unified Resource model**, and delivers real-time updates to clients over WebSocket.++```mermaid+flowchart TD+ User[Browser / Mobile] <-->|WebSocket + HTTP| Pulse[Pulse Server]+ Mobile[Mobile App] <-->|E2E Encrypted| Relay[Relay Server]+ Relay <-->|WebSocket| Pulse++ subgraph "Pulse Server (Go)"+ API[Decomposed API Router]+ WS[WebSocket Hub]+ Monitor[Reloadable Monitor]+ UR[Unified Resource Registry]+ AI[AI Subsystem]+ Config[Config Manager]+ License[Entitlements Engine]+ Audit[Audit Logger]+ end++ Pulse -->|HTTPS :8006| PVE[Proxmox VE]+ Pulse -->|HTTPS :8007| PBS[Proxmox Backup Server]+ Pulse -->|HTTPS| PMG[Proxmox Mail Gateway]+ Pulse -->|HTTPS| TrueNAS[TrueNAS SCALE/CORE]+ DockerAgent[Docker Agent] -->|HTTPS POST| API+ HostAgent[Host Agent] -->|HTTPS POST| API+ K8sAgent[Kubernetes Agent] -->|HTTPS POST| API++ Monitor --> UR+ UR --> WS+ UR --> API+```++## π Backend Architecture (Go)++All backend code lives under `cmd/`, `internal/`, and `pkg/`. The binary is assembled from `cmd/pulse/main.go` which delegates to `pkg/server.Run()`.++### Core Components++1. **Entry Point (`cmd/pulse/main.go` β `pkg/server/server.go`)**+ - Loads unified configuration via `internal/config.Load()`.+ - Initialises the RBAC manager (`pkg/auth`), audit logger (`pkg/audit`), and crypto layer (`internal/crypto`).+ - Creates a `ReloadableMonitor` that manages the lifecycle of all monitoring goroutines.+ - Starts the HTTP/HTTPS server, WebSocket hub, AI services (Patrol + Chat), and the Relay client.+ - Supports graceful hot-reload via `SIGHUP` and `.env` file watching.++2. **Unified Resource Registry (`internal/unifiedresources`)**+ - Central data model that normalises resources from **7 data sources** (`proxmox`, `pbs`, `pmg`, `docker`, `agent`, `kubernetes`, `truenas`) into a single `Resource` struct.+ - **Canonical v6 resource types**: `agent`, `vm`, `system-container`, `app-container`, `docker-host`, `k8s-cluster`, `k8s-node`, `pod`, `k8s-deployment`, `storage`, `pbs`, `pmg`, `ceph`, `physical_disk`.+ - Identity-matching engine: merges resources across sources using machine IDs, DMI UUIDs, hostnames, IPs, and MAC addresses.+ - Provides typed **views** (`NodeView`, `K8sClusterView`, etc.) for consumer-specific queries.+ - Canonical API endpoint: `GET /api/resources`.++3. **Monitoring Engine (`internal/monitoring`)**+ - **Polymorphic monitors**: Each Proxmox VE/PBS/PMG node runs in its own goroutine, polling via the platform REST API.+ - **Agent receivers** (`internal/api`): Docker, Host, and Kubernetes agents push metrics via HTTP POST to `/api/agents/{type}/report`.+ - **TrueNAS provider** (`internal/truenas`): Polls TrueNAS REST API for system info, pools, datasets, disks, alerts, ZFS snapshots, and replication tasks.+ - Enterprise/internal multi-org aware: when `PULSE_MULTI_TENANT_ENABLED=true`, each organisation gets a separate shared-process monitor namespace with its own configuration.++4. **WebSocket Hub (`internal/websocket`)**+ - Manages active browser connections with per-message compression (deflate).+ - Broadcasts state diffs to all subscribed clients; supports per-organization broadcasts for internal multi-org setups.+ - Enforces origin validation, organization-level authorization, and Enterprise/internal multi-org license gating.++5. **Decomposed API Router (`internal/api`)**+ - The router is split into focused registration files for maintainability:+ - `router_routes_auth_security.go` β Auth, OIDC, SAML, SSO, security tokens, recovery, agent install scripts.+ - `router_routes_monitoring.go` β Unified resources, metrics history, charts, recovery points, alerts, notifications, discovery.+ - `router_routes_ai_relay.go` β AI settings, Patrol, Intelligence, Chat sessions, Relay config, and the approval workflow.+ - `router_routes_org_license.go` β Organisations, RBAC, audit logs, license/entitlements, billing.+ - `router_routes_registration.go` β Config CRUD, TrueNAS connections, update management, agent profiles, system settings.+ - `router_routes_hosted.go` β Hosted/SaaS-specific signup and org admin routes.+ - Every endpoint enforces **scoped access control** (e.g., `monitoring:read`, `settings:write`, `ai:execute`, `ai:chat`).++6. **Relay Client (`internal/relay`)**+ - Maintains a persistent WebSocket tunnel to a managed relay server for **mobile remote access**.+ - Uses an ECDH key-exchange for per-channel **end-to-end encryption**.+ - Multiplexes multiple mobile sessions over a single connection with back-pressure (data limiter) and per-channel authentication.+ - Supports push notifications through the relay.+ - Gated by the `relay` license feature.++7. **AI Subsystem (`internal/ai`)**+ - **Pulse Assistant (Chat)**: Interactive LLM-powered chat with infrastructure context. Supports bring-your-own-key (BYOK) providers (OpenAI, Anthropic, Ollama, etc.) plus Claude OAuth.+ - **Pulse Patrol**: Scheduled background analysis that produces findings, predictions, and remediation plans. Autonomy levels: `monitor`, `approval`, `assisted`, `full`.+ - **Intelligence Services**: Patterns, correlations, anomalies, baselines, forecasts, and incident recording. All surfaced via `/api/ai/intelligence/*`.+ - **Safety gates**: Command execution disabled by default (`--enable-commands` opt-in); circuit breakers and scoped permissions at every layer.++8. **Entitlements & Licensing (`internal/license`)**+ - Capability-key based gating: `ai_autofix`, `rbac`, `multi_tenant`, `relay`, `agent_profiles`, `kubernetes_ai`, `ai_alerts`, etc.+ - Core tiers include **Community** (free), **Relay**, **Pro**, hosted **Cloud**, request-assisted **MSP**, and Enterprise/custom entitlements.+ - Trial lifecycle with activation, renewal, and expiry. All state exposed via `/api/license/*`.++9. **Provider-hosted MSP control plane (`internal/cloudcp`)**+ - A Stripe-free provider control plane can run one isolated Pulse runtime/container per client workspace.+ - A signed MSP license sets the provider plan and client workspace cap.+ - Pulse Account handles the provider workspace roster, sign-in-once handoff, client-bound agent install paths, and provider access surfaces.+ - Each client runtime remains a normal Pulse instance for monitoring data, alerts, webhooks, reports, users, and audit history. Shared-process organizations are for Enterprise/internal multi-org, not the default MSP boundary.++10. **Recovery Engine (`internal/recovery`)**+ - Aggregates backup data (PBS snapshots, ZFS snapshots, replication tasks) into a unified recovery point timeline.+ - Provides faceted queries: filter by type, source, status, and source health.+ - API: `/api/recovery/points`, `/api/recovery/series`, `/api/recovery/facets`, `/api/recovery/rollups`.++11. **Audit Logging (`pkg/audit`)**+ - Defence-in-depth: every mutation is logged to SQLite, optionally signed with per-tenant encryption keys.+ - Async logging mode (`PULSE_AUDIT_ASYNC`) for high-throughput environments.+ - Tenant-aware logger manager for isolated per-org audit trails.++### Data Flow++1. **Collection**:+ - **Proxmox VE / PBS / PMG**: Monitoring engine polls platform REST APIs (configurable interval, default 2 s for PVE).+ - **Docker / Host / Kubernetes**: Lightweight agents push metrics via HTTP POST on their configured interval.+ - **TrueNAS**: Provider polls the TrueNAS REST API for system, pool, dataset, disk, alert, and replication data.+2. **Normalisation**: Platform-specific responses are mapped into `unifiedresources.Resource` structs by adapters in `internal/unifiedresources/adapters.go`.+3. **Registration**: Resources are inserted into the in-memory registry, which handles deduplication, identity matching, and status computation.+4. **Broadcast**: The latest state snapshot is serialised to JSON and pushed to all connected WebSocket clients by the Hub.+5. **Persistence**: Metrics history is stored in a SQLite-backed metrics store (`pkg/metrics`) with configurable retention.++## π¨ Frontend Architecture (SolidJS)++The frontend is a modern SPA in `frontend-modern/`, built with **SolidJS** and **TypeScript**. It uses fine-grained reactivity (no Virtual DOM) for maximum performance.++### Key Technologies+- **SolidJS**: Reactive UI framework.+- **TailwindCSS** with a **semantic design token layer**: All structural colours use CSS custom-property tokens (`bg-base`, `bg-surface`, `text-base-content`, `border-border`, etc.) defined in `index.css`β components never hardcode hex values. Light/dark mode switches automatically via class-based theme resolution.+- **Vite**: Build tooling (dev server + production bundling).+- **Lucide Icons**: Icon library (imported as solid components).++### Routing & Navigation++Navigation is organised by **task**, not by platform:++| Route | Page | Purpose |+|---|---|---|+| `/infrastructure` | Infrastructure | Hosts, nodes, clusters across all platforms |+| `/workloads` | Workloads | VMs, LXCs, containers, K8s pods |+| `/storage` | Storage | Proxmox storage, ZFS pools, Ceph |+| `/recovery` | Recovery | Backups, snapshots, replication |+| `/ceph` | Ceph | Detailed Ceph cluster view |+| `/alerts/*` | Alerts | Alert rules, active alerts, history |+| `/ai/*` | AI Intelligence | Patrol findings, investigations, forecasts |+| `/settings/*` | Settings | Configuration, security, diagnostics, reporting, AI, relay |++Canonical v6 task surfaces live on the routes above; legacy aliases redirect into those canonical settings and patrol paths.++### State Management+- **WebSocket store** (`stores/websocket.ts`): Manages the live connection, reactive `State` object, reconnection logic, and per-org switching.+- **Metrics collector** (`stores/metricsCollector.ts`): Buffers time-series data for sparklines and historical charts.+- **AI stores** (`stores/aiChat.ts`, `stores/aiIntelligence.ts`): Manage chat sessions and patrol findings.+- **License store** (`stores/license.ts`): Tracks plan tier, feature flags, and multi-tenant state.+- **System settings store** (`stores/systemSettings.ts`): Caches server-side preferences (for example theme and feature toggles).++### Component Design+- **Shared primitives** in `components/shared/`: `Card`, `Button`, `Toggle`, `FilterButtonGroup`, `Table` β all mapped to the semantic design tokens.+- **Lazy-loaded pages**: All top-level pages are loaded via `lazy()` with optional preloading after initial render.+- **Virtual table windowing**: Large resource lists use virtualised rendering for smooth scrolling at scale.+- **Command Palette** (`Cmd/Ctrl+K`): Quick-access command launcher.+- **Keyboard shortcuts**: `g i` β Infrastructure, `g w` β Workloads, `g s` β Storage, `g b` β Recovery, `g a` β Alerts, `g t` β Settings, `/` β Search.++### Mobile Experience+- **MobileNavBar** component: Bottom tab bar for touch navigation.+- **Relay integration**: The mobile app connects through the relay protocol for encrypted remote access.++## π Security++- **Encryption at Rest**: Sensitive config (passwords, API keys) encrypted with AES-GCM via `internal/crypto`. Each tenant can have its own encryption key.+- **Scoped API Tokens**: Tokens carry explicit scopes (`monitoring:read`, `settings:write`, `ai:chat`, `ai:execute`, `docker:report`, etc.). Endpoints enforce scope checks before processing.+- **RBAC**: Role-based access control via `pkg/auth` with file-backed persistence. Resources: `users`, `settings`, `monitoring`.+- **SSO**: OIDC and SAML providers with per-provider configuration and multi-provider support.+- **Agent Commands**: Disabled by default for security. Operators must opt in with `--enable-commands`.+- **Audit Trail**: Every mutation logged to per-tenant SQLite databases with optional cryptographic signatures.+- **Rate Limiting**: Per-endpoint and per-tenant rate limiting with configurable thresholds.+- **CSRF Protection**: Token-based CSRF prevention on mutation endpoints.+- **Recovery Mode**: Localhost-only endpoint for emergency auth recovery with time-limited tokens.++## π Deployment++Pulse is distributed as:++1. **Docker Container**: Multi-stage build producing a minimal image with the Go binary + embedded frontend.+2. **Single Binary**: The frontend is compiled into the Go binary using `go:embed` (`internal/api/frontend_embed.go`), enabling single-file deployment.+3. **Kubernetes Helm Chart**: For cluster deployments with configurable replicas and persistence.+4. **Systemd Service**: For bare-metal or VM installations with `.env`-based configuration and `SIGHUP` reload support.+5. **Proxmox LXC Helper Script**: One-line install inside a Proxmox helper-scripts container.diff --git a/frontend-modern/public/docs/CONTRIBUTING.md b/frontend-modern/public/docs/CONTRIBUTING.mdnew file mode 100644index 0000000000..9ede8a394e--- /dev/null+++ b/frontend-modern/public/docs/CONTRIBUTING.md@@ -0,0 +1,209 @@+# Contributing to Pulse++Pulse is maintained as a single-maintainer project. It is developed with+extensive AI assistance, openly declared. See+[docs/AI_TRANSPARENCY.md](docs/AI_TRANSPARENCY.md) for how AI is used and+where its output is labelled.++I am not accepting unsolicited external pull requests for this repository.+If you have found a bug, want to propose a feature, or have a concrete+improvement idea, please open an issue instead.++This document also keeps the local development notes needed to reproduce,+debug, and validate issues across the Go backend, SolidJS/TypeScript frontend,+and installer tooling.++## What To Open++- Bug reports: use the bug report issue form and include exact reproduction+ steps, Pulse version, installation type, and any relevant logs or diagnostics.+- Feature requests: open an issue describing the problem you want solved, the+ workflow you are trying to improve, and any constraints that matter.+- Questions and support requests: use GitHub Discussions when you need help,+ troubleshooting, or general guidance rather than a tracked defect.+- Security issues: follow [SECURITY.md](SECURITY.md) instead of opening a public+ report for sensitive problems.++## Pull Request Policy++- External pull requests are not part of the normal contribution flow for this+ repository.+- Unsolicited pull requests may be closed without detailed review, even when the+ underlying idea is valid.+- If I want code help on a specific issue, I will explicitly ask for it there.+- Opening an issue first is the right path; it lets me confirm whether the+ change fits the product direction before anyone spends time building a patch.++## How To Make An Issue Useful++- Search existing issues before opening a new one.+- Keep reproduction steps minimal and exact.+- State the Pulse version and image or package you are actually running.+- Include screenshots, logs, API output, or diagnostics when they clarify the+ problem.+- Separate bug reports from feature requests; avoid mixing both into one issue.++---++## Project Overview++- **Backend (`cmd/`, `internal/`, `pkg/`)** β Go 1.25+ web server that embeds+ the built frontend and exposes REST + WebSocket APIs.+- **Architecture (`ARCHITECTURE.md`)** β High-level system design diagrams and explanations.+- **Frontend (`frontend-modern/`)** β Vite + SolidJS app built with TypeScript.+- **Agents (`cmd/pulse-*-agent`)** β Go binaries distributed alongside Pulse for+ host and Docker telemetry.+- **Documentation (`docs/`)** β Markdown-based guides published to users and+ referenced from the README.+- **Scripts (`scripts/`)** β Bash installers and helpers bundled for+ curl-based distribution.++---++## Getting Started++```bash+git clone https://github.com/rcourtman/Pulse.git+cd Pulse++# Install dependencies+brew install go node npm # or use your distro equivalents++# Install JS deps+cd frontend-modern+npm install+cd ..+```++### Hot Reload Dev Loop++```bash+npm run dev # Frontend shell on :5173, backend on :7655+npm run mock:on # Optional: enable mock data+```++Use `http://127.0.0.1:5173` in the browser for local frontend development. The+frontend dev shell proxies `/api` and `/ws` to the backend on `:7655`; do not+switch your browser to `:7655` unless you are debugging the backend directly.+The managed dev runtime login defaults to `admin` / `adminadminadmin` unless+you override it with `HOT_DEV_AUTH_USER` and `HOT_DEV_AUTH_PASS`.++Backend-only hot reload (requires `air`):++```bash+air -c .air.toml+```++Set `HOT_DEV_USE_PRO=true` to build the Pro variant when available.++Mock mode is supported for development, but the internal developer notes are not shipped in this repository.++---++## Backend Workflow++- Build: `go build ./cmd/pulse`+- Tests: `go test ./...`+- Lint: `golangci-lint run ./...` (install via `go install` if missing)+- Formatting: `gofmt -w ./cmd ./internal ./pkg`++Key entry points:+- HTTP router lives in `internal/api`.+- Monitoring engines live under `internal/monitor`.+- Configuration parsing resides in `internal/config`.++When adding new API endpoints, document them in `docs/API.md` and provide+examples where possible.++---++## Frontend Workflow++- Managed dev runtime: `npm run dev`+- Runtime status: `npm run dev:status`+- Runtime logs: `npm run dev:logs`+- Managed restart: `npm run dev:restart`+- Managed backend restart: `npm run dev:backend-restart`+- Browser proof pack: `npm run dev:verify`+- Foreground managed launcher: `npm run dev:foreground`+- Frontend-only escape hatch: `cd frontend-modern && npm run dev:frontend-only`+- Tests: `npm run test`+- Lint: `npm run lint`+- Format: `npm run format`++The same managed runtime wrappers are available from `frontend-modern/` if you+start there by habit, so `npm run dev`, `npm run dev:status`, and+`npm run dev:verify` behave the same way from either workspace.+- Production build: `npm run build` (syncs the Go embed copy in+ `internal/api/frontend-modern/dist` automatically).++Use SolidJS patterns (signals, memos, createEffect) and the shared design-system+components in `components/shared/`. Add screenshots when introducing new+UI-heavy features.++Design-system lint rules are enforced as CI blockers. Avoid hardcoded structural+light/dark classes and broken utility chains; use semantic tokens from+`frontend-modern/DESIGN_SYSTEM.md`.++---++## Installers & Scripts++- Centralised guidance: `docs/internal/SCRIPT_LIBRARY.md`+- Bundling: `make bundle-scripts`+- Tests: `scripts/tests/run.sh` plus integration suites under+ `scripts/tests/integration/`++Document rollout plans and kill switches in `MIGRATION_SCAFFOLDING.md` so future contributors know how to disable risky changes.++---++## Documentation Standards++- Author or update guides in `docs/` when behaviour changes.+- Organise new topics through `docs/README.md` so they appear in the docs index.+- Avoid marketing copy in technical docsβsave that for `README.md` or+ external sites.+- Keep instructions evergreen; put release-specific notes in+ `docs/RELEASE_NOTES.md`.++Run a quick link check (`npm run lint-docs` if available, or `markdownlint`)+before submitting large doc updates.++---++## Testing Expectations++- Every PR should note the tests run (`go test`, `npm test`, `scripts/tests/run.sh`).+- Add regression coverage when fixing bugs.+- Mention manual verification steps (e.g., βProxmox LXC installer tested on+ PVE 8.1β) if automated coverage is not feasible.++---++## Coding Guidelines++- Adhere to existing formatting tools (`gofmt`, `prettier`, `eslint`).+- Name Go packages with short, meaningful identifiers (avoid `util`).+- Keep functions focused; prefer small helpers over large monoliths.+- Prefer context-aware logging (`logger.Named("component")`) in new Go code.+- Ensure secrets never reach logs and redact sensitive fields in API responses.++---++## Submitting Requested Changes++For maintainer-requested code help on a tracked issue:++1. Link the issue where the maintainer requested the patch.+2. Fork + branch (`git checkout -b feature/my-change`).+2. Make your edits and run relevant tests.+3. Update docs and changelog entries as needed.+4. Open a PR describing:+ - What changed+ - Why it changed+ - Testing performed+ - Rollout / migration concerns++Reviewers will focus on correctness, security, and upgrade paths, so call out+anything unusual up front.diff --git a/frontend-modern/src/features/docs/__tests__/docMarkdown.test.ts b/frontend-modern/src/features/docs/__tests__/docMarkdown.test.tsindex 448db4cc38..e27d6b476f 100644--- a/frontend-modern/src/features/docs/__tests__/docMarkdown.test.ts+++ b/frontend-modern/src/features/docs/__tests__/docMarkdown.test.ts@@ -48,6 +48,14 @@ describe('resolveDocLink', () => {expect(resolveDocLink('README', '../../TERMS.md')).toBe('/docs/TERMS');});+ // Documents shipped from the repository root, such as CONTRIBUTING.md, link+ // as docs/X.md because that is the path from the root. They ship flat into+ // the docs root, so the prefix has to collapse rather than nest.+ it('collapses the docs/ prefix used by root-level documents', () => {+ expect(resolveDocLink('CONTRIBUTING', 'docs/AI_TRANSPARENCY.md')).toBe('/docs/AI_TRANSPARENCY');+ expect(resolveDocLink('CONTRIBUTING', 'SECURITY.md')).toBe('/docs/SECURITY');+ });+it('preserves fragments', () => {expect(resolveDocLink('README', 'CONFIGURATION.md#api-tokens')).toBe('/docs/CONFIGURATION#api-tokens',diff --git a/frontend-modern/src/utils/__tests__/docsLinks.test.ts b/frontend-modern/src/utils/__tests__/docsLinks.test.tsindex 332725dd60..5770b2d833 100644--- a/frontend-modern/src/utils/__tests__/docsLinks.test.ts+++ b/frontend-modern/src/utils/__tests__/docsLinks.test.ts@@ -82,7 +82,12 @@ describe('docsLinks', () => {// its repo source and a new one cannot be added without a source.const shippedDocsRoot = path.join(frontendRoot, 'public', 'docs');// Shipped from the repository root rather than docs/.- const rootSourcedDocs = new Set(['SECURITY.md', 'TERMS.md']);+ const rootSourcedDocs = new Set([+ 'SECURITY.md',+ 'TERMS.md',+ 'ARCHITECTURE.md',+ 'CONTRIBUTING.md',+ ]);function collectShippedDocs(dir: string, prefix = ''): string[] {return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {