Dashboard

Dashboard

Extensible micro-frontend shell for admin dashboards with contributor system, real-time updates, and Go-JS bridge

Overview

github.com/xraph/forge/extensions/dashboard provides an extensible micro-frontend dashboard shell for Forge applications. It is powered by ForgeUI and uses a contributor-based architecture where extensions register pages, widgets, and settings that are merged into a unified admin dashboard.

The dashboard supports both local contributors (in-process, rendering gomponents nodes) and remote contributors (separate HTTP services whose HTML fragments are proxied and embedded). Navigation, layout, and theming are handled automatically by the shell.

What It Registers

ServiceDI KeyType
Dashboard extensiondashboard*Extension

Routes are mounted on the Forge HTTP router during Start() at the configured base path (default /dashboard).

Quick Start

package main

import (
    "log"
    "time"

    "github.com/xraph/forge"
    "github.com/xraph/forge/extensions/dashboard"
)

func main() {
    app := forge.New(
        forge.WithAppName("my-app"),
        forge.WithAppVersion("1.0.0"),
    )

    if err := app.RegisterExtension(dashboard.NewExtension(
        dashboard.WithTitle("My Dashboard"),
        dashboard.WithBasePath("/dashboard"),
        dashboard.WithRealtime(true),
        dashboard.WithRefreshInterval(30 * time.Second),
        dashboard.WithExport(true),
        dashboard.WithTheme("auto"),
    )); err != nil {
        log.Fatalf("failed to register dashboard: %v", err)
    }

    // Dashboard available at http://localhost:8080/dashboard
    if err := app.Run(); err != nil {
        log.Fatalf("application error: %v", err)
    }
}

Programmatic Access

Retrieve the dashboard extension from the DI container to access its subsystems:

ext, _ := forge.InjectType[*dashboard.Extension](app.Container())

// Data collection
collector := ext.Collector()
overview := collector.CollectOverview(ctx)
health := collector.CollectHealth(ctx)
metrics := collector.CollectMetrics(ctx)

// Historical data
history := ext.History()
all := history.GetAll()

// Contributor registry
registry := ext.Registry()

// Bridge (Go-JS function calls)
bridge := ext.DashboardBridge()

// SSE real-time broker
broker := ext.SSEBroker()

// Auth checker (when auth is enabled)
checker := ext.AuthChecker()

HTTP Endpoints

All routes are under the configured base path (default /dashboard):

Pages (ForgeUI)

MethodPathDescription
GET/Dashboard overview
GET/healthHealth status page
GET/metricsMetrics page
GET/servicesServices page
GET/ext/:name/pages/*Contributor extension pages
GET/ext/:name/widgets/:idWidget HTMX fragments
GET/remote/:name/pages/*Remote contributor pages
GET/remote/:name/widgets/:idRemote contributor widgets

Authentication (when EnableAuth is true)

MethodPathDescription
GET/auth/loginLogin page
POST/auth/loginLogin form submission
GET/auth/logoutLogout page
GET/auth/registerRegister page (if provider supplies it)
POST/auth/registerRegister form submission

Auth page paths are configurable. The table above shows defaults.

JSON API

MethodPathDescription
GET/api/overviewApplication overview
GET/api/healthHealth status
GET/api/metricsCurrent metrics
GET/api/servicesService list
GET/api/service-detail?name=XService detail
GET/api/historyMetric history
GET/api/metrics-reportAggregated metrics report
GET/api/search?q=XFederated search (if enabled)
GET/api/sse/statusSSE connection status

Export

MethodPathDescription
GET/export/jsonFull JSON snapshot
GET/export/csvMetrics as CSV
GET/export/prometheusPrometheus text format

Real-Time and Bridge

MethodPathDescription
GET/sseSSE event stream
POST/bridge/callBridge function call
GET/bridge/stream/Bridge streaming (SSE)

Settings

MethodPathDescription
GET/settingsAggregated settings index
GET/ext/:name/settings/:idContributor settings form
POST/ext/:name/settings/:idSubmit settings form

Key Concepts

  • Contributor System -- extensions register pages, widgets, and settings via a manifest. Local contributors render gomponents; remote contributors serve HTML fragments over HTTP.
  • ForgeUI Shell -- layouts (root, dashboard, base, full, settings, auth), HTMX partial navigation, Alpine.js state management, and automatic sidebar construction from contributor manifests.
  • Authentication -- optional page access levels (public, protected, partial), auth page provider for login/register flows, auth-aware user menu in topbar, HTMX-aware redirects. Decoupled from any specific auth provider.
  • Go-JS Bridge -- call Go functions from the browser via Alpine.js $go() magic helpers. 8 built-in dashboard functions plus custom function registration.
  • SSE Real-Time -- server-sent events push metric, health, and contributor state updates to connected browsers.
  • Federated Search -- contributors implementing SearchableContributor are searched in parallel across the entire dashboard.
  • Data Export -- export metrics and health data in JSON, CSV, or Prometheus format.

Detailed Pages

How is this guide?

On this page