Skip to main content
The Dorgu Platform is a full-stack application combining a Go backend with a React frontend, compiled into a single binary with embedded static assets.

Technology stack

Data flow

Project structure

Backend components

Kubernetes watcher

The watcher uses k8s.io/client-go/dynamic/dynamicinformer to watch clusterpersonas.dorgu.io/v1 resources. It maintains a thread-safe in-memory cache (sync.RWMutex-protected map) and pushes events to a Go channel for WebSocket broadcast. The informer handles three event types:
  • Add — New ClusterPersona created, added to cache
  • Update — ClusterPersona modified, cache entry replaced
  • Delete — ClusterPersona removed from cache

REST API

Two endpoints served by gorilla/mux:
  • GET /api/clusters — Returns all cached clusters
  • GET /api/clusters/{name} — Returns a single cluster by name
The API layer converts internal watcher types to JSON-serializable models.

WebSocket hub

A broadcast hub manages all connected clients:
  • Clients register on connect, unregister on disconnect
  • The hub runs a main event loop in a goroutine
  • Events from the watcher channel are broadcast to all clients
  • Each client has a buffered send channel to prevent slow clients from blocking

Static file server

Frontend assets are embedded in the Go binary using //go:embed. The server serves static files with SPA fallback — any unmatched route returns index.html for client-side routing.

Frontend components

React Query

Server state is managed by TanStack Query v5:
  • Query keys: ['clusters'] for list, ['cluster', name] for detail
  • Stale time: 10 seconds
  • Cache invalidation: Triggered by WebSocket events

WebSocket hook

The useWebSocket hook connects at the app root level and:
  • Auto-connects on mount
  • Listens for cluster.* events
  • Invalidates React Query caches on events
  • Auto-reconnects after 5 seconds on disconnect

Embedding

The platform can be embedded in any Go application via the pkg/platform package:
The dorgu CLI uses this package for the dorgu platform serve command.

Design decisions

Development guide

Run in development mode with hot reload

REST API

API endpoint reference